AprilTagDetector

class robotpy_apriltag.AprilTagDetector

Bases: pybind11_object

An AprilTag detector engine. This is expensive to set up and tear down, so most use cases should only create one of these, add a family to it, set up any other configuration, and repeatedly call Detect().

class Config

Bases: pybind11_object

Detector configuration.

property debug

Debug mode. When true, the decoder writes a variety of debugging images to the current working directory at various stages through the detection process. This is slow and should not be used on space-limited systems such as the RoboRIO. Default is disabled (false).

property decodeSharpening

How much sharpening should be done to decoded images. This can help decode small tags but may or may not help in odd lighting conditions or low light conditions. Default is 0.25.

property numThreads

How many threads should be used for computation. Default is single-threaded operation (1 thread).

property quadDecimate

Quad decimation. Detection of quads can be done on a lower-resolution image, improving speed at a cost of pose accuracy and a slight decrease in detection rate. Decoding the binary payload is still done at full resolution. Default is 2.0.

property quadSigma

What Gaussian blur should be applied to the segmented image (used for quad detection). Very noisy images benefit from non-zero values (e.g. 0.8). Default is 0.0.

property refineEdges

When true, the edges of the each quad are adjusted to “snap to” strong gradients nearby. This is useful when decimation is employed, as it can increase the quality of the initial quad estimate substantially. Generally recommended to be on (true). Default is true.

Very computationally inexpensive. Option is ignored if quad_decimate = 1.

class QuadThresholdParameters

Bases: pybind11_object

Quad threshold parameters.

property criticalAngle

Critical angle. The detector will reject quads where pairs of edges have angles that are close to straight or close to 180 degrees. Zero means that no quads are rejected. Default is 10 degrees.

property deglitch

Whether the thresholded image be should be deglitched. Only useful for very noisy images. Default is disabled (false).

property maxLineFitMSE

When fitting lines to the contours, the maximum mean squared error allowed. This is useful in rejecting contours that are far from being quad shaped; rejecting these quads “early” saves expensive decoding processing. Default is 10.0.

property maxNumMaxima

How many corner candidates to consider when segmenting a group of pixels into a quad. Default is 10.

property minClusterPixels

Threshold used to reject quads containing too few pixels. Default is 5 pixels.

property minWhiteBlackDiff

Minimum brightness offset. When we build our model of black & white pixels, we add an extra check that the white model must be (overall) brighter than the black model. How much brighter? (in pixel values, [0,255]). Default is 5.

addFamily(fam: str, bitsCorrected: int = 2) bool

Adds a family of tags to be detected.

Parameters:
  • fam – Family name, e.g. “tag16h5”

  • bitsCorrected

Returns:

False if family can’t be found

clearFamilies() None

Unregister all families.

detect(image: buffer) List[robotpy_apriltag._apriltag.AprilTagDetection]

Detect tags from an 8-bit grayscale image with shape (width, height)

Returns:

list of results

getConfig() robotpy_apriltag._apriltag.AprilTagDetector.Config

Gets detector configuration.

Returns:

Configuration

getQuadThresholdParameters() robotpy_apriltag._apriltag.AprilTagDetector.QuadThresholdParameters

Gets quad threshold parameters.

Returns:

Parameters

removeFamily(fam: str) None

Removes a family of tags from the detector.

Parameters:

fam – Family name, e.g. “tag16h5”

setConfig(config: robotpy_apriltag._apriltag.AprilTagDetector.Config) None

Sets detector configuration.

Parameters:

config – Configuration

setQuadThresholdParameters(params: robotpy_apriltag._apriltag.AprilTagDetector.QuadThresholdParameters) None

Sets quad threshold parameters.

Parameters:

params – Parameters