Search code examples
opencvhaar-wavelet

Any way to check whether a haar cascade was detected or not?


The function detectMultiScale() returns void, so it is not possible to check whether the the object was detected or not using that function

I wish to pass the frame no., at which the object was detected, to a text file. I don't know how to do that when I can't check whether the cascade was detected or not ?

Should I use cvHaarDetectObjects() from C API ?

Kindly help!


Solution

  • The second parameter to CascadeClassifier::detectMultiScale() is a vector of rectangles. You can check its size:

    std::vector<cv::Rect> objs;
    cascade.detectMultiScale(img, objs, scalefactor, minneighbors);
    
    if (objs.size()) {
      // success
    } else {
      // failed
    }