-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.py
52 lines (36 loc) · 1.46 KB
/
App.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import cv2
cap = cv2.VideoCapture(0)
face_model = cv2.CascadeClassifier('Models/haarcascade_frontalface_default.xml')
#eyes_model = cv2.CascadeClassifier('haarcascade_eye.xml')
while True:
status , photo = cap.read()
face_cor = face_model.detectMultiScale(photo)
#eyes_cor = eyes_model.detectMultiScale(photo)
if len(face_cor) == 0:
pass
elif len(face_cor) == 1:
cv2.putText(photo,f"There's only:{len(face_cor)} person",(0,25),cv2.FONT_HERSHEY_SIMPLEX,0.5,(255,255,51),1)
cv2.imshow('App', photo)
if cv2.waitKey(10) == 13:
break
else:
# Drawing rectangle around the face
face_x1 = face_cor[0][0]
face_y1 = face_cor[0][1]
face_x2 = face_x1 + face_cor[0][2]
face_y2 = face_y1 + face_cor[0][3]
# Drawing rectangle around the eyes
"""
eye_x1 = eyes_cor[0][0]
eye_y1 = eyes_cor[0][1]
eye_x2 = eye_x1 + eyes_cor[0][2]
eye_y2 = eye_y1 + eyes_cor[0][3]
"""
#photo = cv2.rectangle(photo, (face_x1,face_y1), (face_x2,face_y2), [0,255,0], 2)
#photo = cv2.rectangle(photo, (eye_x1,eye_y1), (eye_x2,eye_y2), [0,255,0], 2)
cv2.putText(photo,f"No. of people :{len(face_cor)}",(0,25),cv2.FONT_HERSHEY_SIMPLEX,0.5,(255,255,51),1)
cv2.imshow('App', photo)
if cv2.waitKey(10) == 13:
break
#print(f"There are {len(face_cor)} people")
cv2.destroyAllWindows()