OpenCV 2.2 VS2010 - 获取“访问冲突读取”在一个非常简单的代码 [英] OpenCV 2.2 VS2010 - Get an "Access violation reading" in a very simple code

查看:389
本文介绍了OpenCV 2.2 VS2010 - 获取“访问冲突读取”在一个非常简单的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了OpenCV 2.2和Visual C ++ 2010并配置它。
我不会得到编译错误,但运行此代码我得到这个错误

I just installed OpenCV 2.2 and Visual C++ 2010 and configured it. I don't get compilation errors but running this code I get this error

Unhandled exception at 0x6c2f22f2 (msvcr100.dll) in Es_CornerDetector.exe: 0xC0000005: access violation reading location 0x002a1000.

代码:

#include "opencv/highgui.h"
#include "opencv2/features2d/features2d.hpp"

int main(int argc, char** argv)
{
    cv::SurfFeatureDetector detector;
    detector.create("SURF");
}

我真的不明白是什么原因..

I really don't understand which can be the cause..

使用detect.create()可能是错误的,所以我尝试了不同的东西,另一个错误(总是当我尝试访问检测器):

The use of "detector.create()" may be wrong so I tried something different but i get another error (always when I try to access "detector"):

First-chance exception at 0x67608ef4 in Es_CornerDetector.exe: 0xC0000005: Access violation writing location 0x02655008.
Unhandled exception at 0x67608ef4 in Es_CornerDetector.exe: 0xC0000005: Access violation writing location 0x02655008.

替代代码:

#include "opencv\cv.h"
#include "opencv\highgui.h"
#include "opencv2\features2d\features2d.hpp"
#include <vector>
#include <iostream>

int main()
{
    IplImage* img_temp = cvLoadImage("img.jpg");
    cv::Mat img(img_temp);
    if(img.empty()==1)
    {
            std::cout << "Can't load the image.." << endl;
        getchar();
        return -1;
    }

    cv::SurfFeatureDetector detector;
    vector<cv::KeyPoint> keypoints;
    detector.detect(img,keypoints);
    return 0;
}



更新2



我得到相同的错误在2不同的系统与VS2010和VS2008,以及如果我尝试运行示例代码descriptor_extractor_matcher.cpp,可以在..\OpenCV2.2 \samples \cpp\descriptor_extractor_matcher中找到。 cpp

Update 2

I get the same error in 2 different system both with VS2010 and VS2008 and also if I try to run the example code descriptor_extractor_matcher.cpp that can be found in ..\OpenCV2.2\samples\cpp\descriptor_extractor_matcher.cpp

/ p>

Wow, new exotic error:

Run-Time Check Failure #2 - Stack around the variable 'keypoints' was corrupted.

我即将放弃...

推荐答案

我有同样的问题,并弄清楚在我的系统路径中的opencv二进制文件的目录被错误地导致错误的目录,其中包含vc10或vc9 opencv二进制文件。看看你的问题是否是这样的。希望这有助于。

I had the same problem and figured out that the directory having opencv binaries in my system path was incorrectly led to wrong directory which contains vc10 or vc9 opencv binaries. See if your problem is something like this. Hope this helps.

这篇关于OpenCV 2.2 VS2010 - 获取“访问冲突读取”在一个非常简单的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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