Ask Your Question
2

Robust face detection

asked 2013-06-19 05:00:43 -0600

sachin_rt gravatar image

updated 2015-09-30 12:05:06 -0600

I am detecting the face using Haar Detection , But the detection is very slow and not very accurate ? So I was thinking if I could use kalman filter for face detction things would be much better . Any body who worked on this before please help ?

Edit : Is there any other way I can make the face detection robust ? I am working on real time video capture .

Edit : I am using a PTZ camera to track the face and move the camera accordingly so as to maintain the face in the center region . Are there ways we can predict the position of the face ?? Note that here the camera has motion , ie pan and tilt . So what are the ways we can predict the future position of the face ??

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
7

answered 2013-06-19 09:44:28 -0600

I did, some time ago, a face tracking algorithm using template matching and kalman filter in order to reduce the window to perform template matching. I implemented a simple class that i called "FaceKalman" based on this mouse kalman. The code (cpp) is something like this:

FaceKalman::FaceKalman(){
    // TODO Auto-generated constructor stub

}

KalmanFilter FaceKalman::initKalman(Point coord)
{
     /* 
       (x, y, Vx, Vy)
        position of the object (x,y)
        velocity (Vx,Vy)
      */            


    this->measurement =  Mat(2,1,DataType<float>::type);

    KalmanFilter KF(4, 2, 0);

    KF.statePre.at<float>(0) = coord.x;
    KF.statePre.at<float>(1) = coord.y;
    KF.statePre.at<float>(2) = 0;
    KF.statePre.at<float>(3) = 0;

    //VELOCITY NOT TAKEN INTO ACCOUNT
    //KF.transitionMatrix = *(Mat_<float>(4, 4) << 1,0,0,0,   0,1,0,0,  0,0,1,0,  0,0,0,1);

    //VELOCITY TAKEN INTO ACCOUNT
    KF.transitionMatrix = *(Mat_<float>(4, 4) << 1,0,1,0,   0,1,0,1,  0,0,1,0,  0,0,0,1);


    setIdentity(KF.measurementMatrix);
    setIdentity(KF.processNoiseCov, Scalar::all(1e-4));
    setIdentity(KF.measurementNoiseCov, Scalar::all(1e-1));
    setIdentity(KF.errorCovPost, Scalar::all(.1));      

    return KF;
}

Point FaceKalman::updateKalman(KalmanFilter KF, Point coord)
{
    //predict
    Mat prediction = KF.predict();
    Point predictPt(prediction.at<float>(0),prediction.at<float>(1));

    this->measurement(0) = coord.x;
    this->measurement(1) = coord.y;

    //correct
    Mat estimated = KF.correct(this->measurement);
    Point estimatedPoint(estimated.at<float>(0),estimated.at<float>(1));        
    return estimatedPoint;
}

Then, you can use your FaceKalman class for face detection in order to reduce the window to look for the face.

edit flag offensive delete link more

Comments

Is the coord.x in the " KF.statePre.at<float>(0) = coord.x; " and in the " this->measurement(0) = coord.x; " same ??

sachin_rt gravatar imagesachin_rt ( 2013-06-28 14:48:53 -0600 )edit

coord is the measurement that you want to filter over time.

coord.x = x component of the measurement

KF.statePre.at<float>(0) = coord.x; //here it is the first measure

this->measurement(0) = coord.x; // here it is the new measure to filter

albertofernandez gravatar imagealbertofernandez ( 2013-07-01 01:42:05 -0600 )edit

i try to use but this->measurement doesn't work because the compiler says that class has no member called "measurement", must i add it? and how?

sim87 gravatar imagesim87 ( 2015-07-20 05:33:14 -0600 )edit

yes, you should add it to the .h file

albertofernandez gravatar imagealbertofernandez ( 2015-07-21 01:26:50 -0600 )edit

ok, another information, if you can. I try to declare this variable mat in the h file, but it reports always error. In which way must i declare it? I use opencv and this class from a few time and i see the contructors in documentation, but it still doesn't work.

sim87 gravatar imagesim87 ( 2015-07-21 03:57:43 -0600 )edit

cv::Mat_<float> measurement;

albertofernandez gravatar imagealbertofernandez ( 2015-07-21 06:20:17 -0600 )edit

thank you very much!!

sim87 gravatar imagesim87 ( 2015-07-22 04:11:14 -0600 )edit
5

answered 2013-06-21 04:31:35 -0600

Edit : Is there any other way I can make the face detection robust ? I am working on real time video capture

Face detection:

Given an arbitrary image, the goal of face detection is to determine whether or not there are any faces in the image and, if present, return the location and extent of each face.

Viola & Jones algorithm is commonly applied to face detection. Viola and Jones introduced their object detection framework that can be applied to human faces. At runtime, the algorithm is capable of processing images extremely rapidly. It uses a boosted cascade of simple classifiers based on rectangular Haar-like features that can be computed rapidly.

Face tracking:

Track a detected face over time. In order to track a human face, the system not only needs to locate a face, but also needs to find it in a sequence of images. You can use color information, estimate the motion, and so on. There are a lot of algorithms and approaches that perform face tracking in real time.

You can perform face tracking with opencv functions and methods. For example:

Also you can use TLD algorithm to track the face . There are some C++ implementations: tld C++ implementation, tld C++ implementation 2, TLD face tracking video

Or for example this one: Zhang, K., Zhang, L., & Yang, M. H. (2012). Real-time compressive tracking. In Computer Vision–ECCV 2012 (pp. 864-877). Springer Berlin Heidelberg. Project web page. It includes matlab code and c++ code. Compressive tracking video

edit flag offensive delete link more

Comments

Heyy thanks for that quick reply :) I am trying to track a face using a PTZ Camera . For now I am doing face detection using Viola Jones , then I am tracking the detected face using camshift tracking and moving the camera accordingly . But this works a bit slowly . I want to make this more robust and faster , Can you help me with any ideas for faster tracking ??

sachin_rt gravatar imagesachin_rt ( 2013-06-21 06:54:39 -0600 )edit

The simplest answer would be to reduce the size of the input image (before applying Camshift) And you can you Camshift + Kalman (http://www.youtube.com/watch?v=dhYwCmKGU3w)

albertofernandez gravatar imagealbertofernandez ( 2013-06-21 07:19:43 -0600 )edit

I recommend you to see this tutorial: http://www.youtube.com/watch?v=bSeFrPrqZ2A

albertofernandez gravatar imagealbertofernandez ( 2013-06-21 07:21:50 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-06-19 05:00:43 -0600

Seen: 3,735 times

Last updated: Jun 26 '13