User0967
User0967

Reputation: 131

Unhandled Exception in Visual-C++ for an OpenCV hello world program

I have recently setup openCV 2.3.1 in Visual Studio 2010. I set it up using cmake and managed to run simple 'hello world' code as follows:

            #include "stdafx.h"

            #include <opencv2/opencv.hpp>
            #include <cxcore.h>
            #include <highgui.h>

            int _tmain(int argc, _TCHAR* argv[])
            {
                 IplImage *img = cvLoadImage("funny-pictures-cat-goes-pew.jpg");
                 cvNamedWindow("Image:",1);
                 cvShowImage("Image:",img);

                 cvWaitKey();
                 cvDestroyWindow("Image:");
                 cvReleaseImage(&img);

                 return 0;
             }

This code was able to run for the first time, though it was displaying a grey image instead of the cat. As I was trying to see whts wrong, it started giving the following error; Unhandled Exception at a certain memory location...:![enter image description here][1](can't upload image because of low reputation points. But I hope you understood my problem description...

Regards, Ruzzar

Upvotes: 1

Views: 392

Answers (1)

SinisterMJ
SinisterMJ

Reputation: 3509

Can you please recheck that the *img is being properly filled out?

I just tested this, with the single change that my path to the image is absolute (IplImage *img = cvLoadImage("D:\\Development\\TestProjects\\OpenCVTest\\funny-pictures-cat-goes-pew.jpg");), aside from that its the same. It worked perfectly fine on my system here.

OpenCV 2.4.2 used, image from http://i288.photobucket.com/albums/ll169/critterclaw101/funny/funny-pictures-cat-goes-pew.jpg

Edit: when testing with a wrongly set path, I get a grey image, thus I am sure that your code cannot find the image.

Upvotes: 1

Related Questions