Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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);
}