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 dd2950a

Browse files
Merge pull request avinashkranjan#667 from Avishake007/eyes_branch
Added Eyes Detection
2 parents 26aa992 + 6233b91 commit dd2950a

File tree

3 files changed

+12267
-0
lines changed

3 files changed

+12267
-0
lines changed

‎Eye Detection/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
<h1 align="center"> Eye Detection</h1>
3+
It is going to detect your eyes and count the number of eyes
4+
5+
---------------------------------------------------------------------
6+
7+
## Modules Used
8+
- opencv
9+
10+
11+
## How it works
12+
- First you have to go to the path where your py file is using your cmd or terminal
13+
- Then you have to type **python eyes.py** to run the file
14+
- Then it will convert your live video frame by frame into grayscale
15+
- Then it will detect your eyes using the eyes cascade xml file
16+
- Then you could see green rectangle boxes appearing which is detecting your eyes
17+
- It will also show you the number of eyes
18+
19+
#### By [Avishake Maji](https://github.com/Avishake007)

‎Eye Detection/eyes.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
import cv2
3+
4+
5+
capture=cv2.VideoCapture(0) #To open camera 1
6+
7+
if (capture.isOpened()==False):
8+
print("Sorry")
9+
while(capture.isOpened()):
10+
11+
# Load trained cascade classifier
12+
ret,color_image=capture.read()
13+
eye_cascade=cv2.CascadeClassifier('./Eye Detection/haarcascade_eye.xml')
14+
15+
16+
# Convert color image into grayscale
17+
gray_image = cv2.cvtColor(color_image, cv2.COLOR_BGR2GRAY)
18+
19+
#Detect Eyes
20+
eyes=eye_cascade.detectMultiScale(gray_image, 1.1, 5)
21+
#Count the number of eyes
22+
a=str(len(eyes))
23+
font = cv2.FONT_HERSHEY_SIMPLEX
24+
cv2.putText(color_image,a+" eyes detected",(15,350), font, 2,(0,0,0),2,cv2.LINE_AA)
25+
# Draw rectangle around the eyes
26+
for (x, y, w, h) in eyes:
27+
cv2.rectangle(color_image, (x, y), (x + w, y + h), (0, 255, 0), 2)
28+
29+
# Show image
30+
cv2.imshow('Image', color_image)
31+
cv2.imwrite('detect.png',color_image)
32+
if cv2.waitKey(1) & 0xFF == ord('q'):
33+
break
34+
capture.release()
35+
cv2.destroyAllWindows()

0 commit comments

Comments
(0)

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