我想知道opencv窗口是否已经存在。一种可能的解决方案是,
std::string winName = "winName";
cv::namedWindow(winName);
HWND* hwnd = (HWND*)(cvGetWindowHandle(winName.c_str()));
if(hwnd == nullptr)
{
std::cout<<"\n window handle hwnd is null \n";
}
else
{
std::cout<<"\n window handle hwnd is not null \n";
}
cv::destroyAllWindows();
hwnd = (HWND*)(cvGetWindowHandle(winName.c_str()));
if(hwnd == nullptr)
{
std::cout<<"\n window handle hwnd is null \n";
}
else
{
std::cout<<"\n window handle hwnd is not null \n";
}
但这不是一个跨平台的解决方案。有没有 ?