LatentSVM crashes in OpenCV 3.0.0 (contrib)
I am trying to detect objects using the LatentSVM detector that is currently in the contrib repository for OpenCV. My OpenCV installation is 3.0.0 on OS X Mavericks. After loading the model successfully from the opencv_extra repository the detector crashes upon finding objects in an image. In this example I have loaded the car.xml model but this does not seem to be the problem.
void LSVM_Detector::detect(cv::Mat& image)
{
if (detector->isEmpty()) {
cout << "Model is not loaded...EXIT" << endl;
return;
}
// Line below outputs '1'
//cout << "Number of classes = " << detector->getClassCount() << endl;
// Actual detection of objects in the image
cout << "Detecting objects..." << flush;
vector<LSVMDetector::ObjectDetection> detections;
// Line below crashes...
detector->detect(image, detections);
cout << "DONE" << endl;
cout << "Found " << detections.size() << " objects." << endl;
cv::namedWindow("LSVM Detections", cv::WINDOW_AUTOSIZE);
for (auto&d : detections) {
cv::Rect r = d.rect;
float score = d.score;
cout << "Detection score = " << score << endl;
cv::rectangle(image, r, cv::Scalar(0, 255, 0));
}
cv::imshow("LSVM Detections", image);
}
I have tried to read out images in color and grayscale, however both result in the same error:
init done
opengl support available
Loading LSVM model file...DONE
Detecting objects...OpenCV Error: Assertion failed (src.size == dst.size && src.channels() == dst.channels()) in cvConvertScale, file /Users/username/Development/libraries/opencv-3.0.0-beta/modules/core/src/convert.cpp, line 4008
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Users/username/Development/libraries/opencv-3.0.0-beta/modules/core/src/convert.cpp:4008: error: (-215) src.size == dst.size && src.channels() == dst.channels() in function cvConvertScale
I have tried various images, but unfortunately without any luck. Does anyone have an idea what goes wrong here? Any help would be appreciated, I am kind of stuck and the documentation of OpenCV (3.0.0) and the LatentSVM class lacks a little bit here to be honest. Thanks in advance!
give it 24bit bgr images, not grayscale ;)
Berak, thanks for your reply! When giving it a 24 bit BGR image the error changes, but now I get a EXC_BAD_EXCESS error. I am not sure whether this is an OpenCV issue or has something to do with OS X or Xcode...?
This screenshot shows the error message, there is nothing to debug...It just crashes :-( Any clue? https://dl.dropboxusercontent.com/u/8...
are you sure, you got the correct cascade ? must be one from opencv_contrib\modules\latentsvm\testdata\latentsvm, the old ones from opencv_extra do no more work (crash in detect / createPCA_FeaturePyramid)
yes, the algorithm behind it was changed slightly, afaik, it's using a 'star' based cascade now, so the old cascade files do no more work.