Skip to content

Commit b5b4ee4

Browse files
eye detection
1 parent c9d4a98 commit b5b4ee4

File tree

3 files changed

+24447
-0
lines changed

3 files changed

+24447
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# eye 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_eye.xml'
10+
11+
eye_cascade=cv2.CascadeClassifier(path)
12+
eyes=eye_cascade.detectMultiScale(gray,scaleFactor=1.04,minNeighbors=20,minSize=(10,10))
13+
14+
for (x,y,w,h) in eyes:
15+
cx=(x+x+w)//2
16+
cy=(y+y+h)//2
17+
cv2.circle(rimg,(cx,cy),w//2,(255,0,0),2)
18+
cv2.imshow('Img',rimg)
19+
20+
cv2.waitKey(0)
21+
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)