mohammad-usama
commited on
Commit
·
9fb6260
1
Parent(s):
77c010c
yes
Browse filesFor face detection using open cv and a haarcascade dataset
code
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import cv2
|
2 |
+
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
|
3 |
+
cap = cv2.VideoCapture(0)
|
4 |
+
while True:
|
5 |
+
ret, frame = cap.read()
|
6 |
+
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
7 |
+
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
|
8 |
+
for (x, y, w, h) in faces:
|
9 |
+
cv2.rectangle(frame, (x, y), (x + w, y + h), (255, 4, 0), 2)
|
10 |
+
cv2.imshow('Camera', frame)
|
11 |
+
if cv2.waitKey(1) & 0xFF == ord('q'):
|
12 |
+
break
|
13 |
+
|
14 |
+
cap.release()
|
15 |
+
cv2.destroyAllWindows()
|