Tag Decoding

Python Functions

actag.tag_decoding.add_detected_tags_to_axis(ax: Axes, detected_tags: list[list], img_dims: tuple[int, int]) None

Visualizes detected tags onto a matplotlib.pyplot.Axes.

Parameters:
  • ax (matplotlib.pyplot.Axes) – The axis to add the detected tags to.

  • detected_tags (list[list]) – The detected tags to visualize.

  • img_dims (tuple[int, int]) – The dimensions of the image the tags are from.

Returns:

None

actag.tag_decoding.add_sample_locations_to_axis(ax: Axes, quads: list[ndarray], tag_params: AcTagParams, img_dims: tuple[int, int]) None

Adds the sampled data bit locations for each quad to the axis as green dots.

Parameters:
  • ax (matplotlib.pyplot.Axes) – The axis to add the data bit locations to.

  • quads (list[np.ndarray]) – The quads to add the data bit locations for.

  • tag_params (AcTagParams) – The parameters of the AcTag and its family.

  • img_dims (tuple[int, int]) – The dimensions of the image the quads are from.

Returns:

None

actag.tag_decoding.check_quad_for_tag(binary_img: ndarray, quad_corners: ndarray, data_bit_locations: ndarray, tag_params: AcTagParams, num_bit_corrections: int) list[list]

Determine bit values at each of the data bit locations, and if there is a match, return the corresponding tag.

Parameters:
  • binary_img (np.ndarray) – The binary sonar image to search for tags in.

  • quad_corners (np.ndarray) – The corners of the quadrilateral.

  • data_bit_locations (np.ndarray) – The locations of the data bits for the potential tag in the sonar image.

  • tag_params (AcTagParams) – The parameters of the AcTag and its family.

  • num_bit_corrections (int) – The number of bit corrections to allow when checking for a tag.

Returns:

A list of any tags that were found in this quad. Each tag is a list, with the form [tag_id, [corner points in image in correct order], [range and azimuth of corner points in order]].

Return type:

list[list]

actag.tag_decoding.decode_tags(binary_img: ndarray, quads: list[ndarray], sonar_params: SonarParams, tag_params: AcTagParams, num_bit_corrections: int) list[list]

For each quad in the image, try to decode it as an AcTag. Return a list of all of the decoded tags found in the image.

Parameters:
  • binary_img (np.ndarray) – The binary sonar image, output from the adaptive thresholding.

  • quads (list[np.ndarray]) – A list of quadrilaterals found in the image.

  • sonar_params (SonarParams) – The parameters of the sonar that took the image.

  • tag_params (AcTagParams) – The parameters of the AcTag and its family.

  • num_bit_corrections (int) – The number of bit corrections to perform when decoding the tag.

Returns:

A list of all of the decoded tags found in the image. Each tag is a list, with the form [tag_id, [corner points in image in correct order], [range and azimuth of corner points in order]].

Return type:

list[list]

actag.tag_decoding.get_data_bit_locations(quad: ndarray, tag_params: AcTagParams) ndarray

Get the tag data bit locations within the sonar image, by calculating the homography that maps the tag into the sonar image.

Parameters:
  • quad (np.ndarray) – The quadrilateral to use as the central white square of the AcTag.

  • tag_params (AcTagParams) – The parameters of the AcTag and its family.

Returns:

The locations of the data bits in the sonar image.

Return type:

np.ndarray

Rust Functions

actag.rust_impl.get_data_bit_locations()

Rust equivalent of actag.tag_decoding.get_data_bit_locations().

Parameters:
  • quad (Vec<(i64, i64)>) – The quadrilateral to use as the central white square of the AcTag.

  • data_bits (u64) – The number of data bits in the AcTag family.

Returns:

The locations of the data bits in the sonar image.

Return type:

Vec<(u64, u64)>

actag.rust_impl.check_quad_for_tag_python_wrap()

Rust equivalent of actag.tag_decoding.check_quad_for_tag(). Note that this function does not return the range and azimuth values of the tag corners, as the Python version does.

Parameters:
  • binary_img (Vec<Vec<i32>>) – The binarized sonar image to search for tags in.

  • corner_points (Vec<(i64, i64)>) – The corners of the quadrilateral.

  • data_bit_cords (Vec<(u64, u64)>) – The locations of the data bits for the potential tag in the sonar image.

  • tags_in_family (Vec<Vec<i32>>) – The data bits of all of the tags in the AcTag family, including rotations and reversals.

  • bit_corrections_allowed (u64) – The number of bit corrections to allow when checking for a tag.

Returns:

A vector of any tags that were found in this quad. Each tag is a vector, with the form [tag_id, pt1_row, pt1_col, pt2_row, pt2_col, pt3_row, pt3_col, pt4_row, pt4_col].

Return type:

Vec<Vec<u64>>

actag.rust_impl.decode_tags()

Rust equivalent of actag.tag_decoding.decode_tags().

Parameters:
  • binary_img (Vec<Vec<i32>>) – The binary sonar image.

  • quads (Vec<Vec<(i64, i64)>>) – A list of quadrilaterals found in the image.

  • min_range (f64) – The minimum range of the sonar.

  • max_range (f64) – The maximum range of the sonar.

  • horizontal_aperture (f64) – The horizontal aperture of the sonar in radians.

  • tag_family (String) – The name of the AcTag family.

  • tags_in_family (Vec<Vec<i32>>) – A list containing the data bit layouts for each tag in the family, including rotations and reversals.

  • bit_corrections_allowed (u64) – The number of bit corrections to perform when decoding the tag.

Returns:

A vector containing all of the decoded tags found in the image. Each tag is a vector, with the form [tag_id, pt1_row, pt1_col ... pt4_row, pt4_col, pt1_range, pt1_azi ... pt4_range, pt4_azi].

Return type:

Vec<Vec<i32>>

actag.rust_impl.convert_tag_detections_to_range_azi_locations()

Takes the newly detected tags and appends the range and azimuth information for each of the points.

Parameters:
  • detected_tags (Vec<Vec<u64>>) – A vector of the detected tags. Each tag is a vector, with the form [tag_id, pt1_row, pt1_col, pt2_row, pt2_col, pt3_row, pt3_col, pt4_row, pt4_col].

  • img_shape ((i64, i64)) – The shape of the image in (rows, cols) format.

  • min_range (f64) – The minimum range of the sonar.

  • max_range (f64) – The maximum range of the sonar.

  • horizontal_aperture (f64) – The horizontal aperture of the sonar in radians.

Returns:

A vector containing all of the decoded tags found in the image. Each tag is a vector, with the form [tag_id, pt1_row, pt1_col ... pt4_row, pt4_col, pt1_range, pt1_azi ... pt4_range, pt4_azi].

Return type:

Vec<Vec<f64>>