Ask Your Question

langues's profile - activity

2020-09-16 03:30:01 -0600 received badge  Popular Question (source)
2013-10-01 23:34:11 -0600 asked a question imread does not load jpg on osx

I am having trouble with imread not loading a .jpg using the image loading tutorial.

image.jpg is in the same location as my code. I've loaded the libraries in my project and linked the header files properly.

I checked my build information using cout << cv::getBuildInformation() << endl; and confirmed jpg support.

Here is the code i'm using:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main( int argc, char** argv )
{
    Mat image;
    image = imread("image.jpg", CV_LOAD_IMAGE_COLOR);   // Read the file

    if(! image.data )                              // Check for invalid input
    {
        cout <<  "Could not open or find the image" << std::endl ;
        return -1;
    }

    namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.
    imshow( "Display window", image );                   // Show our image inside it.

    waitKey(0);                                          // Wait for a keystroke in the window
    return 0;
}

The if(! image.data ) statement evaluates to true.

Does anyone have any ideas what I could be doing wrong?