Question

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!

Was it helpful?

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
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top