Metrology

class src.processing_cores.metrology.Metrology

Class Metrology for calibration and measurements.

activate_metrology(configuration_id)

Activates the “configuration_id”th metrology.

Arguments:

configuration_id (int): Metrology configuration id

Returns:

bool: Whether the given metrology is activated.

calibrate(configuration_id, image, real_roi_length, real_roi_width)

Generate a new image calibration saved at id “configuration_id”.

Arguments:

configuration_id (int): Configuration id for backup image (Image): Calibration image real_roi_length (float): ROI real length in mm real_roi_width (float): ROI real width in mm

Returns:

bool: Whether the calibration proceed or not.

correct_ratio(image)

Corrects the image ratio.

Arguments:

image (Image): Input image

Returns:

Image: Resized image

estimate_deformations(image)

Calculates camera intrinsic parameters and distortion coefficients.

Arguments:

image (Image): Calibration image

Returns:

numpy.ndarray: Intrinsic parameters array

numpy.ndarray: Distortion coefficients array

estimate_perspective(image)

Computes image corners perspective transformation

Arguments:

image (Image): Input image

Returns:

numpy.ndarray: Transformed image four corners

is_calibrated()

Checks if there is some configuration stored.

Returns:

bool: Whether there is some configuration stored.

mm_to_px(mm)

Converts values in millimeters to values in pixels.

Arguments:

px (int): Values in millimeters

Returns:

float: Values in pixels

normalize(image)

Normalizes image.

Arguments:

image (Image): Input image

Returns:

Image: Normalized image

px_to_mm(px)

Converts values in pixels to values in millimeters.

Arguments:

px (int): Values in pixels

Returns:

float: Values in millimeters

save_calibration()

Saves the current calibration into “calibration.txt”.

undistort(image)

Compensates the camera distortion in the given image.

Arguments:

image (Image): Input image to undistort

Returns:

Image: Undistorted image

warp(image)

Warps the image with the metrology perspective transformation matrix.

Arguments:

image (Image): Input image

Returns:

Image: Warped image