gpt4 book ai didi

c++ - 如何检查opencv窗口是否关闭

转载 作者:可可西里 更新时间:2023-11-01 18:19:07 32 4
gpt4 key购买 nike

如何检查 opencv 窗口是否已关闭?

我想做的事:

cvNamedWindow("main", 1);

while(!cvWindowIsClosed("main"))
{
cvShowImage("main", myImage);
}

但这些不是这样的 cvWindowIsClosed(...) 函数!

最佳答案

您尝试做的事情可以通过 cvGetWindowHandle() 实现:

The function cvGetWindowHandle returns the native window handle (HWND in case of Win32 and GtkWidget in case of GTK+). [Qt Backend Only] qt-specific details: The function cvGetWindowHandle returns the native window handle inheriting from the Qt class QWidget.

想法是获取窗口句柄,然后使用特定平台 API 函数检查该句柄是否仍然有效。

编辑:

或者您可以使用传统的 cvWaitKey()方法:

char exit_key_press = 0;
while (exit_key_press != 'q') // or key != ESC
{
// retrieve frame

// display frame

exit_key_press = cvWaitKey(10);
}

关于c++ - 如何检查opencv窗口是否关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9321389/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com