在OpenCV中使用FeatureDetector会导致访问冲突 [英] Using FeatureDetector in OpenCV gives access violation

查看:352
本文介绍了在OpenCV中使用FeatureDetector会导致访问冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



代码片段:

  #includeopencv2 / 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);
detect-> detect(leftImageGrey,keypoints_1);
detect-> detect(rightImageGrey,keypoints_2);
}

错误:

  DisparisAnalysis.exe中0x770b15de处的未处理异常:0xC0000005:访问冲突读取位置0x00000000。 

我已经搜索过解决方案,发现这个:在FeatureDetector中的访问违例读取OpenCV 2.4.5 我认识到的差别是,他们在开头使用cv :: initModule_nonfree()。但是,当它复制到我的代码,它不编译,因为未找到标识符。
对于SIFT和SURF,任何建议?

解决方案

,你需要nonfree模块, p>


  • 包含opencv2 / nonfree / nonfree.hpp


  • 开始时调用cv :: initModule_nonfree()


  • 链接到opencv_nonfree2.4.x.lib



I need to find and match feature points in stereo images. Therefore I want to compare the different Feature Detection algorithms that are supported in OpenCV 2.4.5. by passing "SURF", "SIFT", etc. to the function.

The code snippet:

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

The error:

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

I've already searched for solutions and found this one: Access violation reading in FeatureDetector OpenCV 2.4.5 The difference I've recognized is, that they use cv::initModule_nonfree() at the beginning. But when copying it into my code it doesn't compile because the identifier isn't found. Any suggestions?

解决方案

for SIFT and SURF, you'll need the nonfree module, that is :

  • include "opencv2/nonfree/nonfree.hpp"

  • call cv::initModule_nonfree() at the beginning

  • link against opencv_nonfree2.4.x.lib

这篇关于在OpenCV中使用FeatureDetector会导致访问冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆