mphy0026.algorithms.camera_calibration module

Functions to support MedPhys Taught Module workshop on calibration and tracking

class mphy0026.algorithms.camera_calibration.InteractiveMeasure(fig, point)[source]

Bases: object

A class to handle mouse press events, outputting the distance to a target point.

mphy0026.algorithms.camera_calibration.calculate_errors(screen_points, projected_points)[source]

Finds corresponding points in each input list, and calculates the distances between each list

mphy0026.algorithms.camera_calibration.distort(lens_3d, distortion)[source]

Distorts a 2D point according to a five parameter distortion :param: a 2D point :param: a 1x5 distortion array [r1, r2, t1, t3, r3] :return: the distorted 2D point

mphy0026.algorithms.camera_calibration.load_intrinsic(filein)[source]

loads a text file formatted, consisting of a 3x3 projection project matrix, followed by a row of distortion coefficients. :return: intrinsic, distortion

mphy0026.algorithms.camera_calibration.load_matrix(filein)[source]

matrix loader :param: filename :return: matrix

mphy0026.algorithms.camera_calibration.load_matrix_as_point(filename, point_id=0)[source]

loads the last column of a 4x4 matrix as a 1 by 4 point, i.e. it discards any rotational data. :param: filename :return: 1x4 point

mphy0026.algorithms.camera_calibration.load_model_points(filein)[source]

loads a four column text file :params: filename :return: array of points

mphy0026.algorithms.camera_calibration.multiply_points_by_matrix(points_in, matrix)[source]

Multiply a matrix of point vectors by a 4x4 matrix :param: An n by 4 matrix of n points, the first

column is the point ID

Param:

A 4x4 matrix

Returns:

An n by 4 matrix of n transformed points

mphy0026.algorithms.camera_calibration.picked_object_directory_reader(directory, points_only=True)[source]

processes an xml picked object directory :param: directory name, and optional flag to only process point landmarks :return: an nx4 array of landmarks, first column is point id

mphy0026.algorithms.camera_calibration.picked_object_reader(filename, points_only=True)[source]

processes an xml picked object file. :param: the filename, and optional flag to only process point landmarks :return: an nx4 array of landmarks, first column is point id

mphy0026.algorithms.camera_calibration.plot_errors(image_file_name, projected_points, screen_points, crop_to_image=True)[source]

Creates a visualisation of the projected and detected screen points

mphy0026.algorithms.camera_calibration.plot_errors_interactive(image_file_name, projected_point, crop_to_image=True)[source]

Creates a visualisation of the projected and detected screen points, which you can click on to measure distances

mphy0026.algorithms.camera_calibration.project(lens_3d, intrinsic)[source]

Projects 3D points relative to the lens to screen points :param: n by 4 matrix n 3D in camera coordinates. First column is the

point ID

Param:

the camera’s intrinsic parameters

:return n by 3 matrix of 2D points on screen coordinates. First column

is the point ID