Ask Your Question

bijan311's profile - activity

2019-03-18 07:05:24 -0600 received badge  Popular Question (source)
2013-06-15 14:15:30 -0600 asked a question imread function not working

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 libopencv_core.so and libopencv_highgui.so 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(!img.data)//This if statement is triggered
    {
        cout<<"Error!\n"
        return -1;
    }

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

    waitKey(0);

    return 1;
}

Thank you