OpenCV: Why SIFT and SURF detectors crashes?
c++, gcc4.9, opencv
Solution
Have you tried to call `initModule_nonfree()`?
#include <opencv2/nonfree/nonfree.hpp>
using namespace std;
using namespace cv;
int main(int argc, char *argv[])
{
initModule_nonfree();
Mat image = imread("TestImage.jpg");
// Create smart pointer for SIFT feature detector.
Ptr<FeatureDetector> featureDetector = FeatureDetector::create("SIFT");
vector<KeyPoint> keypoints;
// Detect the keypoints
featureDetector->detect(image, keypoints); // here crash
// ...
}
Also, you didnt check the pointer featureDetector which is probably null (since you have not called initModule).
Problem
Why do the SIFT and SURF detectors crash? ``` using namespace std; using namespace cv; int main(int argc, char *argv[]) { Mat image = imread("TestImage.jpg"); // Create smart pointer for SIFT feature detector. Ptr<FeatureDetector> featureDetector = FeatureDetector::create("SIFT"); vector<KeyPoint> keypoints; // Detect the keypoints featureDetector->detect(image, keypoints); // here crash // ... } ``` The error is `Segmentation fault (core dumped)`. I use OpenCV 2.4.8, gcc 4.9 and Ubuntu. If I use the other types of features it runs normally. What am I missing?