tlc.core.export.annotation_utils¶

Common utilities for annotation detection in exporters.

Module Contents¶

Classes¶

Class

Description

AnnotationType

Enumeration of supported annotation types for export.

Functions¶

Function

Description

detect_annotation_type

Detect the annotation type and column name for a table.

detect_bounding_box_column

Check if the table has a bounding box column.

detect_keypoints_column

Check if the table has a keypoints column.

detect_obb_column

Check if the table has an oriented bounding box column.

detect_segmentation_column

Check if the table has a segmentation column.

API¶

class AnnotationType¶

Bases: enum.Enum

Enumeration of supported annotation types for export.

BOUNDING_BOXES = bounding_boxes¶
KEYPOINTS = keypoints¶
ORIENTED_BOUNDING_BOXES = oriented_bounding_boxes¶
SEGMENTATION = segmentation¶
detect_annotation_type(
table: Table,
annotation_column_name: str | None = None,
) tuple[AnnotationType, str]¶

Detect the annotation type and column name for a table.

If annotation_column_name is provided, it validates that column and returns its type. Otherwise, it auto-detects the annotation type by checking columns in order: bounding boxes, segmentation, keypoints, oriented bounding boxes.

Parameters:
  • table – The table to analyze.

  • annotation_column_name – Optional specific column name to use.

Returns:

A tuple of (annotation_type, column_name).

Raises:

ValueError – If no compatible annotation column is found.

detect_bounding_box_column(
table: Table,
) tuple[bool, str | None]¶

Check if the table has a bounding box column.

Parameters:

table – The table to check.

Returns:

A tuple of (is_bb_table, column_name).

detect_keypoints_column(
table: Table,
) tuple[bool, str | None]¶

Check if the table has a keypoints column.

Keypoints columns have INSTANCES with VERTICES_2D (2D points) and bounds (X_MAX, Y_MAX).

Parameters:

table – The table to check.

Returns:

A tuple of (is_keypoints_table, column_name).

detect_obb_column(
table: Table,
) tuple[bool, str | None]¶

Check if the table has an oriented bounding box column.

OBB columns have INSTANCES with ORIENTED_BBS_2D.

Parameters:

table – The table to check.

Returns:

A tuple of (is_obb_table, column_name).

detect_segmentation_column(
table: Table,
) tuple[bool, str | None]¶

Check if the table has a segmentation column.

Parameters:

table – The table to check.

Returns:

A tuple of (is_seg_table, column_name).