- fixed: first undistort, then scale down

This commit is contained in:
2025-12-12 13:35:29 +01:00
parent 86cd62218e
commit 352f3f880a
2 changed files with 11 additions and 3 deletions
+2 -1
View File
@@ -59,6 +59,7 @@ class Calibration:
return dst
def process(self, image: np.ndarray, thresh=3.0):
flags = cv.CALIB_RATIONAL_MODEL + 0*cv.CALIB_FIX_PRINCIPAL_POINT
criteria = (cv.TERM_CRITERIA_EPS + cv.TERM_CRITERIA_MAX_ITER, 3000, 0.001)
success = False
error = -1
@@ -66,7 +67,7 @@ class Calibration:
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,
rvecs=None, tvecs=None, flags=cv.CALIB_RATIONAL_MODEL, criteria=criteria)
rvecs=None, tvecs=None, flags=flags, criteria=criteria)
error = ret
if ret < thresh:
success = True
+9 -2
View File
@@ -239,9 +239,16 @@ class Detector(abc.ABC):
self.print_angle(img,f"{str(det)}-{rotation_order}", rot, (30, int(y_pos/k_scale)), rotation_order, 1./k_scale)
y_pos += 30
img_scaled = cv.resize(img, dsize=None, fx=k_scale, fy=k_scale)
# show scaled version of input image
if show_undistorted_image:
img_scaled = self.calibration.image_remap(img_scaled)
# undistort first
img_ud = self.calibration.image_remap(img)
# then scale
img_scaled = cv.resize(img_ud, dsize=None, fx=k_scale, fy=k_scale)
else:
# scale only
img_scaled = cv.resize(img, dsize=None, fx=k_scale, fy=k_scale)
cv.imshow('img', img_scaled)
if self.out_file is not None:
out = out_writer(out, img_scaled, filename=self.out_file)