Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 35ea451

Browse files
Detect Faces Using Python
1 parent 326d091 commit 35ea451

File tree

2 files changed

+33339
-0
lines changed

2 files changed

+33339
-0
lines changed

‎FaceDetection/face-detect.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import cv2
2+
3+
face_cascade = cv2.CascadeClassifier("haarcascade_frontalface.xml")
4+
5+
def detect():
6+
cap = cv2.VideoCapture(0)
7+
8+
while True:
9+
_,img = cap.read()
10+
11+
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
12+
13+
face = face_cascade.detectMultiScale(gray, 1.1, 4)
14+
15+
for (x,y,w,h) in face:
16+
cv2.rectangle(img, (x,y), (x+w,y+h), (0,255,0), 2)
17+
18+
cv2.imshow("Face Detect", img)
19+
20+
if cv2.waitKey(1) == 27:
21+
break
22+
23+
cap.release()
24+
25+
detect()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /