Background: I wanted to create a software eye-tracker for my research that is both robust and doesn't cost right arm and left testicle. So I set my sights on OpenCV and have been playing around with it for two weeks. I realized from day one that I will have to develop a cascade for detecting eyes - so I set about "harvesting" images from the web. Some of them are from freely available databases. http://vis-www.cs.umass.edu/lfw/ http://cvc.yale.edu/projects/yalefacesB/yalefacesB.html http://cvc.yale.edu/projects/yalefaces/yalefaces.html http://images.ee.umist.ac.uk/danny/database.html http://vasc.ri.cmu.edu/idb/html/face/ http://www.bioid.com/downloads/facedb/index.php http://vis-www.cs.umass.edu/~vidit/IndianFaceDatabase/ http://www.cs.cmu.edu/~cil/v-images.html http://vision.ai.uiuc.edu/mhyang/face-detection-survey.html
Some of them had the eye positions already marked so it was easier to extract. But for most of them - I had to manually select the eye area. I also "extracted" images from Google TM Images ( http://images.google.com ) - I wrote a simple vc++ program (an ugly hack really) to grab images from the web or clipboard and then extract eye areas based on mouse selection. I used these images (20x20) to train a classifier - haarcascade_eye.xml . The training is based on the OpenCV methods "createsamples" and "haartraining". My experience with it so far is very encouraging - i grab frames from an webcam and use that image to find face and eyes. The code is very simple - Main code IplImage *frame=cvQueryFrame(capture); if (frame){ FindFace(frame); FindEyes(frame); }
Findface/eyes if (img) if( cascade_face ) or eye { IplImage* gray = cvCreateImage( cvSize(img->width,img->height), 8, 1 ); cvCvtColor( img, gray, CV_BGR2GRAY ); cvFlip( gray, gray, 0 ); double scale = 1.3; IplImage* small_img = cvCreateImage( cvSize( cvRound (img->width/scale),cvRound (img->height/scale)),8, 1 ); cvResize( gray, small_img, CV_INTER_LINEAR ); cvEqualizeHist( small_img, small_img ); cvClearMemStorage( storage ); CvSeq* faces or eyes= cvHaarDetectObjects( small_img, cascade_face or eye, storage, 1.1, 2, 0, cvSize(30, 30) ); if (faces or eyes) { for( int i = 0; i < (faces or eyes ? faces or eyes->total : 0); i++ ) { CvRect *r = (CvRect*)cvGetSeqElem( faces or eyes, i ); cvRectangle( cpy, cvPoint(...), cvPoint(..), CV_RGB(255,0,0), 1, 8, 0 ); } } }
|