From 0848ec172a07557083adcf530a92f39497797dc2 Mon Sep 17 00:00:00 2001 From: Guido Diepen Date: Mon, 27 Feb 2017 09:18:12 +0100 Subject: [PATCH] When Ctrl-C is pressed, only use the Exception handler to break out of the main loop. At the end of the method, we destroy all windows and exit the program --- track multiple faces/demo - track multiple faces.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/track multiple faces/demo - track multiple faces.py b/track multiple faces/demo - track multiple faces.py index 1f15b0b..95b521a 100644 --- a/track multiple faces/demo - track multiple faces.py +++ b/track multiple faces/demo - track multiple faces.py @@ -262,11 +262,14 @@ def detectAndTrackMultipleFaces(): #To ensure we can also deal with the user pressing Ctrl-C in the console - #we have to check for the KeyboardInterrupt exception and destroy - #all opencv windows and exit the application + #we have to check for the KeyboardInterrupt exception and break out of + #the main loop except KeyboardInterrupt as e: - cv2.destroyAllWindows() - exit(0) + pass + + #Destroy any OpenCV windows and exit the application + cv2.destroyAllWindows() + exit(0) if __name__ == '__main__':