在 Visual Studio 2010 中的简单程序中使用特征检测器失败。我使用的是 opencv 2.4.2 并在 2.4.1 上进行了检查。唯一要做的就是创建一个特征检测器并使用它来检测图像中的关键点。我在detectors.cpp(即features2d\detectors.cpp line:65)中遇到指向名为“detecImpl()”的函数的未处理异常崩溃。这个错误确实卡住了,并且花费了大量时间,因此非常感谢任何帮助。
#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;
}
}