2012-07-16 73 views
2

功能探测器在Visual Studio 2010中的简单程序中使用失败。我使用的是opencv 2.4.2,并在2.4.1上进行了检查。唯一要做的就是创建一个特征检测器,并使用它来检测图像中的关键点。我在detect.cpp(即features2d \ detectors.cpp行:65)中得到未处理的异常崩溃,指向名为“detecImpl()”的函数。这个错误真的被卡住了,并且花了很多时间,所以任何帮助都非常感激。opencv功能探测器崩溃,未处理的异常错误

#include <iostream> 
#include <opencv2/core/core.hpp> 
#include "opencv2/highgui/highgui.hpp" 
#include <opencv2/imgproc/imgproc.hpp> 
#include <opencv2/features2d/features2d.hpp> 

using namespace std; 
using namespace cv; 

int main(int argc, char* argv[]) 
{ 
cv::Ptr<cv::FeatureDetector> featureDetector; 
cv::Ptr<cv::DescriptorExtractor> descriptorExtractor; 
featureDetector = cv::FeatureDetector::create("SURF"); 
descriptorExtractor = cv::DescriptorExtractor::create("SURF"); 
cv::Mat imageColor; 
cv::Mat image = cv::imread("car1.jpg", 0); 
    cv::cvtColor(image, imageColor, CV_GRAY2BGR); 
try{ 
imshow("Test Image",imageColor); 
cv::waitKey(3000); 
} 
catch(cv::Exception exc) 
{ 
cout << "CV error occured : " + exc.msg; 
} 
std::vector<cv::KeyPoint> currentKeypoints; 

try{ 
    featureDetector->detect(image,currentKeypoints); //This line generates the error but no exception is caught .... 
    } 
catch(cv::Exception exc) 
{ 
cout << "CV error occured : " + exc.msg; 
return -1; 
} 
} 

回答

3

我已经想通了。在新版本的opencv中,SURF/SIFT分布在独立的库中,需要在创建特征检测器之前进行初始化。

+1

对于那些想知道的一个,初始化为:'CV :: initModule_nonfree()' – Eric 2014-09-05 19:34:00

0

同样的事情发生在我在VS2010上使用OpenCV 2.4.2。

我发现以下工作: FAST,STAR,ORB,BRISK,GFFT和Harris。

SIFT,SURF将在包含非自由功能并启动它们之后运行。

While Dense & SimpleBob坠毁。

,给了最好的结果相对于其余的全是FAST(业绩+精度)