sub_o
sub_o

Reputation: 2802

How to utilize cascade classifier in custom detection algorithm?

So, I've created my own HoG features extractor and a simple sliding window algorithm, which pseudo code looks like this:

for( int i = 0; i < img.rows; i++ ) {
   for( int j = 0; j < img.cols; j++ ) {
     extract image ROI from the current position
     calculate features for the ROI
     feed the features into svm.predict() function, to determine whether it's human or not
   }
}

However since it's very slow (especially when you include different scales), I've decided to train some cascade classifiers using openv_traincascade command on my positive and negative samples.

opencv_traincascade provides me with cascade.xml, params.xml, and a number of stages.xml files

My question is how do I utilize this trained cascade classifiers in my detection loop ?

Edit: No, not detectMultiScale. The reason I'm using cascade classifier is just to speed up detection of non-object, I still need to use my own algorithm to calculate the score of probable ROI. Sorry for the confusion

Upvotes: 0

Views: 1102

Answers (2)

Eric
Eric

Reputation: 2341

Following opencv doc on Object Detection, you have to create the cascade detector object and ::load the cascade you want to apply (the xml file you have generated). ::detectMultiScale is used to fill a std::vector of detected object from current frame by sliding windows of different scales and sizes and merging high confident close samples.

Code here! Same question answered here ?

Upvotes: 2

Safir
Safir

Reputation: 902

In order to use the Cascade Classifier you have to call the CascadeClassifier::load function (you pass the path to the generated XML file as argument). And whenever you want to check whether the object of interest is existing or not you should either call the CascadeClassifier::detect or CascadeClassifier::detectMultiScale functions.

Upvotes: 1

Related Questions