【发布时间】:2012-04-10 20:28:09
【问题描述】:
OpenCV 2.2 版,C++ 接口。
当在窗口中显示加载的图像时,代码如下:sn-p
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;
}
我在使用鼠标按close button 而不是使用转义键来关闭图像时遇到问题。
在这种情况下,我的程序将被阻止在while 中,退出它的唯一方法是停止执行,这显然是不希望的。
是否有任何功能可以控制close button 是否被按下?
这样我就可以将它添加到 while 循环中:
例如
while( 1 ) {
if( cvWaitKey(100) == 27 ) break;
if( cvCloseButtonPressed == 1) break; <--- purely invented method I'm looking for...
}
【问题讨论】:
标签: opencv window mouseevent