diff --git a/picamera2/formats.py b/picamera2/formats.py index 348ce642..85a4e5b4 100644 --- a/picamera2/formats.py +++ b/picamera2/formats.py @@ -11,7 +11,7 @@ "BGGR16_PISP_COMP1", "GBRG16_PISP_COMP1", "GRBG16_PISP_COMP1", "RGGB16_PISP_COMP1", "SBGGR16", "SGBRG16", "SGRBG16", "SRGGB16", } -MONO_FORMATS = {"R8", "R10", "R12", "R8_CSI2P", "R10_CSI2P", "R12_CSI2P"} +MONO_FORMATS = {"R8", "R10", "R12", "R16", "R8_CSI2P", "R10_CSI2P", "R12_CSI2P"} ALL_FORMATS = YUV_FORMATS | RGB_FORMATS | BAYER_FORMATS | MONO_FORMATS diff --git a/picamera2/picamera2.py b/picamera2/picamera2.py index ec60e7d7..caff2cf0 100644 --- a/picamera2/picamera2.py +++ b/picamera2/picamera2.py @@ -238,6 +238,9 @@ def __init__(self, camera_num=0, verbose_console=None, tuning=None, allocator=No os.environ.pop("LIBCAMERA_RPI_TUNING_FILE", None) # Use default tuning self.notifyme_r, self.notifyme_w = os.pipe2(os.O_NONBLOCK) self.notifymeread = os.fdopen(self.notifyme_r, 'rb') + # Set these before trying to open the camera in case that fails (shutting stuff down may check them). + self._preview = None + self.is_open = False # Get the real libcamera internal number. camera_num = self.global_camera_info()[camera_num]['Num'] self._cm.add(camera_num, self) @@ -279,9 +282,7 @@ def camera_manager(self): def _reset_flags(self) -> None: self.camera = None - self.is_open = False self.camera_ctrl_info = {} - self._preview = None self.camera_config = None self.libcamera_config = None self.streams = None