OpenCV:为什么SIFT和SURF检测器崩溃? [英] OpenCV: Why SIFT and SURF detectors crashes?
本文介绍了OpenCV:为什么SIFT和SURF检测器崩溃?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么SIFT和SURF检测器崩溃?
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
// ...
}
分段故障(内核转储)
。我使用OpenCV 2.4.8,gcc 4.9和Ubuntu。如果我使用其他类型的功能,它运行正常。
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?
推荐答案
您尝试调用 initModule_nonfree()
?
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
// ...
}
didnt检查指针featureDetector可能为null(因为你没有调用initModule)。
Also, you didnt check the pointer featureDetector which is probably null (since you have not called initModule).
这篇关于OpenCV:为什么SIFT和SURF检测器崩溃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文