sksurgerycalibration.video.video_calibration_driver_stereo module

Class to do stateful video calibration of a stereo camera.

class sksurgerycalibration.video.video_calibration_driver_stereo.StereoVideoCalibrationDriver(left_point_detector: sksurgeryimage.calibration.point_detector.PointDetector, right_point_detector: sksurgeryimage.calibration.point_detector.PointDetector, minimum_points_per_frame: int)[source]

Bases: sksurgerycalibration.video.video_calibration_driver_base.BaseVideoCalibrationDriver

Class to do stateful video calibration of a stereo camera.

calibrate(flags=1, override_left_intrinsics=None, override_left_distortion=None, override_right_intrinsics=None, override_right_distortion=None, override_l2r_rmat=None, override_l2r_tvec=None)[source]

Do the stereo video calibration, returning reprojection and reconstruction error.

This returns RMS projection error, which is a common metric, but also, the reconstruction / triangulation error.

Parameters:
  • flags – OpenCV flags, eg. cv2.CALIB_FIX_INTRINSIC
  • override_left_intrinsics
  • override_left_distortion
  • override_right_intrinsics
  • override_right_distortion
  • override_l2r_rmat
  • override_l2r_tvec
Returns:

projection, reconstruction error.

Return type:

float, float

grab_data(left_image, right_image, device_tracking=None, calibration_object_tracking=None)[source]

Extracts points, by passing it to the PointDetector.

This will throw various exceptions if the input data is invalid, but will return empty arrays if no points were detected. So, no points is not an error. Its an expected condition.

Parameters:
  • left_image – BGR image.
  • right_image – BGR image.
  • device_tracking – transformation for the tracked device
  • calibration_object_tracking – transformation of tracked

calibration object :return: The number of points grabbed.

handeye_calibration(override_pattern2marker=None, use_opencv: bool = True, do_bundle_adjust: bool = False)[source]

Do handeye calibration, returning reprojection and reconstruction error.

Note: This handeye_calibration on this class assumes you are tracking both the calibration pattern (e.g. chessboard) and the device (e.g. laparoscope). So, the calibration routines calibrate for hand2eye and pattern2marker. If you want something more customised, work with video_calibration_hand_eye.py.

Parameters:override_pattern2marker – If provided a 4x4 pattern2marker

that is taken as constant. :param use_opencv: If True we use OpenCV based methods, if false, Guofang Xiao’s method. :param do_bundle_adjust: If True we do an additional bundle adjustment at the end.

Returns:reprojection, reconstruction error, camera parameters
Return type:float, float, object
iterative_calibration(number_of_iterations: int, reference_ids, reference_image_points, reference_image_size, flags: int = 1)[source]

Does iterative calibration, like Datta 2009, returning reprojection and reconstruction error.

Returns:projection, reconstruction error.
Return type:float, float