Ask Your Question

Dobob's profile - activity

2016-08-25 02:42:38 -0600 received badge  Editor (source)
2016-08-25 02:27:21 -0600 asked a question New to OpenCV, trying to display image

UPDATE: I solved it. You need the "xinit" files under "X11" that you choose when you update Cygwin by reopening the Cygwin installation .exe file. Then type "export DISPLAY=:0.0" in the terminal. Then run your executable program to show the picture.

I am trying to run the .exe file after compiling the source code "DisplayImage.cpp" that I edited in gedit and compiled in Cygwin:

#include <stdio.h>
#include <opencv2/opencv.hpp>

using namespace cv;

int main(int argc, char** argv )
{
    if ( argc != 2 )
    {
        printf("usage: DisplayImage.out <Image_Path>\n");
        return -1;
    }

    Mat image;
    image = imread( argv[1], 1 );

    if ( !image.data )
    {
        printf("No image data \n");
        return -1;
    }
    namedWindow("Display Image", WINDOW_AUTOSIZE );
    imshow("Display Image", image);
    waitKey(0);
    return 0;
}

When I type into the command line the below statement, I get GtK-WARNING. I can't seem to find a solution to this online.

$ ./DisplayImage turtle.jpg

(Display Image:22864): Gtk-WARNING **: cannot open display