gpt4 book ai didi

c++ - 在 OpenCV 中使用 FeatureDetector 会导致访问冲突

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:03:20 25 4
gpt4 key购买 nike

我需要在立体图像中查找和匹配特征点。因此,我想比较 OpenCV 2.4.5 支持的不同特征检测算法。通过将“SURF”、“SIFT”等传递给函数。

代码片段:

#include "opencv2/opencv.hpp"
#include <opencv/highgui.h>
#include <opencv2/nonfree/features2d.hpp>

using namespace cv;
using namespace std;

...

void DisparityAnalysis::detectKeyPoints(Mat1b leftImageGrey, Mat1b rightImageGrey, string algorithmName)
{
Ptr<FeatureDetector> detector = FeatureDetector::create(algorithmName);
detector->detect(leftImageGrey, keypoints_1);
detector->detect(rightImageGrey, keypoints_2);
}

错误:

Unhandled exception at 0x770b15de in DisparityAnalysis.exe: 0xC0000005: Access violation reading location 0x00000000.

我已经搜索了解决方案并找到了这个:Access violation reading in FeatureDetector OpenCV 2.4.5我认识到的区别是,他们在开始时使用 cv::initModule_nonfree() 。但是当把它复制到我的代码中时,它不会编译,因为没有找到标识符。有什么建议吗?

最佳答案

对于 SIFT 和 SURF,您需要非自由模块,即:

  • 包含“opencv2/nonfree/nonfree.hpp”

  • 在开头调用 cv::initModule_nonfree()

  • 针对 opencv_nonfree2.4.x.lib 的链接

关于c++ - 在 OpenCV 中使用 FeatureDetector 会导致访问冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17785028/

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