-
Notifications
You must be signed in to change notification settings - Fork 0
/
cam.py
30 lines (22 loc) · 865 Bytes
/
cam.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
import cv2
face_cap = cv2.CascadeClassifier(cv2.data.haarcascades + "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.circle(video_data , (int((x + x+w)/2) ,int( (y+ y+h)/2) ), 0 , (255 , 0 , 0) , 10)
cv2.line(video_data ,(330, 0) , (330, 600) , (0 , 0 , 255) , 4 )
cv2.imshow("video_live", video_data)
if cv2.waitKey(10) == ord("a"):
break
video_cap.release()
cv2.destroyAllWindows()