简体   繁体   中英

Opencv : Cannot open display : C++, Raspberry Pi Headless connection

I have got an error :

Gtk-WARNING **: cannot open display:

  1. Below is the simple image display program in opencv using C++ and in raspberry pi 3 Model B

  2. I understood " Imshow " function which create a window to display image in GUI will not work in terminal

  3. I am using headless connection (with LAN connection - SSH through Putty, raaspberry pi desktop access through VNC )

Code:

#include<opencv2/highgui/highgui.hpp>
using namespace cv ;
int main() {
    Mat img = imread("/home/USER/Pictures/python.jpg",CV_LOAD_IMAGE_COLOR);
    imshow("opencvtest",img);
    waitKey(0);
    return 0;
}

Getting the error:

$ g++ -ggdb pkg-config --cflags opencv -o basename opencvtest.cpp .cpp opencvtest.cpp pkg-config --libs opencv

$ ./opencvtest

" (opencvtest:1927): Gtk-WARNING **: cannot open display"

Just help me running a simple program and let me know how can i achieve this . I am newbie to raspberry pi .

Thanks Atila

在执行应用程序之前,请尝试以下命令。

export DISPLAY=:0.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM