fluidimage.calibration.calib_cv#

2D/3D Calibration using OpenCV (fluidimage.calibration.calib_cv)#

class fluidimage.calibration.calib_cv.ParamContainerCV(params_cv, tag='OpenCV')[source]#

Bases: ParamContainer

A container to easily display OpenCV parameters

class fluidimage.calibration.calib_cv.SimpleCircleGrid(params: ParamContainerCV)[source]#

Bases: object

Detect the centers of calibration target consisting of a grid of circle shaped points. Use it to detect the image points.

detect_all(image: ndarray, debug=False)[source]#

Detects all blobs as per parameters without any constraints.

Parameters:
image: array

A calibration image of maximum intensity 255.

debugbool

Plot the detected points and the bounding box

detect_grid(image: ndarray, origin: tuple, nx: int, ny: int, ds: float, debug=False)[source]#

Detect a nx by ny circle grid centered around an origin.

Parameters:
image: array

A calibration image of maximum intensity 255.

origin: tuple

Origin / Principal point location in pixel coordinates

nx, nyint

Shape of the grid, i.e. number of points

dsfloat

Grid spacing in pixel coordinates

debugbool

Plot the detected points and the bounding box

class fluidimage.calibration.calib_cv.CalibCV(path_file='cam.h5')[source]#

Bases: object

Calibrate a camera and save them as HDF5 files. Also use this to load saved calibrations and interpolate extrinsic parameters (rotation and translation) while reconstructing.

get_rotation(znew)[source]#

Linearly interpolate the rotation vector based on z location.

get_translate(znew)[source]#

Linearly interpolate the translation vector based on z location.

calibrate(imgpoints: list, objpoints: list, zs: list, im_shape: tuple, origin=None, debug=False, flags=None)[source]#

Calibrate a camera based on a list of image points (in pixel coordinates) and object points (in world coordinates) and the z-locations (in world coordinates).

Parameters:
imgpointslist of arrays

Image points in pixel coordinates. Use SimpleCircleGrid to detect them from a single calibration image. Append such image points from multiple calibration images in a list.

objpointslist of arrays

Object points as produced by function construct_object_points constitute a single array. Likewise append them into a list for multiple calibration images.

zslist of float

List of z locations of the calibration targes in world coordinates.

im_shapetuple of int

Image dimensions in pixels.

origintuple, optional

Origin / Principal point location in pixel coordinates

flagsint, optional

OpenCV specific calibration flags

debugbool, optional

Return the result if true, else save it as an XML file.

Functions

construct_object_points(nx, ny, z, ds)

Prepare object points in world coordinates, as flattened list of coordinates such as.

Classes

CalibCV([path_file])

Calibrate a camera and save them as HDF5 files.

ParamContainerCV(params_cv[, tag])

A container to easily display OpenCV parameters

SimpleCircleGrid(params)

Detect the centers of calibration target consisting of a grid of circle shaped points.