diff --git a/samples/python/watershed.py b/samples/python/watershed.py index 6d349e1c1b..134e499301 100755 --- a/samples/python/watershed.py +++ b/samples/python/watershed.py @@ -55,7 +55,7 @@ class App: cv2.imshow('watershed', vis) def run(self): - while True: + while cv2.getWindowProperty('img', 0) != -1 or cv2.getWindowProperty('watershed', 0) != -1: ch = 0xFF & cv2.waitKey(50) if ch == 27: break