gpt4 book ai didi

visual-studio-2010 - opencv 特征检测器崩溃并出现未处理的异常错误

转载 作者:太空宇宙 更新时间:2023-11-03 21:28:18 24 4
gpt4 key购买 nike

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

#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;
}
}

最佳答案

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

关于visual-studio-2010 - opencv 特征检测器崩溃并出现未处理的异常错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11508440/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com