title: Opencv : Cannot open display : C++, Raspberry Pi Headless connection
body: <p>I have got an error : </p>
  
  <blockquote>
    <p>Gtk-WARNING **: cannot open display:</p>
  </blockquote>
  
  <ol>
  <li><p>Below is the simple image display program in opencv using C++ and in raspberry pi 3 Model B</p></li>
  <li><p>I understood " Imshow " function which create a window to display image in GUI will not work in terminal</p></li>
  <li>I am using headless connection (with LAN connection - SSH through Putty, raaspberry pi desktop access through VNC )</li>
  </ol>
  
  <p>Code:</p>
  
  <pre><code>#include&lt;opencv2/highgui/highgui.hpp&gt;
  using namespace cv ;
  int main() {
      Mat img = imread("/home/USER/Pictures/python.jpg",CV_LOAD_IMAGE_COLOR);
      imshow("opencvtest",img);
      waitKey(0);
      return 0;
  }
  </code></pre>
  
  <p>Getting the error:</p>
  
  <pre><code>$ g++ -ggdb pkg-config --cflags opencv -o basename opencvtest.cpp .cpp opencvtest.cpp pkg-config --libs opencv
  
  $ ./opencvtest
  </code></pre>
  
  <blockquote>
    <p>" (opencvtest:1927): Gtk-WARNING **: cannot open display"</p>
  </blockquote>
  
  <p>Just help me running a simple program and let me know how can i achieve this . I am newbie to raspberry pi .</p>
  
  <p>Thanks
  Atila</p>