The code below is just to see feature detection in SIFT. The problem is that it breaks when I run it.
#include <features2d.hpp>
#include <stdafx.h>
#include <stdlib.h>
#include <cv.hpp>
#include <cxcore.hpp>
#include <highgui.h>
#include <iostream>
using namespace cv;
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
Mat img = imread("c:\\chappal.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;
}
When debugged step by step the program breaks at this line:feature_detector->detect(img, keypoints);
I have checked it again and again and dont know what the problem might be caused by.
P.S. I first tried SiftFeatureDetector
in place of FeatureDetector::create("SIFT");
but got errors as in it could not find SiftFeatureDetector
in the library file. I learned about both code samples from posts here on this forum.
Thank you
I don't know if you tried this, but since it is now in the nonfree.h library, you need to use the initModule_nonfree(). That solved the problem for me.