Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 135

How can I check if the monitor is connected in Windows / Linux?

$
0
0
How can I check if the monitor is connected in Windows / Linux? The following program behavior is required, when I run my application: - if monitor is connected, then results will be showed in the window - if monitor isn't connected, or if I run application by SSH, then results will be saved to the image.jpg Currently, if monitor isn't connected or if I run my application by using SSH, I get an error, that I can't catch as exception: > QXcbConnection: Could not connect to> display #include #include #include using namespace cv; using namespace std; int main( int argc, char** argv ) { if( argc != 2) return -1; Mat image = imread(argv[1], CV_LOAD_IMAGE_COLOR); if(! image.data ) return -1; try { namedWindow( "Display window", WINDOW_AUTOSIZE ); imshow( "Display window", image ); waitKey(0); } catch(...) { imwrite( "output.jpg", image ); } return 0; } Currently OpenCV application requires addition flag -monitor to enable/disable output to the window, that isn't very usable. There is not required a full-fledged API, which would replace the OS API. But it would be very useful if there was a function that returns whether the monitor is connected or not.

Viewing all articles
Browse latest Browse all 135

Latest Images

Trending Articles



Latest Images