Ask Your Question
2

Open eyes / closed eyes in Opencv

asked 2014-03-20 16:35:43 -0500

enrique gravatar image

updated 2016-01-26 13:30:31 -0500

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!

edit retag flag offensive close merge delete

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 ( 2014-03-20 18:42:11 -0500 )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 ( 2014-03-20 18:44:07 -0500 )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 ( 2014-03-22 03:37:34 -0500 )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 ( 2014-03-22 17:35:57 -0500 )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 ( 2014-03-22 17:56:25 -0500 )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 ( 2014-06-01 13:25:32 -0500 )edit

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

yihui gravatar imageyihui ( 2016-12-12 10:34:55 -0500 )edit

4 answers

Sort by ยป oldest newest most voted
2

answered 2014-06-03 02:18:20 -0500

  • 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

edit flag offensive delete link more

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 ( 2015-01-04 04:58:03 -0500 )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 ( 2015-01-04 05:00:03 -0500 )edit
1

answered 2014-06-02 13:24:55 -0500

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/

edit flag offensive delete link more
1

answered 2014-06-01 11:08:26 -0500

ammar_7777 gravatar image

updated 2014-06-01 11:09:33 -0500

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.

edit flag offensive delete link more

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 ( 2018-07-31 11:22:24 -0500 )edit
0

answered 2016-03-23 09:16:10 -0500

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

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2014-03-20 16:35:43 -0500

Seen: 10,824 times

Last updated: Jun 03 '14