-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path22_RealTime_Yuz_Algilama.py
More file actions
31 lines (23 loc) · 922 Bytes
/
Copy path22_RealTime_Yuz_Algilama.py
File metadata and controls
31 lines (23 loc) · 922 Bytes
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
""" -*- coding: utf-8 -*-
@author: omerkocadayi
https://github.com/omerkocadayi
https://www.linkedin.com/in/omerkocadayi/ """
import cv2
cap = cv2.VideoCapture(0)
faceCascade = cv2.CascadeClassifier("haarcascade\\haarcascade_frontalface_default.xml")
while True:
ret, frame = cap.read()
frame = cv2.flip(frame, 1)
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
rects = faceCascade.detectMultiScale(gray,
scaleFactor=1.3,
minNeighbors=4,
minSize=(50, 50),
flags=cv2.CASCADE_SCALE_IMAGE)
for (a,b,c,d) in rects:
cv2.rectangle(frame, (a,b), (a+c, b+d), (0,255,255), 2)
cv2.imshow("Frame", frame)
if cv2.waitKey(2) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()