0

I'm trying to load an image onto a window with OpenCV but I keep on getting a breakpoint at Imshow . Here is the code I followed from a tutorial.

     namedWindow("result", CV_WINDOW_AUTOSIZE );

    Mat image ;
   // image = imread( "Particle", 1 );
    String inputName;

    for( int i = 1; i < argc; i++ )
    {
        inputName.assign( argv[i] );
    }
    if( inputName.empty() || (isdigit(inputName.c_str()[0]) && inputName.c_str()[1] == '\0') )
    {
        if( inputName.size() )
        {
            image = imread("Particle.png", 1 );
        }
        else
        {
            if(image.empty()) cout << "Couldn't read image" << endl;
        }
        imshow("result",image);

}
4
  • What's the message coming with your "breakpoint" ? Did you get into the "Couldn't read image" condition ? If so that probably explains why imshow is crashing... Put your own breakpoint at imshow line, run your application in debug configuration, then check your variables. Commented Jul 28, 2013 at 18:22
  • signal SIGABRT is the breakpoint. I'm also getting one at string imgpath=... Commented Jul 28, 2013 at 19:35
  • Abort() called on some internal error. Do you know how to debug a program ? My guess is you don't give the right input to your program in the command line. Commented Jul 28, 2013 at 19:45
  • Im just compiling in Xcode so no command line and I don't know how to debug this problem. Pretty new to programming Commented Jul 28, 2013 at 20:04

1 Answer 1

1

oh, dear, no idea where you found that 'tutorial', but it's making a lot of 'special' assumptions there, that might not fit your actual situation

try something more simple instead:

int main(int argc, char **argv) {
    string imgpath = argv[1];  // call me : prog imgpath [on the cmdline]
    Mat m = imread(imgpath);
    imshow("lala", m);
    waitKey(0);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.