Ask Your Question

redjan's profile - activity

2013-09-27 17:03:01 -0600 commented question OpenCV crash after SURF Detection

this comment doesn't help.

2013-09-26 18:40:45 -0600 asked a question OpenCV crash after SURF Detection

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.