Ask Your Question
2

Open eyes / closed eyes in Opencv

asked Mar 20 '14

enrique gravatar image

updated Jan 26 '16

Hi,

I am working on a application able to get a face from a picture and say if the eyes are open or closed. For now, with Haar cascades from Opencv, getting the face ROI and even the eyes ROI is an easy task, but I am struggling on how to distinguish between open and closed eyes.

What I have tried so far is the in-built Haar classifiers in Opencv, but is detecting eyes in general, either they are open or closed. I also tried to train my own Haar cascade, but dont have really clear the process and the results I get are not good enough.

Somebody who has gone this way? Any ideas around?

Thanks in advance!

Preview: (hide)

Comments

Im sorry I don't know the answer to your problem, but I was just wondering how you went about getting the eyes ROI? I am currently making a face tracking program but I am stuck getting the mouth ROI.

WigglesTehPro gravatar imageWigglesTehPro (Mar 21 '14)edit

PS. how many positives are you using for your training? and are you making two cascades? one for open and one for closed?

WigglesTehPro gravatar imageWigglesTehPro (Mar 21 '14)edit

Sorry, didnt see your replies before. I am getting eyes, nose and mouth with a Haar classifiers. The one that is built-in in Opencv works fine for that. What detectMultiScale returns is the ROI (Rect in Opencv).

enrique gravatar imageenrique (Mar 22 '14)edit

No worries and going back to your problem have you tried to train your own classifiers one using positive images of opened eyes an one using closed eyes? then program to say if detects eye using open classifier then eyes are open and if detects eyes using closed classifier then they are closed. Hope that makes sense.

WigglesTehPro gravatar imageWigglesTehPro (Mar 22 '14)edit
1

Hi again, yes I tried doing that, but unfortunately it is not that simple and I not getting it to work as I would like. This is why I was looking for alternatives. Really appreciated your help though.

enrique gravatar imageenrique (Mar 22 '14)edit

You can try this too, get some images of eyes closed and some images of open eyes... Create a CSV file, train your data and use one image as as test... http://docs.opencv.org/modules/contrib/doc/facerec/tutorial/facerec_gender_classification.html

caaarlos gravatar imagecaaarlos (Jun 1 '14)edit

Hi, i want find how to detect eye closed and eye open with using android studio? is it possible?

yihui gravatar imageyihui (Dec 12 '16)edit

4 answers

Sort by » oldest newest most voted
2

answered Jun 3 '14

  • Get only region around the eyes and normalization (less computational cost and avoid false positive): a) landmarks detection b) rotation of the face c) get only region around the eyes d) illumination normalization e) resize
  • Apply HPOG/HOG/LBP/... to the normalized region around the eyes
  • Classify features

[I used LBP and SVM for classification. I'm getting good results.]

image description

For training, I use this database[1]. This database has recently been released. You can also see more information.

[1] http://parnec.nuaa.edu.cn/xtan/data/ClosedEyeDatabases.html

Preview: (hide)

Comments

i am also working on open eye detection and used same data to train haar cascade file but not able to generate .vec file please help me.

sandy1246 gravatar imagesandy1246 (Jan 4 '15)edit

whenever i am going to generate .vec file it gives error like this

pi@raspberrypi~/Desktop $ opencv_createsamples -info pos.info -num 1192 -w 24 -h 24 -vec pos.vec

Info file name: pos.info Img file name: (NULL) Vec file name: pos.vec BG file name: (NULL) Num: 1192 BG color: 0 BG threshold: 80 Invert: FALSE Max intensity deviation: 40 Max x angle: 1.1 Max y angle: 1.1 Max z angle: 0.5 Show samples: FALSE Original image will be scaled to: Width: $backgroundWidth / 24 Height: $backgroundHeight / 24 Create training samples from images collection... pos.info(1) : parse errorDone. Created 0 samples

sandy1246 gravatar imagesandy1246 (Jan 4 '15)edit
1

answered Jun 2 '14

Perhaps you can apply skin detection in the region of the eye that is returned by the haar cascade. If you the percent of skin pixels is greater than a threshold, then the eye is closed.

Skin detection in OpenCV: http://razibdeb.wordpress.com/2013/09/10/skin-detection-in-c-using-opencv/

Also, for detecting the eyes, you can use flandmark detector instead of OpenCV's haar cascades: http://cmp.felk.cvut.cz/~uricamic/flandmark/

Preview: (hide)
1

answered Jun 1 '14

ammar_7777 gravatar image

updated Jun 1 '14

hi ... to solve your problem after you get ROI that contain eye try to apply circular haugh transform to detect geza. if there is a cycle in ROI eye is open if not eye is close.

i hope that can help u.

Preview: (hide)

Comments

Unfortunately this doesn't work... It finds many other non existent circles... The code is implemented here: https://github.com/opencv/opencv/blob...

AlaaM gravatar imageAlaaM (Jul 31 '18)edit
0

answered Mar 23 '16

aguila gravatar image

hi, i am trying to solve the same problem, what i did is, used the dlib face detector, and then get the distance of the eye landmarks (36 to 47), normally when the eyes are open is a stable value, when closed in my case is always 1, also you can get the average intensity value of the ROI of the eyes and compare it when the eyes are open or closed, it can also be achieved with the new clandmark detector hope it helps

Preview: (hide)

Question Tools

1 follower

Stats

Asked: Mar 20 '14

Seen: 13,357 times

Last updated: Jun 03 '14