How to check if an opencv window is closed

后端 未结 5 750
囚心锁ツ
囚心锁ツ 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 15:59

    Suppose you have only one image window open, then clicking the 'x' button at its corner causes the waitkey() function to return a -1 value. Then check if the cvGetWindowHandle("name_of_the_window") function returns 0 or not. If it does return 0, then the window is actually closed. I have tested it in OpenCV3. But I am still not very clear on the reason why the waitkey() return -. I will much appreciate if anyone explains why this happens. [I don't know if my answer to this question will be relevant or not after such a long time. But hopefully if anyone else gets stuck with the same issue (like me), this answer might help them out.] Thanks.

提交回复
热议问题