SurfFeatureDetector core dumped

asked 2016-04-08 09:39:26 -0500

Razakhel gravatar image

updated 2016-04-10 07:55:29 -0500

I am trying to reproduce the code displayed here (it was an absolute pain to debug).

The actual code is:

int main(int argc, char* argv[]) {

    Mat img_object = imread("/home/razakhel/Downloads/base.png" CV_IMREAD_GRAYSCALE);
    Mat img_scene = imread("/home/razakhel/Downloads/pattern.png" CV_IMREAD_GRAYSCALE);

    if (! || ! {
        std::cout<< " --(!) Error reading images " << std::endl; return -1;

    //-- Step 1: Detect the keypoints using SURF Detector
    int minHessian = 400;

    SurfFeatureDetector detector(minHessian);

    std::vector<KeyPoint> keypoints_object, keypoints_scene;

    detector.detect(img_object, keypoints_object); // <= Core dumped
    detector.detect(img_scene, keypoints_scene);


    return 0;

The error appears on the line commented as such. The base.png is a 1366x768 picture (I tried with it rescaled to 640x380, same thing). The pattern.png is scaled at 205x180, but the code isn't reaching its import anyway. I assume it is unrelated to the size, but we never know.

I've been searching for answers for a while, but all I've been able to find was a problem related to the missing initModule_nonfree().

If anyone has an idea, I'd gladly try it.

edit retag flag offensive close merge delete


please try with grayscale images,

imread("/home/razakhel/Downloads/base.png", CV_IMREAD_GRAYSCALE)
berak gravatar imageberak ( 2016-04-10 07:27:49 -0500 )edit

My bad, actually I tried without the greyscale before posting in case it changed something, but it didn't. It doesn't work in either situation. I've updated the post!

Razakhel gravatar imageRazakhel ( 2016-04-10 07:57:02 -0500 )edit