diff --git a/src/orisys/sensor.py b/src/orisys/sensor.py index 28751cd..452756e 100644 --- a/src/orisys/sensor.py +++ b/src/orisys/sensor.py @@ -1095,7 +1095,14 @@ class Sensor: # self.cap = None # if self.verbose: # print("Sensor disconnected.") - cv2.destroyAllWindows() + try: + cv2.destroyAllWindows() + except cv2.error: + # A headless OpenCV build (``opencv-python-headless``) has no highgui, + # so there is nothing to close. Failing here would leave the rest of + # the shutdown — and every caller that disconnects in a ``finally`` — + # reporting an error that says nothing about the sensor. + pass # ========================================================================= # Public API - Configuration & Calibration