Typical "Exception at memory location"

asked 2016-03-15 12:30:23 -0600

updated 2016-03-15 13:30:57 -0600

berak gravatar image

Hello, I'm trying to make a simple program in VS2015, just reading and showing an image, and I don't know what could be the error. In the title I wrote "typical" because I read a lot about it and I'm certainly sure that can be a straightfoward solution.

This is my program:

#include <cstdio>
#include <opencv2\opencv.hpp>
//#include <iostream>
//#include "opencv2\imgproc\imgproc.hpp"
using namespace cv;
using namespace std;

int main() {
    //char NombreImagen[] = "imagen1.jpg";
    Mat imagen1;
    imagen1 = cv::imread("C:\\imagen1.jpg");
    if (!imagen1.data) {
        cout << "Error al mostrar la imagen: " << endl;
        exit(1);
    }
    namedWindow("Original", CV_WINDOW_AUTOSIZE);
    imshow("Original", imagen1);
    waitKey(0);
    return 0;
}

When I executed in debug (x64), it's done, but there's always the following message:

Exception thrown at 0x000007FEFD96965D in App1.exe: Microsoft C++ exception: cv::Exception at memory location 0x000000000031EB10.

Any help will be useful. Thank you a lot for the attention.

edit retag flag offensive close merge delete

Comments

I don't know the exact problem, but try if(imagen1.empty()) instead of if(!imagen1.data), Proof your image path twice and try to Debug your code with F10 to localize the problem. Did you copy the correct dll's into your application folder and did you link the right libs (Debug vs. Release)? Did you compile OpenCV by yourself or do you use prebuild. I think prebuild is not for Visual Studio 2015, but only for 2013 and 2012.

matman gravatar imagematman ( 2016-03-15 17:38:30 -0600 )edit