Skip to content

Commit 5148e84

Browse files
Add files via upload
1 parent fd353ef commit 5148e84

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

FaceRecgonition/main.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import cv2
2+
import dlib
3+
4+
cap = cv2.VideoCapture(0)
5+
detector = dlib.get_frontal_face_detector()
6+
7+
while True:
8+
ret, frame = cap.read()
9+
frame = cv2.flip(frame,1)
10+
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
11+
faces = detector(gray)
12+
13+
i=0
14+
q
15+
for face in faces:
16+
x, y = face.left(), face.top()
17+
x1, y1 = face.right(), face.bottom()
18+
cv2.rectangle(frame,(x,y),(x1,y1),(0,255,0),2)
19+
i=i+1
20+
cv2.putText(frame,'face num'+str(i),(x-10,y-10),cv2.FONT_HERSHEY_SIMPLEX,0.7,(0,0,255),2)
21+
print(face,i)
22+
cv2.imshow('frame',frame)
23+
if cv2.waitKey(1) & 0xFF == ord('q'):
24+
break
25+
cap.release()
26+
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)