I have the following code:
total_frames = 50
for i in range(total_frames):
# do stuff
img_name = # something
img = cv2.cv.LoadImage(img_name)
cv2.cv.ShowImage("Dragonfly Simulation", img)
# rest of code
I was just looking for a way to detect when the window has been closed using the
X button of the window in addition to waiting for a key press, but I couldn't find an answer anywhere (
cvGetWindowHandle are not available in the Python
So I played around and this is how it works:
while cv2.getWindowProperty('window-name', 0) >= 0: keyCode = cv2.waitKey(50) ...
-1 as soon is the window is closed.
See the documentation for the enumeration of
cv::WindowPropertyFlags for how this works: getting the flag with index
0 is the fullscreen property, but actually it doesn't matter which flag to use, they all become
-1 as soon as the window is closed.