From bd9ab1d3445078f6f829b189e05bddbe8b14d0c1 Mon Sep 17 00:00:00 2001 From: zrezke Date: Thu, 4 Apr 2024 11:59:05 +0200 Subject: [PATCH] Assume default intrinsics if they couldn't be retrieved. --- rerun_py/depthai_viewer/_backend/device.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rerun_py/depthai_viewer/_backend/device.py b/rerun_py/depthai_viewer/_backend/device.py index 17146a93d8ab..8a041df133e6 100644 --- a/rerun_py/depthai_viewer/_backend/device.py +++ b/rerun_py/depthai_viewer/_backend/device.py @@ -113,9 +113,14 @@ def get_intrinsic_matrix(self, board_socket: dai.CameraBoardSocket, width: int, return self.intrinsic_matrix.get((board_socket, width, height)) # type: ignore[return-value] if self.calibration_data is None: raise Exception("Missing calibration data!") - M_right = self.calibration_data.getCameraIntrinsics( # type: ignore[union-attr] - board_socket, dai.Size2f(width, height) - ) + try: + M_right = self.calibration_data.getCameraIntrinsics( # type: ignore[union-attr] + board_socket, dai.Size2f(width, height) + ) + except RuntimeError: + print("No intrinsics found for camera: ", board_socket, " assuming default.") + f_len = (height * width) ** 0.5 + M_right = [[f_len, 0, width / 2], [0, f_len, height / 2], [0, 0, 1]] self.intrinsic_matrix[(board_socket, width, height)] = np.array(M_right).reshape(3, 3) return self.intrinsic_matrix[(board_socket, width, height)]