Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
Hie.. I am doing a project and i need to detect eye blink of person in opencv. Can someone please tell me the steps of detecting blink or suggest me some sites from where i can study.
Posted
Comments
Philippe Mori 18-Feb-12 8:38am    
I think that the eye blinks faster than what a camera can see so I don't think it is possible to do with common technologies.
BupeChombaDerrick 25-Feb-12 18:13pm    
Totally agree with Philippe, eye blinks are too fast, besides what use can you make of such a system (enlighten me), try using haarcascade_eye.xml file that comes with openCV to detect eye positions as a pre-processing stage and then see if you can invent a classifier to tell whether a person blinked. You can only capture such high speed events (blinks) using expensive high speed cameras which makes your project unfeasible and i doubt if the system you which to design can process frames at such high frame rates to be applicable.
Member 8329163 26-Feb-12 0:42am    
actually i have to detect left and right blink and accordingly monitor the computer (left click-> left blink , right click-> right blink). If its not possible then can you please suggest me some other idea how can I remote control my computer using eye.

Try checking out this link
TrackEye : Real-Time Tracking Of Human Eyes Using a Webcam[^]

I understand what you are trying to do.But instead of detecting rapid eye blinks why not detect whether one closes a right or left eye instead. With this suggestion, you need to detect faces first, see this link on how you can train a haar classifier to detect objects.
http://note.sonots.com/SciSoftware/haartraining.html[^]

Then you can train a second set of classifiers to scan only those detected regions for right and left eye. You can use two classifiers, one should detect closed eyes and the other open eyes, and just using a simple geometric constraint your system can tell whether the eye is on the right or left side,and based on the two classifier outputs the system can tell whether either eye is open or closed and it could output control signals based on that.

See also a tutorial code for openCV 2.3

https://code.ros.org/svn/opencv/trunk/opencv/samples/cpp/tutorial_code/objectDetection/objectDetection.cpp[^]

Hope this helps.
 
Share this answer
 
Comments
Member 8329163 26-Feb-12 9:53am    
Thanks a lot for your suggestion. I'll try to do it. Thank you.
Member 8329163 17-Mar-12 15:46pm    
hie, i need help. I found a code for blink detection. I studied from the site http://opencv-code.com/Real_Time_Eye_Tracking_and_Blink_Detection , but its not working properly. I am not able to fix the problem and the code is error free. Can someone please suggest me how can i improve this code.
BupeChombaDerrick 18-Mar-12 8:44am    
please state clearly what you mean by "not working properly" ... because if the code is error free then the algorithm must not be okay. I'am taking a look at the code will get back to you after i do some analysis!
Member 8329163 18-Mar-12 15:01pm    
I mean the code is not able to detect the blink and neither it is detecting the eyes. :(
Member 8329163 18-Mar-12 15:11pm    
I guess it might be the problem of camera. I am using the camera of my laptop. As per your suggestion I tried detecting eyes and applied some function for the movement of cursor along with the movement of eyes. Here is the code and its working fine but as you said I need to detect left and right eyes individually and then closed eyes. I am not getting how to do it.


#include <stdio.h>
#include "cv.h"
#include "highgui.h"
#include "X11/Xlib.h"
CvHaarClassifierCascade *cascade;
CvMemStorage *storage;

void detectFaces( IplImage *img );
int mouse(int delta_x,int delta_y) {
Display *display = XOpenDisplay(0);
Window root = DefaultRootWindow(display);
XWarpPointer(display, None, root, 0, 0, 0, 0, delta_x, delta_y);
XCloseDisplay(display);
}
int main( int argc, char** argv )
{
CvCapture *capture;
IplImage *frame;
int key;
char *filename = "haarcascade_eye.xml";

cascade = ( CvHaarClassifierCascade* )cvLoad( filename, 0, 0, 0 );
storage = cvCreateMemStorage( 0 );
capture = cvCaptureFromCAM( 0 );

assert( cascade && storage && capture );

cvNamedWindow( "video", 1 );

while( key != 'q' ) {
frame = cvQueryFrame( capture );

if( !frame ) {
fprintf( stderr, "Cannot query frame!\n" );
break;
}

cvFlip(frame,frame,2);
frame->origin = 0;

detectFaces( frame );

key = cvWaitKey( 25 );
}

cvReleaseCapture( &capture );
cvDestroyWindow( "video" );
cvReleaseHaarClassifierCascade( &cascade );
cvReleaseMemStorage( &storage );

return 0;
}

void detectFaces( IplImage *img )
{
int i;

CvSeq *faces = cvHaarDetectObjects(img,cascade,storage,1.15,3,0,cvSize( 40, 20 ) );

for( i = 0 ; i < ( faces ? faces->total : 0 ) ; i++ )
{
CvRect *r = ( CvRect* )cvGetSeqElem( faces, i );
cvRectangle( img,cvPoint( r->x, r->y ),cvPoint( r->x + r->width, r->y + r->height ),CV_RGB( 255, 0, 0 ), 1, 8, 0 );
mouse(2.1*r->x,1.8*r->y);
}

cvShowImage( "video", img );
}

please help.
I use your program in the first cite. but it said "cannot initialize capture"
how to solve it? please help me
 
Share this answer
 
Comments
CHill60 1-Apr-14 18:50pm    
if you have a question of your own then use the Red "Ask a question" link

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900