DestroyWindow does not close window on Mac using Python and OpenCV

后端 未结 12 1119
野趣味
野趣味 2020-11-27 05:36

My program generates a series of windows using the following code:

def display(img, name, fun):
    global clicked

    cv.NamedWindow(name, 1)
    cv.ShowIm         


        
12条回答
  •  南笙
    南笙 (楼主)
    2020-11-27 05:50

    There are a few peculiarities with the GUI in OpenCV. The destroyImage call fails to close a window (atleast under Linux, where the default backend was Gtk+ until 2.1.0) unless waitKey was called to pump the events. Adding a waitKey(1) call right after destroyWindow may work.

    Even so, closing is not guaranteed; the the waitKey function is only intercepted if a window has focus, and so if the window didn't have focus at the time you invoked destroyWindow, chances are it'll stay visible till the next destroyWindow call.

    I'm assuming this is a behaviour that stems from Gtk+; the function didn't give me any trouble when I used it under Windows.

提交回复
热议问题