First time here? Check out the FAQ!

Ask Your Question
1

Error While Debugging a Code

asked Feb 21 '13

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

Preview: (hide)

4 answers

Sort by » oldest newest most voted
1

answered Feb 23 '13

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.

Preview: (hide)
2

answered Feb 22 '13

SR gravatar image

updated Feb 22 '13

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.

Preview: (hide)

Comments

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

izzo gravatar imageizzo (Feb 22 '13)edit
0

answered Feb 22 '13

unxnut gravatar image

updated Feb 22 '13

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.

Preview: (hide)

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 (Feb 23 '13)edit

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

SR gravatar imageSR (Feb 23 '13)edit

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

izzo gravatar imageizzo (Feb 23 '13)edit
1

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

SR gravatar imageSR (Feb 24 '13)edit
-1

answered Feb 22 '13

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.

Preview: (hide)

Comments

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

izzo gravatar imageizzo (Feb 22 '13)edit
1

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

berak gravatar imageberak (Feb 22 '13)edit

Question Tools

Stats

Asked: Feb 21 '13

Seen: 475 times

Last updated: Feb 23 '13