Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

your program seems to want the image-name as an argument to the cmdline.

(no idea, how to supply that in eclipse, i'm not using it. but did you try running your prog from the console, and actually supply an image name [like "myprog.exe lena.jpg"] ? )

but to make your prog more safe against the absence of args:

int main( int argc, char **argv ) 
{
    if ( argc<2 ) // check, if there's args at all 
    {             // i think, your prog crashes, because you're using argv[1], and there's no such thing
        printf("please supply an image name\n"); 
        return -1; 
    }
    Mat image = imread(argv[1]);
    if ( image.empty() )
    {
        printf("image '' not found or invalid\n", argv[1]); 
        return -1; 
    }

    ...

your program seems to want the image-name as an argument to the cmdline.

(no idea, how to supply that in eclipse, i'm not using it. but did you try running your prog from the console, and actually supply an image name [like "myprog.exe lena.jpg"] ? )

but to make your prog more safe against the absence of args:

int main( int argc, char **argv ) 
{
    if ( argc<2 ) // check, if there's args at all 
    {             // i think, your prog crashes, because you're using argv[1], and there's no such thing
        printf("please supply an image name\n"); 
        return -1; 
    }
    Mat image = imread(argv[1]);
    if ( image.empty() )
    {
        printf("image '' '%s' not found or invalid\n", argv[1]); 
        return -1; 
    }

    ...