calibration: caller provides threshold

This commit is contained in:
2025-12-11 10:34:00 +01:00
parent de0d089ebc
commit 6c8fc36819
2 changed files with 6 additions and 4 deletions
+5 -3
View File
@@ -42,13 +42,15 @@ class Calibration:
calib = {'mtx': mtx.tolist(), 'dist': dist.tolist()} calib = {'mtx': mtx.tolist(), 'dist': dist.tolist()}
print(f"Saved {filename} successfully!") print(f"Saved {filename} successfully!")
def process(self, image: np.ndarray, r_vecs=None, t_vecs=None, flags=0): def process(self, image: np.ndarray, thresh=3.0, r_vecs=None, t_vecs=None, flags=0):
success = False success = False
if len(self.obj_points_list) > 0 and len(self.img_points_list) > 0: no = len(self.obj_points_list)
ni = len(self.img_points_list)
if no == ni and no > 0:
ret, mtx, dist, r_vecs, t_vecs = cv.calibrateCamera(self.obj_points_list, self.img_points_list, image.shape, self.mtx, self.dist, ret, mtx, dist, r_vecs, t_vecs = cv.calibrateCamera(self.obj_points_list, self.img_points_list, image.shape, self.mtx, self.dist,
rvecs=r_vecs, tvecs=t_vecs, flags=flags) rvecs=r_vecs, tvecs=t_vecs, flags=flags)
if ret < 3: if ret < thresh:
success = True success = True
self.mtx = mtx self.mtx = mtx
self.dist = dist self.dist = dist
+1 -1
View File
@@ -185,7 +185,7 @@ class Detector(abc.ABC):
print(f"{det}: Points matching success") print(f"{det}: Points matching success")
elif k == ord('c'): elif k == ord('c'):
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY) gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
if self.calibration.process(gray): if self.calibration.process(gray, thresh=3*len(self.detector)):
print(f"{self.camera_name}: Camera calibration success") print(f"{self.camera_name}: Camera calibration success")
self.calibration.save(f"{RESULTS_FOLDER}/{self.camera_name}_cal.npz") self.calibration.save(f"{RESULTS_FOLDER}/{self.camera_name}_cal.npz")
elif k == ord('x'): elif k == ord('x'):