When I Debug a sample program I got following error message ?

asked 2012-11-04 11:14:11 -0500

Elec gravatar image

updated 2012-11-04 12:02:44 -0500

sammy gravatar image

I'm using OpenCV2.4.2 and Visual Studio 2008

This is the error message

The program '[4060] OpenCV_sample.exe: Native' has exited with code -1 (0xffffffff).

This is the sample program

I included all the libraries which need here. using namespace cv; using namespace std;

int main( int argc, char** argv )
{ 
if( argc != 2) 
{
 cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
 return -1;
}

Mat image;
image = imread(argv[1], CV_LOAD_IMAGE_COLOR);   // Read the file

if(! image.data )                              // Check for invalid input
{
    cout <<  "Could not open or find the image" << std::endl ;
    return -1;
}

namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window", image );                   // Show our image inside it.

waitKey(0); // Wait for a keystroke in the window
return 0;
}
edit retag flag offensive close merge delete

Comments

This is not an error. The program simply tells you it exited. The reason is clearly described in the code you pasted here - did you read the code?

sammy gravatar imagesammy ( 2012-11-04 12:04:54 -0500 )edit

Hello sammy, I'm new to these things..could u please tell me which line should I change to show the image.Or how I show the image using open CV.What's wrong with this?

Elec gravatar imageElec ( 2012-11-04 19:36:12 -0500 )edit

Hello sammy, I'm new to these things..could u please tell me which line should I change to show the image.Or how I show the image using open CV.What's wrong with this?

Elec gravatar imageElec ( 2012-11-06 10:18:38 -0500 )edit
1

Guy, I don't mean to be rude, but this is the type of things you just find for yourself. If you cannot spot the error in a second, you either are completely lazy (you do not want to read the source code by yourself), either have no idea about programming, and in that case, it's better to start with a C++ tutorial on the internet. Then, when you know the basics, go back to OpenCV. Really, there is no point trying to understand OpenCV if you do not know C++, because you'll find billions of such errors and won't be able to complete any meaningful program.

sammy gravatar imagesammy ( 2012-11-07 01:24:47 -0500 )edit