@@ -378,7 +378,7 @@ def align_face_with_landmarks(face_bgr, orig_frame, bbox, output_size=(128, 128)
378
378
landmarks = np .array ([* landmarks [:2 ],mouth_center ])[:2 ]
379
379
# 5. Reference points (ArcFace), scaled to output_size
380
380
ref_landmarks = get_scaled_ref_landmarks ((128 ,128 ),zoom = 1 )[:2 ] # + (bbox[0],bbox[1])
381
- ref_landmarks_anti_spoof = get_scaled_ref_landmarks ((128 ,128 ),zoom = 1 / anti_spoof_size_boost )[:2 ]
381
+ ref_landmarks_anti_spoof = get_scaled_ref_landmarks ((128 ,128 ),zoom = 2 / anti_spoof_size_boost )[:2 ]
382
382
383
383
# 6. Estimate affine transform
384
384
tform , _ = cv2 .estimateAffinePartial2D (landmarks , ref_landmarks , method = cv2 .LMEDS )
@@ -483,9 +483,7 @@ def score(rec_embedding):
483
483
if not ret :
484
484
break
485
485
frame = ensure_bgr (frame )
486
-
487
-
488
- if not image_quality_score (frame )> 0.3 :
486
+ if not image_quality_score (frame )> 0.2 :
489
487
failed_find_attempts [current_cap ] += 1
490
488
continue
491
489
else :
@@ -506,7 +504,7 @@ def score(rec_embedding):
506
504
for (xmin , ymin , xmax , ymax , conf , _ ) in boxes :
507
505
# Crop the detected face from the original frame
508
506
face_crop = frame [ymin :ymax , xmin :xmax ]
509
- if not image_quality_score (face_crop ) > 0.2 :
507
+ if not image_quality_score (face_crop ) > 0.25 :
510
508
continue
511
509
did_try = 1
512
510
@@ -518,7 +516,7 @@ def score(rec_embedding):
518
516
anti_spoof_face = cv2 .resize (anti_spoof_face ,[80 ,80 ]).transpose (2 , 0 , 1 )[np .newaxis , ...].astype (np .float32 )
519
517
anti_spoof_result = compiled_anti_spoof ([anti_spoof_face ])[compiled_anti_spoof .output (0 )]
520
518
label = np .argmax (anti_spoof_result )
521
- value = anti_spoof_result [0 ][label ]/ 2
519
+ value = anti_spoof_result [0 ][label ]
522
520
523
521
if label != 1 :
524
522
spoof_attempts += 1
@@ -620,7 +618,7 @@ def add_face(cap_path=...,face_name=...,complete=False):
620
618
rec_face = stretch_contrast (face_crop )
621
619
rec_face , anti_spoof_face = align_face_with_landmarks (rec_face , frame , (xmin ,ymin ,xmax ,ymax ))
622
620
#rec_face=gray_world_correction(rec_face)
623
- frame [ymin :ymax , xmin :xmax ] = cv2 .resize (rec_face ,crop_dims )
621
+ frame [ymin :ymax , xmin :xmax ] = cv2 .resize (anti_spoof_face ,crop_dims )
624
622
# 3. Run recognition on the face crop
625
623
rec_input = rec_face .transpose (2 , 0 , 1 )[np .newaxis , ...].astype (np .float32 )
626
624
rec_embedding = compiled_rec ([rec_input ])[compiled_rec .output (0 )]
0 commit comments