为什么SIFT和SURF探测器会崩溃?
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
// ...
}
错误为Segmentation fault (core dumped)
。我使用OpenCV 2.4.8, gcc 4.9和Ubuntu。如果我使用其他类型的功能,它会正常运行。我错过了什么?
您试过呼叫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
// ...
}
也,你没有检查指针特征检测器,这可能是空的(因为你没有调用initModule)。