ObjectDetectionAnnotation
Represents a single COCO-style object-detection or instance-segmentation annotation for one object. Required fields are id, image_id, and category_id; optional fields include segmentation, bbox, area, iscrowd, and score. This datatype is used as the schema for each element in ObjectDetectionAnnotations within the Telekinesis ecosystem.
Field
Required
| Field | Type | Description |
|---|---|---|
id | int | Annotation identifier (int). |
image_id | int | Image identifier (int). |
category_id | int | Category identifier (int). |
Optional
| Field | Type | Description |
|---|---|---|
segmentation | list[list[float]], list[np.ndarray], or dict | Polygons (list of polygons) or RLE dict with counts and size. Default []. |
bbox | list[int] or np.ndarray | Bounding box [x, y, width, height]; length 4. Default [0, 0, 0, 0]. |
area | float | Area of the segment. Default 0.0. |
iscrowd | int | Whether the annotation is a crowd region. Default 0. |
score | float or None | Detection or confidence score. Default None. |
Methods
| Method | Description |
|---|---|
to_dict() | Returns a dictionary with keys: id, image_id, category_id, segmentation, bbox, area, iscrowd, score. |
Example
From the datatypes examples:
python
from datatypes import datatypes
from loguru import logger
# ------------------------------------------------
# 1. Create ObjectDetectionAnnotation instance
# ------------------------------------------------
ann = datatypes.ObjectDetectionAnnotation(
id=1,
image_id=0,
category_id=1,
segmentation=[[10.0, 10.0, 50.0, 10.0, 50.0, 50.0, 10.0, 50.0]],
bbox=[10, 10, 40, 40],
area=1600.0,
iscrowd=0,
)
# ------------------------------------------------
# 2. Access data via to_dict
# ------------------------------------------------
d = ann.to_dict()
logger.info("ObjectDetectionAnnotation id={}", d["id"])
logger.info("ObjectDetectionAnnotation image_id={}", d["image_id"])
logger.info("ObjectDetectionAnnotation category_id={}", d["category_id"])
logger.info("ObjectDetectionAnnotation bbox={}", d["bbox"])
logger.info("ObjectDetectionAnnotation area={}", d["area"])
logger.info("ObjectDetectionAnnotation score={}", d.get("score"))
