Skip to content

Commit a401eb1

Browse files
authored
Update face_detect3.py
1 parent bb30e09 commit a401eb1

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Face-Detection/v3/face_detect3.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ def detect():
1212
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
1313

1414
face = face_cascade.detectMultiScale(gray, 1.1, 4)
15-
a=str(len(face))
15+
a=len(face)
1616
font = cv2.FONT_HERSHEY_SIMPLEX
17-
if int(a)==1:
18-
cv2.putText(img,a+"face detected",(15,350), font, 2,(255,0,0),2,cv2.LINE_AA)
17+
if a<=1:
18+
cv2.putText(img,str(a)+"face detected",(15,350), font, 2,(255,0,0),2,cv2.LINE_AA)
1919
else:
20-
cv2.putText(img,a+"faces detected",(15,350), font, 2,(255,0,0),2,cv2.LINE_AA)
21-
20+
cv2.putText(img,str(a)+"faces detected",(15,350), font, 2,(255,0,0),2,cv2.LINE_AA)
21+
2222
for (x, y, w, h) in face:
2323
cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)
2424

@@ -28,7 +28,6 @@ def detect():
2828
break
2929

3030
cap.release()
31-
cv2.destroyAllWindows()
3231

3332

3433
detect()

0 commit comments

Comments
 (0)