mirror of
https://github.com/serengil/deepface.git
synced 2025-06-08 12:35:22 +00:00
Use return boolean to detect effective capture
Actually an image is always returned but empty
This commit is contained in:
parent
810dfac4fe
commit
051a8d3172
@ -68,9 +68,8 @@ def analysis(
|
|||||||
|
|
||||||
cap = cv2.VideoCapture(source) # webcam
|
cap = cv2.VideoCapture(source) # webcam
|
||||||
while True:
|
while True:
|
||||||
_, img = cap.read()
|
has_frame, img = cap.read()
|
||||||
|
if not has_frame:
|
||||||
if img is None:
|
|
||||||
break
|
break
|
||||||
|
|
||||||
# cv2.namedWindow('img', cv2.WINDOW_FREERATIO)
|
# cv2.namedWindow('img', cv2.WINDOW_FREERATIO)
|
||||||
@ -111,13 +110,11 @@ def analysis(
|
|||||||
detected_faces = []
|
detected_faces = []
|
||||||
face_index = 0
|
face_index = 0
|
||||||
for x, y, w, h in faces:
|
for x, y, w, h in faces:
|
||||||
if w > 130: # discard small detected faces
|
if w <= 130: # discard small detected faces
|
||||||
|
continue
|
||||||
face_detected = True
|
face_detected = True
|
||||||
if face_index == 0:
|
if face_index == 0:
|
||||||
face_included_frames = (
|
face_included_frames += 1 # increase frame for a single face
|
||||||
face_included_frames + 1
|
|
||||||
) # increase frame for a single face
|
|
||||||
|
|
||||||
cv2.rectangle(
|
cv2.rectangle(
|
||||||
img, (x, y), (x + w, y + h), (67, 67, 67), 1
|
img, (x, y), (x + w, y + h), (67, 67, 67), 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user