title: Catching opencv exception from imshow() and namedWindow()
body: <p>I've got some code that isn't working as intended.  I have an application that uses imshow() to display an image, but I also want the program to still work if there is no display.  For this reason I am trying to catch the exception from imshow (GTK-Warning: cannot open display) and continue the program without it (the bool 'display' is checked at every imshow() call).</p>
  
  <pre><code>//Display
  bool display{false};
  try{
      std::cout &lt;&lt; "Attempting to open display..." &lt;&lt; std::endl;
      cv::resize(image,modimage1,cv::Size(800,480));
      cv::namedWindow("Output", CV_WINDOW_NORMAL);
      cv::setWindowProperty("Output", CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLS$
      cv::imshow("Output", modimage1);
      cv::waitKey(1);
      display = true;
  } catch( cv::Exception&amp; e ){
      const char* err_msg = e.what();
      std::cout &lt;&lt; "exception caught:" &lt;&lt; err_msg &lt;&lt; std::endl;
      std::cout &lt;&lt; "Failed to launch display, running without visual..." &lt;&lt; s$
  }
  </code></pre>
  
  <p>The catch block is copied right out of the opencv documentation, so I'm surprised that it doesn't catch the exception.  The program behaves exactly as it did without the try block.  The last output is "Attempting to open display" then I get the "GTK-Warning" and it exits the program.</p>
  
  <p>So, what's missing?  Am I catching the wrong error type?  Is the exception not actually thrown by openCV but GTK/X/?</p>
  
  <p>Thanks</p>