update watershed.py: check if windows are still open
authorSimon Hänisch <simonhaenisch@users.noreply.github.com>
Mon, 27 Jun 2016 15:03:37 +0000 (17:03 +0200)
committerGitHub <noreply@github.com>
Mon, 27 Jun 2016 15:03:37 +0000 (17:03 +0200)
change the `while` loop to check if the two windows created by this example still exist, stop the program otherwise

samples/python/watershed.py

index 6d349e1..134e499 100755 (executable)
@@ -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