OpenCV: Why SIFT and SURF detectors crashes?

青春壹個敷衍的年華 提交于 2019-12-11 02:43:00

问题


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?


回答1:


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).



来源:https://stackoverflow.com/questions/23630704/opencv-why-sift-and-surf-detectors-crashes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!