Eye detection is "jumping". [closed]

asked 2013-07-17 18:23:38 -0600

MattiasR gravatar image

updated 2013-07-17 18:53:53 -0600

I am working on a system that tracks the eye and log data like eye blinks, rate, etc. But I have a problem that the cv::Rect, returned after eye detection (haar detection), is jumping around so that the iris of the person appear on different positions in the matrix. in a 640x480 web cam frame, where the face is about 200px height the cv::Rect of the eye can jum about 40px each time I do the tracking. It jumps so far out that the eye sometimes is outside the rectangle representing the eye!

I am running this detection about 2 times per second, and in between I trace the eye by template mathcing. The template matching works great but sometimes the template slides of and after that keep track on the wrong position of the face. For example during a fast movement of the face the template can get stuck on the nose, or mouth.

I've tried 3 of the four eye classsifiers, (_eye, _mcs, _lefteye_2split). These three, according to the book "Master openCV..." is the best. But I cant se any big difference (more than the _mcs classifier is much slower)

It doesnt matter which one I use, So i was thinking that I might do something wrong!

Someone that is running eye detection multiple times with a good result?

My detector: eyeCascade.detectMultiScale(webcamFrame(ROI), detEye, 1.1, 3, CV_HAAR_FIND_BIGGEST_OBJECT|CV_HAAR_DO_CANNY_PRUNING|CV_HAAR_SCALE_IMAGE, cv::Size(20,20

ROI = centerpoint of last eye position, double width, double height. (4x sixe of cv::Rect( eye position))

edit: There are different classifiers for left and right eye. I force the system to find only one eye. (persons right, on the screen the left one.) Which classifier is the right one?

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-21 08:54:19.307634

Comments

1

kalman filter ?

berak gravatar imageberak ( 2013-07-17 18:48:41 -0600 )edit

No filtering of the position yet. Do you think that is necessary?, I mean... The cv::Rect output from detection algorithm misses the eye abou 1/3 of all the times. Half the pupil is inside the rectangle. It feels wrong. Head is still, image is good.

MattiasR gravatar imageMattiasR ( 2013-07-17 18:51:01 -0600 )edit

"Do you think that is necessary ?"

ah, no idea, just mindstorming

berak gravatar imageberak ( 2013-07-17 19:28:14 -0600 )edit
1

Why using haar classifiers? Did you try flandmarks for example in order to get the position of the eyes and another landmarks? And this paper "Accurate eye centre localisation by means of gradients" has a c++ implementation for pupil tracking

albertofernandez gravatar imagealbertofernandez ( 2013-07-18 01:15:40 -0600 )edit

I took a look at the flandmarks stuff, after your recommendation, and it sounds really good. Is it possible to use it in real - time you think? Haar vs flandmarks -computation time? Thanks! I will try flandmarks

MattiasR gravatar imageMattiasR ( 2013-07-18 04:20:19 -0600 )edit

Haar vs flandmarks computation time i don't know. But if you look at the videos, you can see the fps of flandmarks with different resolutions.

albertofernandez gravatar imagealbertofernandez ( 2013-07-18 04:26:11 -0600 )edit

i cant get the flandmarks to work. unresolved external symbol during FLANDMARK_init(); :(

MattiasR gravatar imageMattiasR ( 2013-07-18 06:09:11 -0600 )edit

you need the code from the cpp/libflandmark folder in your project:

flandmark_detector.cpp
flandmark_detector.h
liblbp.cpp
liblbp.h
stdint.h

and later, when you run it, it needs to find flandmark_model.dat ( from the data folder )

berak gravatar imageberak ( 2013-07-18 06:14:19 -0600 )edit

There is no cpp folder, but I copied the files from libflandmark into my project. stdint.h isnt there, but a file called msvc-compat.h. I copied 5 files. I include the dlandmark_detecter.h into my main file. I am able to "FLANDMARK * model;", but when I try to do "model = flandmark_init("file"); I get the unresolved external symbol. Where shall I start to look for the error? Thanks for helping me!

MattiasR gravatar imageMattiasR ( 2013-07-18 06:25:43 -0600 )edit

oh, right, i got the old sourcefourge version ..

still investigating!

berak gravatar imageberak ( 2013-07-18 06:40:03 -0600 )edit

Error LNK2001, and Error LNK1120.

MattiasR gravatar imageMattiasR ( 2013-07-18 06:43:00 -0600 )edit

This is the only thing I do:

include "stdafx.h"

include "flandmark_detector.h"

int _tmain(int argc, _TCHAR* argv[]) { FLANDMARK_Model * model = flandmark_init("flandmark_model.dat"); return 0; }

MattiasR gravatar imageMattiasR ( 2013-07-18 07:06:55 -0600 )edit

ahh those pesky tchars ..., might be a widechar / unicode / ascii thing then

afaik, if you use _tmain() it assumes all strings being tchars, so the function sig does not match (thus linker error)

try an empty project for now,

include "flandmark_detector.h"

int main(int argc, char * argv[]) { FLANDMARK_Model * model = flandmark_init("flandmark_model.dat"); return 0; }

berak gravatar imageberak ( 2013-07-18 07:11:58 -0600 )edit

I created an empty project. copied the files mentioned before. And used the code you wrote. I also included the propertysheey I use so that I can use opencv. But the same error. could it be the propertysheet? Just to be clear. I dont have to run this cmake-thing??!!

MattiasR gravatar imageMattiasR ( 2013-07-18 07:22:02 -0600 )edit

" I dont have to run this cmake-thing??!!"

not really. you'll have to add the opencv related includes/libs manually then

berak gravatar imageberak ( 2013-07-18 07:31:49 -0600 )edit

This is strange... Too bad there isn't much information available on the internet about flandmark. Thanks for your help!

MattiasR gravatar imageMattiasR ( 2013-07-18 07:36:04 -0600 )edit

at least i could reproduce it ;)

haven't found out what it is, but it is related to the propertysheet.

try to skip it as well, add the opencv stuff manually ( easier, if you edit the vcproj from scite or notepad )

berak gravatar imageberak ( 2013-07-18 07:39:36 -0600 )edit

By adding it manually, should I create an empty propertysheet and add the opencvstuff? or do you mean by copy all the files into the project folder?

MattiasR gravatar imageMattiasR ( 2013-07-18 07:54:16 -0600 )edit

Could it be because I use the debug-files from opencv? (with a 'd' at the end of each filename.

MattiasR gravatar imageMattiasR ( 2013-07-18 07:57:38 -0600 )edit

meant creating an empty project, and adding the "additional includes" in the c++ section / libs manually

unfortunately, i only got vs2008 here, so no real idea, how that looks on your side.

berak gravatar imageberak ( 2013-07-18 07:59:12 -0600 )edit

not likely. it's something in your project settings

berak gravatar imageberak ( 2013-07-18 08:01:56 -0600 )edit

I tried it again. Empty project. In the configuration manager I change to x64, (and copy from x86). I add the 5 files from the folder libflandmark. I add in C/C++ additional directories, opencv/build/include, -opencv & -opencv2. In the linker I add opencv/build/x64/vc10/lib/ and in linker-input I add all opencv_.....d.lib files. (debug files). Thats the only thing. Opencv works, And I still got a linker error from flandmarks... :(

MattiasR gravatar imageMattiasR ( 2013-07-18 10:36:42 -0600 )edit

I asked on stackoverflow.com. A guy there found that I didn't include the files in my project (add->existing files). WHen I did that everything works great. Thanks for helping me!

About the performance: With one (perfect image) when I measure the time for only the detect method, i get 0 ms. On my computer i thing I have a resolution of 15ms. So 1 detect (without the Haar-part) takes less than 15 ms. which is really really good!

Thank you everyone.

MattiasR gravatar imageMattiasR ( 2013-07-19 02:02:42 -0600 )edit

waa, what a story, nice that you got it solved ;)

so, does it give less jitter than the original (eye-cascade) idea ?

berak gravatar imageberak ( 2013-07-19 02:17:00 -0600 )edit

I have not tried it yet on webcam. But i tried about 10 photos. And the result were perfect!

MattiasR gravatar imageMattiasR ( 2013-07-19 15:46:50 -0600 )edit

ah, good. i asked, because i was trying asmlib for something similar before, and results on static images looked nice, too, but images from a webcam had the same jitter problems like your original cascade solution.

thanks for the info ;)

berak gravatar imageberak ( 2013-07-19 16:00:39 -0600 )edit

I will continue the work within a couple of days, and I can write a comment here about the result, after trying it with the webcam.

MattiasR gravatar imageMattiasR ( 2013-07-20 08:01:22 -0600 )edit