-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproj.py
28 lines (27 loc) · 812 Bytes
/
proj.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
# import cv2
# video_cap = cv2.VideoCapture(0)
# while True :
# ret,video_data = video_cap.read()
# cv2.imshow("video_live",video_data)
# if cv2.waitKey(10)== ord("a"):
# break
# video_cap.release()
import cv2
face_cap = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")
video_cap = cv2.VideoCapture(0)
while True :
ret,video_data = video_cap.read()
col = cv2.cvtColor(video_data,cv2.COLOR_BGR2GRAY)
faces = face_cap.detectMultiScale(
col,
scaleFactor=1.1,
minNeighbors=5,
minSize=(30,30),
flags=cv2.CASCADE_SCALE_IMAGE
)
for (x,y,w,h) in faces:
cv2.rectangle(video_data,(x,y),(x+w,y+h),(0,255,0),2)
cv2.imshow("Face Detection",video_data)
if cv2.waitKey(10)== ord("a"):
break
video_cap.release()