sksurgeryimage.calibration.point_detector module

Base class for a PointDetector.

e.g. Chessboard corners, SIFT points, Charuco points etc.

class sksurgeryimage.calibration.point_detector.PointDetector(scale=(1, 1), camera_intrinsics=None, distortion_coefficients=None)[source]

Bases: object

Class to detect points in a 2D video image.

These point detectors are often used to detect points for camera calibration. However, it would also be possible for some subclasses to utilise camera intrinsics and distortion coefficients in order to improve the point detection process itself. It would be up to the derived class to decide how to use them, if at all.

Parameters:
  • scale – tuple (x scale, y scale) to scale up/down the image
  • camera_intrinsics – [3x3] camera matrix
  • distortion_coefficients – [1xn] distortion coefficients
get_camera_parameters()[source]

Returns a copy of the camera matrix, and distortion coefficients. Throws RuntimeError if either are None.

Returns:[3x3], [1xn] matrices
get_model_points()[source]

Derived classes should override this, to detector returns the complete model of 3D points. e.g. for a chessboard this would be all the corners in chessboard coordinates (e.g. z=0).

By design, this can return an ndarray with zero rows, if the detector does not support 3D coordinates.

Returns:[Nx3] numpy ndarray representing model points.
get_points(image, is_distorted=True)[source]

Client’s call this method to extract points from an image.

Parameters:
  • image – numpy 2D RGB/grayscale image.
  • is_distorted – False if the input image has already been undistorted.
Returns:

ids, object_points, image_points as Nx[1,3,2] ndarrays

set_camera_parameters(camera_intrinsics, distortion_coefficients)[source]

Enables camera parameters to be set dynamically at run-time. Calls _validate_camera_parameters().

Parameters:
  • camera_intrinsics – [3x3] camera matrix
  • distortion_coefficients – [1xn] distortion coefficients