From 240999df530f3e4787678e813b047df73a122378 Mon Sep 17 00:00:00 2001 From: Richard-xx Date: Thu, 14 Dec 2023 14:12:28 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20fix(calibration=5Futils?= =?UTF-8?q?):=20Fix=20marker=5Fcorners=20variables=20initialization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Initialize marker_corners_l and marker_corners_r variables to 0 if res2_l or res2_r is None, respectively, to avoid potential NoneType errors in the subsequent code. --- calibration_utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/calibration_utils.py b/calibration_utils.py index 49353da..e926a9a 100644 --- a/calibration_utils.py +++ b/calibration_utils.py @@ -13,6 +13,7 @@ from functools import reduce from collections import deque from typing import Optional +import re # Creates a set of 13 polygon coordinates rectProjectionMode = 0 @@ -918,6 +919,9 @@ def sgdEpipolar(self, images_left, images_right, M_lp, d_l, M_rp, d_r, r_l, r_r, res2_l = self.detect_charuco_board(image_data_pair[0]) res2_r = self.detect_charuco_board(image_data_pair[1]) + marker_corners_l = 0 if res2_l is None else res2_l[3] + marker_corners_r = 0 if res2_r is None else res2_r[3] + if res2_l[1] is not None and res2_r[2] is not None and len(res2_l[1]) > 3 and len(res2_r[1]) > 3: cv2.cornerSubPix(image_data_pair[0], res2_l[1], @@ -1155,6 +1159,9 @@ def test_epipolar_charuco(self, left_img_pth, right_img_pth, M_l, d_l, M_r, d_r, for i, image_data_pair in enumerate(image_data_pairs): res2_l = self.detect_charuco_board(image_data_pair[0]) res2_r = self.detect_charuco_board(image_data_pair[1]) + + marker_corners_l = 0 if res2_l is None else res2_l[3] + marker_corners_r = 0 if res2_r is None else res2_r[3] if self.traceLevel == 2 or self.traceLevel == 4 or self.traceLevel == 10: print(f'Marekrs length for pair {i} is: L {len(res2_l[1])} | R {len(res2_r[1])} ')