1

I have opencv2.1 and coding in Visual C++ 2010 Express in 64bit computer. I didn't have problems before, I could work my other codes, however the following simple code gives an error:

Unhandled exception at 0x571365af (msvcr90d.dll) in cvMatExample.exe: 0xC0000005: Access violation reading location 0x6d622e65.

#include "cvaux.h"
#include "highgui.h"
#include <stdio.h>

using namespace cv;
using namespace std;

int main(){

    Mat xxx;
    xxx= imread("frame.bmp",0);

    namedWindow("Result",CV_WINDOW_AUTOSIZE);
    imshow("Result", xxx);

    return 0;

}

So where exactly is the problem? or is cv::Mat not compatible with my computer? Thanks in advance.

M.Babcock
  • 18,753
  • 6
  • 54
  • 84
user1132254
  • 141
  • 1
  • 3
  • 7
  • Did you try using an absolute link to frame.bmp, e.g. C:\frame.bmp , so you could verify that the image was found? – Codemeister Jan 05 '12 at 13:54
  • yes, I tried it too, but even for that case, cv::imread gives an error, so that is not why I'm getting an error. – user1132254 Jan 09 '12 at 10:36

2 Answers2

1

I had exactly the same problem. What worked for me was to repair my .Net installation with this:

http://www.microsoft.com/en-us/download/details.aspx?id=17718

Then reboot when asked.

cheers

Kirus
  • 63
  • 1
  • 7
1

It's good practice to check the return of a function call when you can:

xxx = imread("frame.bmp",0);

if (!xxx .data) 
{
    printf("Failed to load image\n");
    // deal with error
}

Maybe your image was not loaded by imread(). On Windows is often common to refer to the full path with double slashes: C:\\folder\\another_folder\\img.jpg

karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • No, problem isn't about that because even for cv::imread function, this code gives an error, so I cannot even check if it load image well. So basically my Visual C++ 2010 Express gives error for any operation with cv:: – – user1132254 Jan 09 '12 at 10:31
  • Are you sure that is the call `xxx= imread("frame.bmp",0);` that triggers the error? – karlphillip Jan 09 '12 at 11:26
  • yes, because I did do debug too, went step by step and this is where I got the error. Also except imread, for another project, I also tried to use a cv function, cv::findContours and I got an error too. So basically all cv functions gives error. – user1132254 Jan 09 '12 at 11:50
  • Your runtime environment may be messed up, but to tell you the truth I've had inumerous problems with the C++ interface of OpenCV on Windows, some I gave up on trying to solve. My advice to you, implement this application using the C interface (`cvLoadImage()`, etc) and see if it works. If it does, stick with it, or be ready to uninstall everything and start from the scratch. I suggest you [follow this guide](http://stackoverflow.com/questions/7011238/opencv-2-3-c-visual-studio-2010/7014918#7014918). – karlphillip Jan 09 '12 at 11:57
  • Thank you for your answer, however I am suppose to work on a code written by someone else and that person used cv functions everywhere, so either I will change everything, or I will find a way to work it. – user1132254 Jan 09 '12 at 12:07
  • Uninstall OpenCV and try again following the tutorial I recommended. I guess that's the fastest and easiest way to try to fix the problem. – karlphillip Jan 09 '12 at 12:09