OpenCV crash after SURF Detection

asked 2013-09-26 18:40:45 -0500

redjan gravatar image

I wrote a simple program in OpenCV that detects SURF feature in a given image and diplays the detected features in a namedWindow.

#include <iostream>
#include <opencv2\core\core.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\features2d\features2d.hpp>

using namespace cv;

int main(int argc,char** argv)
{
if(argc!=3)//Check cmd number of argumets
{
    std::cout<<"Usage: "<<argv[0]<<" <image-file> <method>"<<std::endl;
    return -1;
}

//LOAD THE SOURCE IMAGE
Mat Img = imread(argv[1],CV_LOAD_IMAGE_GRAYSCALE);
if(!Img.data)//Check correct image load
{
    std::cout<<"Cannot read image file. Check file path!"<<std::endl;
    return -1;
}

//COMPUTE FEATURES
SurfFeatureDetector detector;
std::vector<KeyPoint> features;
detector.detect(Img,features);

//SHOW RESULT
Mat ImgF;
drawKeypoints(Img,features,ImgF);
namedWindow("Features", CV_GUI_NORMAL);
imshow("Features",ImgF);


waitKey();
return 0;

}

Everything is OK, the programs do what it have to do. The problem is when pressing a key to terminate the program a crash error occurs.

edit retag flag offensive close merge delete

Comments

1

And we shall guess this error?

Moster gravatar imageMoster ( 2013-09-27 00:52:08 -0500 )edit

this comment doesn't help.

redjan gravatar imageredjan ( 2013-09-27 17:03:01 -0500 )edit

You dont get my intention. We cant know what the error is if you dont tell us the error message.

Moster gravatar imageMoster ( 2013-09-28 00:10:52 -0500 )edit