Skip to content

Commit

Permalink
small calibration changes (#240)
Browse files Browse the repository at this point in the history
feat: set balance to more sensible 0.5
refactor: reuse function
  • Loading branch information
NiklasNeugebauer authored Dec 12, 2024
1 parent 96da831 commit cef33b2
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions rosys/vision/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def get_undistorted_camera_matrix(self, crop: bool = False) -> np.ndarray:
new_K, _ = cv2.getOptimalNewCameraMatrix(K, D, (w, h), 1, (w, h), centerPrincipalPoint=True)
elif self.intrinsics.model == CameraModel.FISHEYE:
new_K = cv2.fisheye.estimateNewCameraMatrixForUndistortRectify(K, D, (w, h), np.eye(3),
balance=0.0 if crop else 1.0,
balance=0.5 if crop else 1.0,
new_size=(w, h),
fov_scale=1)
elif self.intrinsics.model == CameraModel.OMNIDIRECTIONAL:
Expand Down Expand Up @@ -376,9 +376,7 @@ def undistort_array(self, image_array: np.ndarray, crop: bool = False) -> np.nda
x, y, roi_w, roi_h = roi
dst = dst[y:y+roi_h, x:x+roi_w]
elif self.intrinsics.model == CameraModel.FISHEYE:
balance = 0.0 if crop else 1.0
new_K = cv2.fisheye.estimateNewCameraMatrixForUndistortRectify(K, D, (w, h), np.eye(3), balance=balance)

new_K = self.get_undistorted_camera_matrix(crop=crop)
map1, map2 = cv2.fisheye.initUndistortRectifyMap( # pylint: disable=unpacking-non-sequence
K, D, np.eye(3), new_K, (w, h), cv2.CV_16SC2)
dst = cv2.remap(image_array, map1, map2, interpolation=cv2.INTER_LINEAR, borderMode=cv2.BORDER_CONSTANT)
Expand Down

0 comments on commit cef33b2

Please sign in to comment.