Andrea F
Andrea F

Reputation: 733

Loading image Opencv

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);

}

Upvotes: 0

Views: 307

Answers (1)

berak
berak

Reputation: 39816

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);
}

Upvotes: 1

Related Questions