My program generates a series of windows using the following code:
def display(img, name, fun):
cv.SetMouseCallback(name, fun, img)
while cv.WaitKey(33) == -1:
if clicked == 1:
clicked = 0
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
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.