Skip to content

Commit 2502391

Browse files
authored
Create Face.py
1 parent e482230 commit 2502391

File tree

1 file changed

+25
-0
lines changed
  • Face Recognition Using Python

1 file changed

+25
-0
lines changed

Face Recognition Using Python/Face.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import cv2
2+
3+
cap = cv2.VideoCapture(0)
4+
5+
face_cascade = cv2.CascadeClassifier(
6+
cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
7+
body_cascade = cv2.CascadeClassifier(
8+
cv2.data.haarcascades + "haarcascade_fullbody.xml")
9+
10+
while True:
11+
_, frame = cap.read()
12+
13+
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
14+
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
15+
16+
for (x, y, width, height) in faces:
17+
cv2.rectangle(frame, (x, y), (x + width, y + height), (255, 0, 0), 3)
18+
19+
cv2.imshow("Camera", frame)
20+
21+
if cv2.waitKey(1) == ord('q'):
22+
break
23+
24+
cap.release()
25+
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)