> ## Documentation Index
> Fetch the complete documentation index at: https://docs.datamarkin.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Detections

> Core Detection Data Structures for Computer Vision Processing.

Provides unified data structures for representing detection results from various computer vision frameworks, including bounding boxes, masks, keypoints, and tracking information. Designed for efficient processing and seamless integration across different ML frameworks and visualization tools.

## Classes

* [`KeyPoint`](#keypoint) - Represents a single keypoint with coordinate and visibility information for pose estimation.
* [`Detection`](#detection) - Unified representation of a single object detection with comprehensive metadata and tracking.
* [`Detections`](#detections) - Container for multiple Detection objects with comprehensive filtering and processing capabilities.

## KeyPoint

Represents a single keypoint with coordinate and visibility information for pose estimation.

Stores spatial coordinates and visibility state for structured keypoint data representation in pose estimation and object keypoint detection tasks. Provides a standardized format for keypoint data across different ML frameworks and coordinate systems.

### Parameters

**x** `int` *required*

X coordinate in pixels from image left edge.

**y** `int` *required*

Y coordinate in pixels from image top edge.

**name** `str` *required*

Descriptive name or label for the keypoint (e.g., "nose", "left\_eye").

**visibility** `bool` *required*

Whether the keypoint is visible and detectable in the image.

### Example

```python Example theme={null}
import pixelflow as pf

# Create a keypoint for pose estimation
nose_point = pf.detections.KeyPoint(x=320, y=240, name="nose", visibility=True)
print(f"Nose at ({nose_point.x}, {nose_point.y})")

# Create keypoint with occlusion
hidden_point = pf.detections.KeyPoint(x=150, y=200, name="left_elbow", visibility=False)

# Use in detection workflow
keypoints = [nose_point, hidden_point]
detection = pf.detections.Detection(keypoints=keypoints, class_name="person")

```

## Detection

Unified representation of a single object detection with comprehensive metadata and tracking.

Stores complete detection information including bounding boxes, segmentation masks, keypoints, classification data, tracking information, and spatial analytics. Provides a standardized interface for detection data across different ML frameworks with automatic validation and type conversion for consistent data handling.

### Parameters

**inference\_id** `Optional[str]`

Unique identifier for the inference session or batch.

**bbox** `Optional[List[float]]`

Bounding box coordinates in XYXY format \[x1, y1, x2, y2]. Automatically validated and normalized.

**masks** `Optional[List[Any]]`

Segmentation masks in various formats (binary arrays, polygons).

**segments** `Optional[List[Any]]`

Polygon segments for precise object boundaries.

**keypoints** `Optional[List[KeyPoint]]`

List of KeyPoint objects for pose/structure data.

**class\_id** `Optional[Union[int, str]]`

Numeric or string class identifier from model.

**class\_name** `Optional[str]`

Human-readable class name (e.g., "person", "vehicle").

**labels** `Optional[List[str]]`

Additional classification labels or attributes.

**confidence** `Optional[float]`

Detection confidence score \[0.0-1.0], automatically rounded to 4 decimal places for consistency.

**tracker\_id** `Optional[int]`

Unique tracking identifier for multi-frame object tracking.

**data** `Optional[Dict[str, Any]]`

Additional custom metadata and framework-specific data.

**zones** `Optional[List[str]]`

List of zone identifiers the detection intersects. Defaults to empty list if None.

**zone\_names** `Optional[List[str]]`

Human-readable names for intersected zones. Defaults to empty list if None.

**line\_crossings** `Optional[List[Dict]]`

Line crossing events for this detection. Defaults to empty list if None.

**first\_seen\_time** `Optional[float]`

Timestamp when detection first appeared (Unix time).

**total\_time** `float` *required*

Total duration since first detection in seconds. Default is 0.0.

### Example

```python Example theme={null}
import pixelflow as pf
from ultralytics import YOLO
import cv2

# Basic detection from ML framework
image = cv2.imread("image.jpg")
model = YOLO("yolo11n.pt")
outputs = model.predict(image)
results = pf.detections.from_ultralytics(outputs)

# Create basic detection with bounding box
detection = pf.detections.Detection(
```

## Detections

Container for multiple Detection objects with comprehensive filtering and processing capabilities.

Provides a unified interface for managing collections of detections with support for iteration, indexing, filtering, zone management, serialization, and bulk operations. Implements standard Python container protocols and includes dynamically attached filter methods for zero-overhead detection processing and analysis workflows.

### Example

```python Example theme={null}
import pixelflow as pf
from ultralytics import YOLO
import cv2

# Create detections from ML framework
image = cv2.imread("image.jpg")
model = YOLO("yolo11n.pt")
outputs = model.predict(image)
detections = pf.detections.from_ultralytics(outputs)

# Manual creation and management
detections = pf.detections.Detections()
detection1 = pf.detections.Detection(bbox=[100, 50, 200, 150], class_name="person")
detection2 = pf.detections.Detection(bbox=[300, 100, 400, 200], class_name="car")
detections.add_detection(detection1)
detections.add_detection(detection2)

# Container operations
print(f"Found {len(detections)} objects")
for detection in detections:
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.