Ask Your Question
1

The detect feature of SIFT/SURF always breaks code

asked 2012-10-31 09:12:48 -0500

ipunished gravatar image

Hi,

Ive been trying out SIFT/SURF from online resources and wanted to test it out myself.

I first tried without the non-free libraries using this code:

int _tmain(int argc, _TCHAR* argv[])
{
Mat img = imread("c:\\car.jpg", 0);
Ptr<FeatureDetector> feature_detector = FeatureDetector::create("SIFT");
vector<KeyPoint> keypoints;

feature_detector->detect(img, keypoints);

Mat output;

drawKeypoints(img, keypoints, output, Scalar(255, 0, 0));

namedWindow("meh", CV_WINDOW_AUTOSIZE);
imshow("meh", output);
waitKey(0);



return 0;

}

Here if I do a step by step debugging it breaks at feature_detector->detect(img, keypoints);

Then I tried using the non-free library and tried this code:

int main(int argc, char** argv) 
{
    const Mat input = cv::imread("/tmp/image.jpg", 0); //Load as grayscale

    SiftFeatureDetector detector;
    vector<KeyPoint> keypoints;
    detector.detect(input, keypoints);

    // Add results to image and save.
    Mat output;
    drawKeypoints(input, keypoints, output);
    imwrite("/tmp/SIFT_RESULT.jpg", output);

    return 0;

 }

This again compiles without errors but when ran, breaks at this step: detector.detect(input, keypoints);

I cannot find the reason why. Can some one please help me out here.

Thank you

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2012-10-31 14:09:04 -0500

Maria Dimashova gravatar image

The call of cv::initModule_nonfree() should help you (see another my answer on similar question).

edit flag offensive delete link more

Comments

1

Thank you for the help, I read through your other answer and also made the necassary changes, I linked to the non-free library and also called the cv::initModule_nonfree() function. But this time it breaks and gives unhandled exception at drawKeypoints(input, keypoints, output);.. I do not know what else to do.. i'm tired from searching for a solution

ipunished gravatar imageipunished ( 2012-10-31 21:36:01 -0500 )edit
1

Did you check the size of 'input' matrix? I think it was empty in your case and this was the problem.

Maria Dimashova gravatar imageMaria Dimashova ( 2012-11-02 02:06:25 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2012-10-31 09:12:48 -0500

Seen: 1,482 times

Last updated: Oct 31 '12