Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

ok, let's try again (assuming, you're running opencv2.4.x):

#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace cv;

#include <iostream>
using namespace std;

int main() {
    namedWindow("mywindow");
    //
    // now here's the hidden challenge: it has to *find* the image file.
    // if you're using a relative path (like below, it assumes, 
    // that the image is in the folder, where your prog *starts*
    // that is not nessecarily the location of your binary )
    // when in doubt, try an *absolute path* like "/home/opencv/samples/cpp/lena.png"
    //
    Mat img = imread("lena.png"); 
    if ( img.empty() ) {
        cerr << "sorry dave, i could not find the specified image" << endl;
        return -1;
    }
    imshow("mywindow", img);
    waitKey(0); // forever

    return 0;
}