Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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!