imread function not working

asked 2013-06-15 14:15:30 -0500

bijan311 gravatar image

I am trying to write a basic program in opencv that just displays an image, but imread does not seem to be working.I have and linked to the program and I'm using linux.

Here is my code:

#include <opencv2/opencv.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main()
    Mat img = imread("test.jpg", 1);

    if(! if statement is triggered
        return -1;

    namedWindow("Test", CV_WINDOW_AUTOSIZE);
    imshow("Test", img);


    return 1;

Thank you

edit retag flag offensive close merge delete



try: if ( img.empty() ) instead

berak gravatar imageberak ( 2013-06-15 14:22:22 -0500 )edit

and make sure this 'test.jpg' exists at the very same folder you start your program

Guanta gravatar imageGuanta ( 2013-06-15 15:39:55 -0500 )edit

i think you have to put semicolon (;) after cout<<"Error!\n" I have check this code work OK.

jigarsen18 gravatar imagejigarsen18 ( 2013-06-17 00:19:04 -0500 )edit