From de37867e1f42d6e8e63d814d5ff7638c9ca9602e Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 20 Sep 2024 10:41:38 +0200 Subject: [PATCH] Don't destroy windows if visualization disabled This fixes the following error on exit when OpenCV is built without GUI support: Traceback (most recent call last): File "facetracker.py", line 450, in cv2.error: OpenCV(4.9.0) /build/source/modules/highgui/src/window.cpp:1266: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvDestroyAllWindows' [254225] Failed to execute script 'facetracker' due to unhandled exception! --- facetracker.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/facetracker.py b/facetracker.py index a30628e..bb6906c 100644 --- a/facetracker.py +++ b/facetracker.py @@ -447,7 +447,8 @@ except KeyboardInterrupt: input_reader.close() if out is not None: out.release() -cv2.destroyAllWindows() +if args.visualize != 0: + cv2.destroyAllWindows() if args.silent == 0 and tracking_frames > 0: average_tracking_time = 1000 * tracking_time / tracking_frames