Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a9d34c8

Browse files
Update face-detect.py
1 parent b6adc71 commit a9d34c8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

‎Face-Detection/face-detect.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@ 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))
16+
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)
19+
else:
20+
cv2.putText(img,a+"faces detected",(15,350), font, 2,(255,0,0),2,cv2.LINE_AA)
1521

1622
for (x, y, w, h) in face:
1723
cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)
1824

1925
cv2.imshow("Face Detect", img)
2026

21-
if cv2.waitKey(1) == 27:
27+
if cv2.waitKey(1) &0xFF== ord('q'):# Press q to quit
2228
break
2329

2430
cap.release()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /