Skip to content

Commit

Permalink
fix : distance value
Browse files Browse the repository at this point in the history
  • Loading branch information
sycuuui committed May 21, 2024
1 parent 31d8e17 commit 0bba3f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Binary file modified __pycache__/mosaic.cpython-311.pyc
Binary file not shown.
16 changes: 9 additions & 7 deletions mosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def mosaic(video_path, image_paths):
)
embedding_list.append(embedding_result["embeddings"][0])

threshold = 0.3
not_threshold = 0.47

while cap.isOpened():
ret, frame = cap.read()
if not ret:
Expand All @@ -46,13 +49,6 @@ def mosaic(video_path, image_paths):

print(f"{current_frame_count}감지 시작")

if len(detections.xyxy[0]) > 2:
threshold = 0.27
not_threshold = 0.2851
else:
threshold = 0.3
not_threshold = 0.47

for face_id in detections.xyxy[0]:
x1, y1, x2, y2 = face_id[:4].int().tolist()
if y2 - y1 > 50 and x2 - x1 > 50:
Expand Down Expand Up @@ -84,9 +80,15 @@ def mosaic(video_path, image_paths):
break

if distance > not_threshold:
face_filename = f"D/face_{face_count}.jpg"
verified_str = 'Different'
distance_str = '(%.4f >= %.4f)' % (distance, threshold)
print(face_filename, verified_str, distance_str)
face = cv2.resize(face_image, (10, 10))
face = cv2.resize(face, (x2 - x1, y2 - y1), interpolation=cv2.INTER_AREA)
frame[y1:y2, x1:x2] = face
face_filepath = os.path.join(faces_dir, face_filename)
cv2.imwrite(face_filepath, face_image)
break

face_count += 1
Expand Down

0 comments on commit 0bba3f1

Please sign in to comment.