Skip to content

Commit c9d4a98

Browse files
Face Detection
1 parent d2c612f commit c9d4a98

File tree

8 files changed

+66647
-0
lines changed

8 files changed

+66647
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Face detection
2+
import numpy as np
3+
import cv2
4+
img=cv2.imread('faces.jpeg')
5+
6+
rimg=cv2.resize(img,(img.shape[0]//3,img.shape[1]//5),interpolation=cv2.INTER_AREA)
7+
gray=cv2.cvtColor(rimg,cv2.COLOR_BGR2GRAY)
8+
9+
path='haarcascade_frontalface_default.xml'
10+
11+
face_cascade=cv2.CascadeClassifier(path)
12+
faces=face_cascade.detectMultiScale(gray,scaleFactor=1.25,minSize=(40,40))
13+
14+
for (x,y,w,h) in faces:
15+
cv2.rectangle(rimg,(x,y),(x+w,y+h),(0,255,0),1)
16+
cv2.imshow('Img',rimg)
17+
18+
cv2.waitKey(0)
19+
cv2.destroyAllWindows()
3.33 MB
Loading

0 commit comments

Comments
 (0)