人脸识别阈值

This commit is contained in:
曹前明 2022-10-20 17:54:58 +08:00
parent 885497f651
commit 97710370b6
3 changed files with 7 additions and 6 deletions

View File

@ -74,14 +74,15 @@ class EmployeeCreateUpdateSerializer(CustomModelSerializer):
instance.user.save() instance.user.save()
# 同时去除门禁授权 # 同时去除门禁授权
if settings.DAHUA_ENABLED and dhClient: if settings.DAHUA_ENABLED and dhClient:
if instance.type == 'employee': # 如果是正式员工或相关方且有门禁权限:
if instance.type in ['employee', 'remployee'] and instance.third_info.get('dh_face_card', None):
start_time = None start_time = None
end_time = None end_time = None
if instance.job_state == 20 and old_job_state == 10: # 离职 if instance.job_state == 20 and old_job_state == 10: # 离职
now = datetime.now() now = datetime.now()
start_time = now start_time = now
end_time = now + timedelta(minutes=60) end_time = now + timedelta(minutes=60)
elif instance.job_state == 10 and old_job_state == 20: # 重新在职 elif instance.job_state == 10 and old_job_state == 20 and instance.type == 'employee': # 正式员工重新在职
now = datetime.now() now = datetime.now()
start_time = now start_time = now
end_time = now + timedelta(days=7300) end_time = now + timedelta(days=7300)

View File

@ -258,7 +258,7 @@ class DhClient:
} }
self.request(**dhapis['face_bind'], json=json_data) self.request(**dhapis['face_bind'], json=json_data)
def face_deploy(self): def face_deploy(self, minSim: int = 90):
params = { params = {
"id": "001001001", "id": "001001001",
@ -271,8 +271,8 @@ class DhClient:
_, res = self.request(**dhapis['dev_tree'], params=params) _, res = self.request(**dhapis['dev_tree'], params=params)
for i in json.loads(res): for i in json.loads(res):
json_data = { json_data = {
"minSimilarity": "80", "minSimilarity": str(minSim),
"dpMinSimilarity": 80, "dpMinSimilarity": minSim,
"surveyType": ["1"], "surveyType": ["1"],
"groups": str(settings.DAHUA_FACEGROUPID_1), "groups": str(settings.DAHUA_FACEGROUPID_1),
"chnId": i['id'] "chnId": i['id']

View File

@ -396,5 +396,5 @@ class DhCommonViewSet(CreateModelMixin, CustomGenericViewSet):
人脸库同步到所有智能设备 人脸库同步到所有智能设备
""" """
dhClient.face_deploy() dhClient.face_deploy(request.data.get('minSim', 90))
return Response() return Response()