2012-07-16 82 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(業績+精度)