How to check if an opencv window is closed

后端 未结 5 747
囚心锁ツ
囚心锁ツ 2020-12-20 15:18

How do you check if an opencv window has been closed?

I would like to do:

cvNamedWindow(\"main\", 1);

while(!cvWindowIsClosed(\"main\"))
{
    cvSho         


        
5条回答
  •  不思量自难忘°
    2020-12-20 16:12

    You can use the cv::getWindowProperty method.

    Do like that:

    cv::namedWindow("main", WINDOW_AUTOSIZE);
    
    while(1)
    {
         cv::imshow("main", myImage);
    
         // add this IF.
         if (cv::getWindowProperty("main", WND_PROP_AUTOSIZE) == -1)
             break;
    }
    

    When the windows be closed the getWindowProperty will return -1.

提交回复
热议问题