Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

you do not have to "kill imshow()". all you have to do is "catch" the event you're looking for, and make it break the loop.

a typical program looks like this:

while True:
     img = cv2.imread("some_random.png")
     # some processing

     if my_event_happened:  # insert your event here!
            break

     cv2 imshow("I", img)
     cv2.waitKey(20)

note, that you still need the waitKey() call for showing the image !

you do not have to "kill imshow()". all you have to do is "catch" the event you're looking for, and make it break the loop.

a typical program looks like this:

while True:
     img = cv2.imread("some_random.png")
     # some processing

     if my_event_happened:  # insert your event here!
            break

     cv2 imshow("I", img)
     cv2.waitKey(20)

note, that you still need the waitKey() call for showing the image !

also, take a look at the py gui tutorials .