Ask Your Question
1

haar clasifier parallel running

asked 2013-02-27 07:25:12 -0600

balzeee gravatar image

i am trying to run 4 haar clasifiers parallely to classify gestures that i have obtained from a video...i dont knw how to run the classifiers parallely...can any1 help me with the code

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-02-27 13:48:43 -0600

xaffeine gravatar image

I have gotten good results using OpenMP. Something like the following should work. In my example, I am only interested in the best/biggest face in each image. Change that part, obviously, if you want more than one.

#include <omp.h>

cv::CascadeClassifier faceFinder_[4];
cv::Rect faceBounds[4];

#pragma omp parallel for // num_threads( 4 )
for( int tt=0; tt < 4; ++tt )
{
    FindBestFace( faceFinder_[tt], rectifiedGray[tt], faceBounds[tt] );
}

static void FindBestFace( cv::CascadeClassifier & finder, const cv::Mat & srcImg, cv::Rect & faceBounds )
{
    vector< cv::Rect> faces;

    int minFaceDiameter = srcImg.cols / 6;

    finder.detectMultiScale( srcImg, faces,
        1.1, 2, 0
        //|CV_HAAR_FIND_BIGGEST_OBJECT
        //|CV_HAAR_DO_ROUGH_SEARCH
        |CV_HAAR_SCALE_IMAGE
        ,
        cv::Size(minFaceDiameter, minFaceDiameter) );  
    if( faces.empty() )
    {
        faceBounds = cv::Rect( 0, 0, 0, 0 );
    }
    else
    {
        faceBounds = faces[0];
    }
}
edit flag offensive delete link more

Comments

Don't forget to initialize your classifiers with models!

xaffeine gravatar imagexaffeine ( 2013-02-27 16:10:19 -0600 )edit

Question Tools

Stats

Asked: 2013-02-27 07:25:12 -0600

Seen: 470 times

Last updated: Feb 27 '13