Ask Your Question
1

Error While Debugging a Code

asked 2013-02-21 10:00:58 -0600

izzo gravatar image

Hey there, i am having a problem with debugging a program for loading and displaying an image

I am using visual studio 2010, and i've followed all the steps to include OpenCV libraries into it, i also tried some projects it all works, But when i try this code to be debugged there's an error shows up:

The code :

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>

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("OpenCV.jpg", 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;
}

The error :

image description

edit retag flag offensive close merge delete

4 answers

Sort by ยป oldest newest most voted
1

answered 2013-02-23 14:24:16 -0600

izzo gravatar image

Problem solved.

I re-installed visual studio 2010 without 64 bit compiler, it was a conflict between 32 and 64 bit support compiler, and the code working as charm :)

Thanks all for help.

edit flag offensive delete link more
2

answered 2013-02-22 01:54:36 -0600

SR gravatar image

updated 2013-02-22 01:55:59 -0600

Probably you mixed debug and release DLLs of OpenCV.

Double-check that you only link against debug DLLs in debug mode and you only link against release DLLs in release mode.

edit flag offensive delete link more

Comments

Hey SR, i've made sure of the Debug N' Release DLLs there's no mixing between them!

izzo gravatar imageizzo ( 2013-02-22 14:06:30 -0600 )edit
0

answered 2013-02-22 16:30:15 -0600

unxnut gravatar image

updated 2013-02-22 16:31:57 -0600

Can you change the line image = imread("OpenCV.jpg", CV_LOAD_IMAGE_COLOR); // Read the file to image = imread("OpenCV.jpg"); // Read the file and see if that fixes the problem? Also, try to run the code through debugger and find out which line throws exception.

Also, make sure that the image is appropriately named (OpenCV.jpg) and in the proper path. You can set up the working directory in Visual Studio settings.

edit flag offensive delete link more

Comments

Problem solved.

I re-installed visual studio 2010 without 64 bit compiler, it was a conflict between 32 and 64 bit support compiler, and the code working as charm :)

Thanks all for help.

izzo gravatar imageizzo ( 2013-02-23 06:56:21 -0600 )edit

Please create an answer that contains your comment and mark it as accepted. It will help other users.

SR gravatar imageSR ( 2013-02-23 08:39:52 -0600 )edit

I answered but can't accept it, it needs 50 points.

izzo gravatar imageizzo ( 2013-02-23 14:26:50 -0600 )edit
1

I see. Now you should have > 50 points ;-)

SR gravatar imageSR ( 2013-02-23 18:26:52 -0600 )edit
-1

answered 2013-02-22 07:32:37 -0600

unxnut gravatar image

You may also want to enclose your code in a try...catch block and print a more meaningful exception message by catching the exception.

edit flag offensive delete link more

Comments

I tried the try catch but it's not helpful, same error as in the image.

izzo gravatar imageizzo ( 2013-02-22 14:04:36 -0600 )edit
1

if mixing debug & release dlls/libs is the issue, here, it won't help

berak gravatar imageberak ( 2013-02-22 16:34:02 -0600 )edit

Question Tools

Stats

Asked: 2013-02-21 10:00:58 -0600

Seen: 447 times

Last updated: Feb 23 '13