OpenCV version 2.2, C++ interface.
When showing a loaded image in a window with following code snippet
cvStartWindowThread();
Mat image;
image = imread(argv[1], CV_LOAD_IMAGE_COLOR); // Read the file
if(! image.data ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window", image );
while( 1 ) {
if( cvWaitKey(100) == 27 ) break;
}
I face a problem when closing image by pressing the close button
with the mouse, instead of using escape key.
In this case my program will be blocked in the while
and the only way to exit it is to stop execution, which obviously is not desired.
Is there any function that controls if the close button
has been pressed?
In that way I could add it in the while loop as this:
E.g.
while( 1 ) {
if( cvWaitKey(100) == 27 ) break;
if( cvCloseButtonPressed == 1) break; <--- purely invented method I'm looking for...
}