diff --git a/docs/index.md b/docs/index.md index 7f2e25ad..5f838eb8 100644 --- a/docs/index.md +++ b/docs/index.md @@ -34,7 +34,7 @@ We write your reusable computer vision tools. Whether you need to load your data Annotate predictions from a range of object detection and segmentation models - [:octicons-arrow-right-24: Tutorial](how_to/detect_and_annotate) + [:octicons-arrow-right-24: Tutorial](how_to/detect_and_annotate.md) - __Track Objects__ @@ -42,7 +42,7 @@ We write your reusable computer vision tools. Whether you need to load your data Discover how to enhance video analysis by implementing seamless object tracking - [:octicons-arrow-right-24: Tutorial](how_to/track_objects) + [:octicons-arrow-right-24: Tutorial](how_to/track_objects.md) - > __Count Objects Crossing Line__ diff --git a/supervision/detection/core.py b/supervision/detection/core.py index 62ed8869..a1432182 100644 --- a/supervision/detection/core.py +++ b/supervision/detection/core.py @@ -25,7 +25,34 @@ from supervision.utils.internal import deprecated @dataclass class Detections: """ - A dataclass representing detection results. + The `sv.Detections` allows you to convert results from a variety of object detection + and segmentation models into a single, unified format. The `sv.Detections` class + enables easy data manipulation and filtering, and provides a consistent API for + Supervision's tools like trackers, annotators, and zones. + + ```python + import cv2 + import supervision as sv + from ultralytics import YOLO + + image = cv2.imread() + model = YOLO('yolov8s.pt') + annotator = sv.BoundingBoxAnnotator() + + result = model(image)[0] + detections = sv.Detections.from_ultralytics(result) + + annotated_image = annotator.annotate(image, detections) + ``` + + !!! tip + + In `sv.Detections`, detection data is categorized into two main field types: + fixed and custom. The fixed fields include `xyxy`, `mask`, `confidence`, + `class_id`, and `tracker_id`. For any additional data requirements, custom + fields come into play, stored in the data field. These custom fields are easily + accessible using the `detections[]` syntax, providing flexibility + for diverse data handling needs. Attributes: xyxy (np.ndarray): An array of shape `(n, 4)` containing