import argparse
from pynsdk.biometrics import NBiometricType, NSubject, NBiometricCaptureOptions, NLivenessMode, NFace
from pynsdk.biometric_client import NBiometricClient
from pynsdk.core import NAsyncStatus
from pynsdk.devices.ncamera import NCamera
from pynsdk.devices.ndevice import NDeviceType
from pynsdk.licensing import NLicense
import cv2
def main(args):
NLicense.obtain("/local", 5000, "FaceClient")
client = NBiometricClient.create()
client.set_biometric_types(NBiometricType.Face)
client.use_device_manager(True)
client.initialize()
client.set_property("Faces.LivenessMode", NLivenessMode.nlmPassive)
device_manager = client.get_device_manager()
device_manager.set_device_types(NDeviceType.nCamera)
device_manager.init_devices()
device = device_manager.get_device(args.camera_idx)
client.set_face_capture_device(device)
subject = NSubject.create()
face = NFace.create()
face.set_capture_options(NBiometricCaptureOptions.Stream | NBiometricCaptureOptions.Manual)
subject.faces.add(face)
status = client.capture_async(subject)
#wait 1s
if not (NCamera(device).is_capturing()):
cv2.waitKey(1000)
while(status.get_status() != NAsyncStatus.naCompleted):
nframe = face.get_image()
frame = nframe.to_numpy()
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
face.objects
if face.objects.count > 0:
face_attribute = face.objects[0]
rect = face_attribute.get_rect()
left_eye = face_attribute.get_left_eye_center_point()
right_eye = face_attribute.get_right_eye_center_point()
mout_center = face_attribute.get_mouth_center_point()
cv2.rectangle(frame, (rect.x, rect.y), (rect.x + rect.width, rect.y + rect.height), (0, 255, 0), 1)
cv2.circle(frame, (int(left_eye.x), int(left_eye.y)), 1, (0, 255, 0), -1)
cv2.circle(frame, (int(right_eye.x), int(right_eye.y)), 1, (0, 255, 0), -1)
cv2.circle(frame, (int(mout_center.x), int(mout_center.y)), 1, (0, 255, 0), -1)
cv2.putText(frame, f'Liveness: {face_attribute.get_liveness_score()}', (rect.x, rect.y), cv2.FONT_HERSHEY_DUPLEX, 0.67, (0, 0, 0), thickness=1)
feature_points = face_attribute.feature_points
for i in range(0, feature_points.count):
cv2.circle(frame, (int(feature_points[i].x), int(feature_points[i].y)), 1, (0, 255, 0), -1)
cv2.imshow('frame', frame)
key = cv2.waitKey(1)
if key == ord('q'):
break
if key == ord('s'):
client.force_start()
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Face liveness sample')
parser.add_argument('--camera_idx', type=int, default=0, help='camera index')
args_ = parser.parse_args()
main(args_)
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Neurotec_Biometric_13_0_Python_Win_2023-04-17.zip (22个子文件)
images
BTH_0002_R_009.bmp 301KB
S2002R02_tem 3KB
S2002R03.jpg 23KB
S2002R02.jpg 22KB
BTH_0002_R_013.bmp 301KB
C1_S1_I8.tiff 352KB
020_tem 3KB
S2002R01_tem 3KB
S2002R04.jpg 24KB
020.bmp 301KB
S2002R01.jpg 25KB
C1_S1_I8.jpg 46KB
BTH_0002_R_005.bmp 301KB
tutorials
biometrics
face_enroll.py 1KB
finger_enroll.py 916B
face_icao_check.py 1KB
face_create_and_verify.py 2KB
verify.py 1KB
iris_enroll.py 1016B
finger_get_minutia.py 1KB
iris_segment.py 2KB
face_liveness.py 3KB
共 22 条
- 1
资源评论
xiamentingtao
- 粉丝: 516
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功