oakutils.aruco package

Submodules

oakutils.aruco.finder module

Module for finding aruco markers in images and acquiring transformation matrices to them.

Classes

ArucoFinder

Use to find ArUco markers in an image.

class oakutils.aruco.finder.ArucoFinder(aruco_dict: int = 1, marker_size: float = 0.05, calibration: ColorCalibrationData | MonoCalibrationData | None = None)

Bases: object

Class for finding aruco markers in images and acquiring transformation matrices to them.

property calibration: ColorCalibrationData | MonoCalibrationData | None

The calibration data used by the ArucoFinder.

Returns:

The calibration data used by the ArucoFinder

Return type:

ColorCalibrationData, MonoCalibrationData, None

draw(image: np.ndarray, markers: Sequence[tuple[int, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]) np.ndarray

Use to draw the detected markers onto the image.

Parameters:
  • image (np.ndarray) – The image to draw the markers on

  • markers (Sequence[tuple[int, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]) – The sequence of aruco markers found in the image Each tuple contains the id, transformation matrix, rotation vector, translation vector, and corners

Returns:

A copy of the image with the markers drawn on it

Return type:

np.ndarray

find(image: np.ndarray, *, rectified: bool | None = None) Sequence[tuple[int, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]

Use to find the aruco markers in the image.

Note: Makes an assumption that there is a single marker for each id.

Parameters:
  • image (np.ndarray) – The image to find the marker in

  • rectified (bool, optional) – Whether or not the image is rectified, by default None If None will use the calibration data to undistort the image

Returns:

The sequence of aruco markers found in the image Each tuple contains the id, transformation matrix, rotation vector, translation vector, and corners

Return type:

Sequence[tuple[int, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]

oakutils.aruco.localizer module

Module for localizing the camera in the world using ArUco markers.

Classes

ArucoLocalizer

Use to localize the camera in the world using ArUco markers.

class oakutils.aruco.localizer.ArucoLocalizer(transforms: dict[int, np.ndarray], buffersize: int = 5, max_age: int = 5, alpha: float = 0.95)

Bases: object

Localizes the camera in the world using ArUco markers.

add_transform(tag: int, transform: np.ndarray) None

Use to add a transform to the localizer.

Parameters:
  • tag (int) – The id of the marker to use

  • transform (np.ndarray) – The transform from the world to the marker

localize(markers: Sequence[tuple[int, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]) np.ndarray

Use to localize the camera in the world using ArUco markers.

Parameters:

markers (Sequence[tuple[int, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]) – A sequence of markers detected sin the image

Returns:

The transform from the world to camera

Return type:

np.ndarray

oakutils.aruco.stream module

Module for filtering aruco marker detections as a continous stream.

Classes

ArucoStream

Use to filter aruco marker detections as a continous stream.

class oakutils.aruco.stream.ArucoStream(aruco_dict: int = 1, marker_size: float = 0.05, calibration: ColorCalibrationData | MonoCalibrationData | None = None, buffersize: int = 5, max_age: int = 5, alpha: float = 0.95)

Bases: object

Class for filtering aruco marker detections as a continous stream.

draw(image: np.ndarray, markers: Sequence[tuple[int, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]) np.ndarray

Use to draw the detected markers onto the image.

Parameters:
  • image (np.ndarray) – The image to draw the markers on

  • markers (Sequence[tuple[int, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]) – The sequence of aruco markers found in the image Each tuple contains the id, transformation matrix, rotation vector, translation vector, and corners

Returns:

A copy of the image with the markers drawn on it.

Return type:

np.ndarray

find(image: np.ndarray, *, rectified: bool | None = None) Sequence[tuple[int, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]

Use to find the aruco markers in the image and perform filtering.

Note: Makes an assumption that there is a single marker for each id.

Parameters:
  • image (np.ndarray) – The image to find the marker in

  • rectified (bool, optional) – Whether or not the image is rectified, by default None If None will use the calibration data to undistort the image

Returns:

The list of aruco markers found in the image Each tuple contains the id, transformation matrix, rotation vector, translation vector, and corners

Return type:

Sequence[tuple[int, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]

Module contents

Module for ArUco marker detection and localization.

Classes

ArucoFinder

Use to find ArUco markers in an image.

ArucoLocalizer

Use to localize the camera within the world frame using ArUco markers.

ArucoStream

Used on a video stream to find ArUco markers.

class oakutils.aruco.ArucoFinder(aruco_dict: int = 1, marker_size: float = 0.05, calibration: ColorCalibrationData | MonoCalibrationData | None = None)

Bases: object

Class for finding aruco markers in images and acquiring transformation matrices to them.

property calibration: ColorCalibrationData | MonoCalibrationData | None

The calibration data used by the ArucoFinder.

Returns:

The calibration data used by the ArucoFinder

Return type:

ColorCalibrationData, MonoCalibrationData, None

draw(image: np.ndarray, markers: Sequence[tuple[int, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]) np.ndarray

Use to draw the detected markers onto the image.

Parameters:
  • image (np.ndarray) – The image to draw the markers on

  • markers (Sequence[tuple[int, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]) – The sequence of aruco markers found in the image Each tuple contains the id, transformation matrix, rotation vector, translation vector, and corners

Returns:

A copy of the image with the markers drawn on it

Return type:

np.ndarray

find(image: np.ndarray, *, rectified: bool | None = None) Sequence[tuple[int, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]

Use to find the aruco markers in the image.

Note: Makes an assumption that there is a single marker for each id.

Parameters:
  • image (np.ndarray) – The image to find the marker in

  • rectified (bool, optional) – Whether or not the image is rectified, by default None If None will use the calibration data to undistort the image

Returns:

The sequence of aruco markers found in the image Each tuple contains the id, transformation matrix, rotation vector, translation vector, and corners

Return type:

Sequence[tuple[int, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]

class oakutils.aruco.ArucoLocalizer(transforms: dict[int, np.ndarray], buffersize: int = 5, max_age: int = 5, alpha: float = 0.95)

Bases: object

Localizes the camera in the world using ArUco markers.

add_transform(tag: int, transform: np.ndarray) None

Use to add a transform to the localizer.

Parameters:
  • tag (int) – The id of the marker to use

  • transform (np.ndarray) – The transform from the world to the marker

localize(markers: Sequence[tuple[int, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]) np.ndarray

Use to localize the camera in the world using ArUco markers.

Parameters:

markers (Sequence[tuple[int, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]) – A sequence of markers detected sin the image

Returns:

The transform from the world to camera

Return type:

np.ndarray

class oakutils.aruco.ArucoStream(aruco_dict: int = 1, marker_size: float = 0.05, calibration: ColorCalibrationData | MonoCalibrationData | None = None, buffersize: int = 5, max_age: int = 5, alpha: float = 0.95)

Bases: object

Class for filtering aruco marker detections as a continous stream.

draw(image: np.ndarray, markers: Sequence[tuple[int, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]) np.ndarray

Use to draw the detected markers onto the image.

Parameters:
  • image (np.ndarray) – The image to draw the markers on

  • markers (Sequence[tuple[int, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]) – The sequence of aruco markers found in the image Each tuple contains the id, transformation matrix, rotation vector, translation vector, and corners

Returns:

A copy of the image with the markers drawn on it.

Return type:

np.ndarray

find(image: np.ndarray, *, rectified: bool | None = None) Sequence[tuple[int, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]

Use to find the aruco markers in the image and perform filtering.

Note: Makes an assumption that there is a single marker for each id.

Parameters:
  • image (np.ndarray) – The image to find the marker in

  • rectified (bool, optional) – Whether or not the image is rectified, by default None If None will use the calibration data to undistort the image

Returns:

The list of aruco markers found in the image Each tuple contains the id, transformation matrix, rotation vector, translation vector, and corners

Return type:

Sequence[tuple[int, np.ndarray, np.ndarray, np.ndarray, np.ndarray]]