From 2019234ad1152833cd415c953722b8558141ad73 Mon Sep 17 00:00:00 2001 From: Richard Bowman Date: Fri, 9 Aug 2024 02:50:39 +0100 Subject: [PATCH] Close OpenCV camera cleanly --- src/openflexure_microscope_server/things/camera/opencv.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/openflexure_microscope_server/things/camera/opencv.py b/src/openflexure_microscope_server/things/camera/opencv.py index 4732bfda..0b37582f 100644 --- a/src/openflexure_microscope_server/things/camera/opencv.py +++ b/src/openflexure_microscope_server/things/camera/opencv.py @@ -44,6 +44,9 @@ class OpenCVCamera(Camera): return self def __exit__(self, _exc_type, _exc_value, _traceback): + if self.stream_active: + self._capture_enabled = False + self._capture_thread.join() self.cap.release() @thing_property