Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various changes #1162

Merged
merged 4 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions picamera2/devices/imx500/imx500.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
from picamera2 import CompletedRequest, Picamera2

NETWORK_NAME_LEN = 64
MAX_NUM_TENSORS = 8
MAX_NUM_DIMENSIONS = 8
MAX_NUM_TENSORS = 16
MAX_NUM_DIMENSIONS = 16

FW_LOADER_STAGE = 0
FW_MAIN_STAGE = 1
Expand Down Expand Up @@ -581,14 +581,11 @@ def __get_input_tensor_info(self, tensor_info) -> tuple[str, int, int, int]:

@staticmethod
def get_kpi_info(metadata: dict) -> Optional[tuple[float, float]]:
"""Return the KPI parameters in the form (dnn_runtime, dsp_runtime)."""
"""Return the KPI parameters in the form (dnn_runtime, dsp_runtime) in milliseconds."""
kpi_info = metadata.get('CnnKpiInfo')
if kpi_info is None:
return None
if type(kpi_info) not in [bytes, bytearray]:
kpi_info = bytes(kpi_info)

dnn_runtime, dsp_runtime = struct.unpack('II', kpi_info)
dnn_runtime, dsp_runtime = kpi_info[0], kpi_info[1]
return dnn_runtime / 1000, dsp_runtime / 1000

def __set_network_firmware(self, network_filename: str):
Expand Down
2 changes: 1 addition & 1 deletion picamera2/picamera2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ def configure_(self, camera_config="preview") -> None:
self.controls = Controls(self, controls=self.camera_config['controls'])
self.configure_count += 1

if False and "ScalerCrops" in self.camera_controls:
if "ScalerCrops" in self.camera_controls:
par_crop = self.camera_controls["ScalerCrops"]
full_fov = self.camera_controls["ScalerCrop"][1]
scaler_crops = [par_crop[0] if camera_config["main"]["preserve_ar"] else full_fov]
Expand Down
5 changes: 2 additions & 3 deletions tests/crop_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@

for m, l in [(False, False), (False, True), (True, False), (True, True)]:
cfg = picam2.create_video_configuration(main={"size": (1920, 1080), "format": 'XRGB8888', "preserve_ar": m},
lores={"size": (640, 640), "format": 'XRGB8888', "preserve_ar": l},
lores={"size": (320, 320), "format": 'XRGB8888', "preserve_ar": l},
display="main")
picam2.configure(cfg)
picam2.start(show_preview=True)

for _ in range(100):
for _ in range(50):
im = picam2.capture_array("lores")
cv2.imshow("lores", im)
cv2.resizeWindow("lores", (640, 640))
cv2.waitKey(1)

picam2.stop()
Loading