diff --git a/apps/app_full.py b/apps/app_full.py index 71aed9c2..272cf399 100755 --- a/apps/app_full.py +++ b/apps/app_full.py @@ -7,7 +7,7 @@ QLineEdit, QPushButton, QSlider, QSpinBox, QTabWidget, QVBoxLayout, QWidget) -from picamera2 import Picamera2 +from picamera2 import Picamera2, utils from picamera2.encoders import H264Encoder, Quality from picamera2.outputs import FfmpegOutput, FileOutput from picamera2.previews.qt import QGlPicamera2 @@ -92,7 +92,7 @@ def update_controls(): global scaler_crop # Fix aspect ratio of the pan/zoom - full_img = picam2.camera_properties["ScalerCropMaximum"] + full_img = utils.convert_from_libcamera_type(picam2.camera_ctrl_info['ScalerCrop'][1].max) ar = full_img[2] / full_img[3] new_scaler_crop = list(scaler_crop) new_scaler_crop[3] = int(new_scaler_crop[2] / ar) @@ -516,7 +516,7 @@ class panZoomDisplay(QWidget): def __init__(self): super().__init__() self.setMinimumSize(201, 151) - self.scale = 200 / picam2.camera_properties["ScalerCropMaximum"][2] + self.scale = 200 / utils.convert_from_libcamera_type(picam2.camera_ctrl_info['ScalerCrop'][1].max)[2] self.zoom_level_ = 1.0 self.max_zoom = 7.0 self.zoom_step = 0.1 @@ -537,7 +537,7 @@ def setZoomLevel(self, val): def paintEvent(self, event): painter = QPainter() painter.begin(self) - full_img = picam2.camera_properties["ScalerCropMaximum"] + full_img = utils.convert_from_libcamera_type(picam2.camera_ctrl_info['ScalerCrop'][1].max) self.scale = 200 / full_img[2] # Whole frame scaled_full_img = [int(i * self.scale) for i in full_img] @@ -555,11 +555,11 @@ def paintEvent(self, event): def draw_centered(self, pos): global scaler_crop center = [int(i / self.scale) for i in pos] - full_img = picam2.camera_properties["ScalerCropMaximum"] + full_img = utils.convert_from_libcamera_type(picam2.camera_ctrl_info['ScalerCrop'][1].max) w = scaler_crop[2] h = scaler_crop[3] - x = center[0] - w // 2 + picam2.camera_properties["ScalerCropMaximum"][0] - y = center[1] - h // 2 + picam2.camera_properties["ScalerCropMaximum"][1] + x = center[0] - w // 2 + full_img[0] + y = center[1] - h // 2 + full_img[1] new_scaler_crop = [x, y, w, h] # Check still within bounds @@ -583,7 +583,7 @@ def setZoom(self): if self.zoom_level > self.max_zoom: self.zoom_level = self.max_zoom factor = 1.0 / self.zoom_level - full_img = picam2.camera_properties["ScalerCropMaximum"] + full_img = utils.convert_from_libcamera_type(picam2.camera_ctrl_info['ScalerCrop'][1].max) current_center = (scaler_crop[0] + scaler_crop[2] // 2, scaler_crop[1] + scaler_crop[3] // 2) w = int(factor * full_img[2]) h = int(factor * full_img[3]) @@ -1128,9 +1128,9 @@ def apply_settings(self): # Finally set the modes and check sensor crop if self.preview_check.isChecked(): switch_config("still") - current_crop = picam2.camera_properties["ScalerCropMaximum"] + current_crop = utils.convert_from_libcamera_type(picam2.camera_ctrl_info['ScalerCrop'][1].max) switch_config("preview") - if current_crop != picam2.camera_properties["ScalerCropMaximum"]: + if current_crop != utils.convert_from_libcamera_type(picam2.camera_ctrl_info['ScalerCrop'][1].max): print("Preview and Still configs have different aspect ratios") self.preview_warning.show() else: @@ -1208,7 +1208,7 @@ def toggle_hidden_controls(): # Final setup window.setWindowTitle("Qt Picamera2 App") recording = False -scaler_crop = picam2.camera_properties["ScalerCropMaximum"] +scaler_crop = utils.convert_from_libcamera_type(picam2.camera_ctrl_info['ScalerCrop'][1].max) hdr_imgs = {"exposures": None} pic_tab.apply_settings() diff --git a/picamera2/picamera2.py b/picamera2/picamera2.py index 4677c2ac..f8f41137 100644 --- a/picamera2/picamera2.py +++ b/picamera2/picamera2.py @@ -499,7 +499,7 @@ def sensor_modes(self) -> list: self.configure(temp_config) frameDurationMin = self.camera_controls["FrameDurationLimits"][0] cam_mode["fps"] = round(1e6 / frameDurationMin, 2) - cam_mode["crop_limits"] = self.camera_properties["ScalerCropMaximum"] + cam_mode["crop_limits"] = utils.convert_from_libcamera_type(self.camera_ctrl_info['ScalerCrop'][1].max) cam_mode["exposure_limits"] = tuple([i for i in self.camera_controls["ExposureTime"] if i != 0]) self.sensor_modes_.append(cam_mode) return self.sensor_modes_ diff --git a/tests/autofocus_test.py b/tests/autofocus_test.py index bc675295..6023b395 100755 --- a/tests/autofocus_test.py +++ b/tests/autofocus_test.py @@ -2,7 +2,7 @@ from libcamera import controls -from picamera2 import Picamera2 +from picamera2 import Picamera2, utils picam2 = Picamera2() if 'AfMode' not in picam2.camera_controls: @@ -94,6 +94,6 @@ time.sleep(0.1) print("Test AfWindows") -max_window = picam2.camera_properties['ScalerCropMaximum'] +max_window = utils.convert_from_libcamera_type(picam2.camera_ctrl_info['ScalerCrop'][1].max) picam2.set_controls({'AfWindows': [max_window]}) time.sleep(0.1)