我有以下代码:
total_frames = 50
cv2.cv.NamedWindow("Dragonfly Simulation")
cv2.cv.StartWindowThread()
for i in range(total_frames):
# do stuff
img_name = # something
img = cv2.cv.LoadImage(img_name)
cv2.cv.ShowImage("Dragonfly Simulation", img)
cv2.cv.WaitKey(2)
cv2.cv.DestroyWindow("Dragonfly Simulation")
cv2.cv.WaitKey(1)
# rest of code
Run Code Online (Sandbox Code Playgroud)
那么它做了什么:
但是在这种情况下,我有total_frame之前给出的.我不希望这样.
相反,我想要一个执行以下操作的代码:
但是,我在OpenCV中找不到可以检测用户何时关闭窗口的函数.有人可以建议一个解决方法吗?