Ask Your Question
2

How to use soft cascade in the latest opencv

asked 2014-01-20 21:12:46 -0600

claycau gravatar image

updated 2014-01-20 21:16:03 -0600

Hi, I have already download the latest opencv from github and successed compile it. I notice that the latest version realize the soft cascade algorithm and I want to test it. But I don't know how to detect a pedestrian use this method. Is there anybody know it? My platform is vs2010+win64+opencv3.00 ,

edit retag flag offensive close merge delete

Comments

The softcascade is indeed implemented but it is not documented. The only way to get a hang from it is to browse through the sourcecode and try to decipher the different functions the algorithm supplies. It is one of the downsides of an open-source library where people could add functionality as they pleased in the past. If you however, figure it out, create a sample, add it to the repository so that future users can get a hang of it also.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-01-21 02:14:45 -0600 )edit

1 answer

Sort by » oldest newest most voted
2

answered 2014-01-21 03:37:29 -0600

berak gravatar image

you can use it in a very similar way to the HogDetector or the CascadeClassifier:

cv::softcascade::Detector soft;

// load data ( no idea why the other one did not work..)
cv::FileStorage fs("E:/code/opencv/data/softcascade/soft-cascade-17.12.2012.xml", cv::FileStorage::READ);   
bool ok = soft.load(fs.getFirstTopLevelNode());
if ( ! ok ) {
    std::cerr << "cascade load error!" << std::endl; 
    return -1;
}

std::vector<cv::Rect> rois; // where in the image to look for people
// pretty nifty, if you got a bg-separator in front of it, so you only
// need to look at small (moving) parts of the image...
rois.push_back(Rect(0,0,img.cols,img.rows)); //for now, the whole img
std::vector<cv::softcascade::Detection> softobj; // results

soft.detect(img,rois,softobj);

for ( size_t j=0; j<softobj.size(); ++j ) // lame visualization ..
{                
     cv::Rect R(softobj[j].x, softobj[j].y, softobj[j].w, softobj[j].h);
     cv::rectangle(img,R,cv::Scalar(softobj[j].confidence*3-128 ,0,0),2);
}
edit flag offensive delete link more

Comments

Nice, didn't know the interface was that similar :)

StevenPuttemans gravatar imageStevenPuttemans ( 2014-01-21 03:46:44 -0600 )edit

3Q for your response! ^ ^ Hope it will help others~~

claycau gravatar imageclaycau ( 2014-01-21 06:30:07 -0600 )edit
1

According with the exp result I review your code,if add a "grouprectangles" function for the output location may be better. I found that the training of soft cascade is independent with adaboost. Can I train a detector by myself use haar or hog feature by the latest opencv?

claycau gravatar imageclaycau ( 2014-01-21 07:35:46 -0600 )edit
1
  • grouprectangles sounds like a good idea.

  • for training , there's the sft tool in the apps folder, but no manual for it ofc ;) i never tried (so far), but it looks like you have to supply a config file for that manually

berak gravatar imageberak ( 2014-01-21 07:42:33 -0600 )edit
2

Obviously, it need a config file. I try to read the source code to list the format of config file. However, I think the easiest way is to ask somebody who know it ...... heihei
whatever , 3Q U again :) Let me try it ~

claycau gravatar imageclaycau ( 2014-01-21 08:50:50 -0600 )edit

I can't find the cv::softcascade in recent opencv3 and opencv_contrib-master. Could you share your experience about the soft cascade or recommend some related links?

Sheng Liu gravatar imageSheng Liu ( 2015-08-17 19:29:42 -0600 )edit

It is updated and not using only the softcascade but also the ICF/ACF features. Look here for ICF and here for ACF.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-08-18 02:03:58 -0600 )edit
1

adobe has obtained a patent on the softcascade, so it had to go ;(

berak gravatar imageberak ( 2015-08-18 02:10:56 -0600 )edit

Thank you!

Sheng Liu gravatar imageSheng Liu ( 2015-08-18 02:56:51 -0600 )edit

Question Tools

Stats

Asked: 2014-01-20 21:12:46 -0600

Seen: 1,230 times

Last updated: Jan 21 '14