English 中文(简体)
Cannot with C++ syntax
原标题:Cannot run Opencv with C++ syntax
  • Im using Opencv 2.3.1 on Visual studio 2010 (vc10)
  • I have configured opencv based on many tutorials and can compile & run C-syntax program like:

www.un.org/Depts/DGACM/index_spanish.htm

#include "StdAfx.h"
#include <iostream>
#include <opencv2/opencv.hpp>

using namespace std;
using namespace cv;

int main ()
{
    IplImage* img = cvLoadImage("D:cat_helmet.jpg", CV_LOAD_IMAGE_UNCHANGED);
    cvNamedWindow("display", CV_WINDOW_AUTOSIZE);
    cvShowImage("display", img );
    cvWaitKey(0);        

    return 0;
}

However, I cannot run the C++ syntax program like www.un.org/Depts/DGACM/index_spanish.htm

#include "StdAfx.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std; 

int main(  )
{ 
    namedWindow( "Display window", CV_WINDOW_AUTOSIZE );
    Mat image;
    image = imread("D:cat_helmet", CV_LOAD_IMAGE_COLOR);   

    if(! image.data )                             
    {
        cout <<  "Could not open or find the image" << std::endl ;
        return -1;
    }
    imshow( "Display window", image );                   

    waitKey(0);                                          
    return 0;
}

我收到错误信息(职能电话: 姓名:,mread,imshow)。

First-chance exception at 0x5361fcc3 in FirstOpencv2.3.exe: 0xC0000005: Access violation reading location 0x2079616c.

Unhandled exception at 0x5361fcc3 in FirstOpencv2.3.exe: 0xC0000005: Access violation reading location 0x2079616c.

我如何确定这一点?

最佳回答

You say that you have followed a multitude of guides and tutorials. I ve had great success with this one http://www.anlak.com/using-opencv-2-3-1-with-visual-studio-2010-tutorial/

事情是,这gu横穿公园,帮助你在建立开放式CV 2.3.1时揭开两个主要问题,其中之一是将彩票档案放在你的项目夹中。 另一件是失踪的拖车_。

他还为你尝试(在C++ syntax)提供了一些体面的编码。

Good luck.

问题回答

上述答复没有意义。 我也面临同样的问题。 造成这一例外的主要原因是,你试图展示出空洞的图像(通过透镜阅读)。 该方案的主要问题是:

    image = imread("D:cat_helmet", CV_LOAD_IMAGE_COLOR); 

我认为,不起作用并没有达到预期效果。 还有一点是,在通过参考文件时,我有以下联系:

阅读(经过精心设计、档案、挂旗)

这里,通过参考方法使用透镜。 我不是C++专家,但我觉得可能是问题。

    int main() 
    {
      std::string imgPath("splash.bmp"); //Add your file name
      Mat img = imread(imgPath);
      namedWindow( "Example1", WINDOW_AUTOSIZE);
      imshow("Example1", img);
      waitKey(0);
      return 0;
    }

这部法典对我有效。 此外,我把案卷放在旁以减轻复杂性。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?