397 lines
9.6 KiB
Markdown
397 lines
9.6 KiB
Markdown
=== "BoundingBox"
|
|
|
|
```python
|
|
>>> import supervision as sv
|
|
|
|
>>> image = ...
|
|
>>> detections = sv.Detections(...)
|
|
|
|
>>> bounding_box_annotator = sv.BoundingBoxAnnotator()
|
|
>>> annotated_frame = bounding_box_annotator.annotate(
|
|
... scene=image.copy(),
|
|
... detections=detections
|
|
... )
|
|
```
|
|
|
|
<div class="result" markdown>
|
|
|
|
{ align=center width="800" }
|
|
|
|
</div>
|
|
|
|
=== "BoxCorner"
|
|
|
|
```python
|
|
>>> import supervision as sv
|
|
|
|
>>> image = ...
|
|
>>> detections = sv.Detections(...)
|
|
|
|
>>> corner_annotator = sv.BoxCornerAnnotator()
|
|
>>> annotated_frame = corner_annotator.annotate(
|
|
... scene=image.copy(),
|
|
... detections=detections
|
|
... )
|
|
```
|
|
|
|
<div class="result" markdown>
|
|
|
|
{ align=center width="800" }
|
|
|
|
</div>
|
|
|
|
=== "Color"
|
|
|
|
```python
|
|
>>> import supervision as sv
|
|
|
|
>>> image = ...
|
|
>>> detections = sv.Detections(...)
|
|
|
|
>>> color_annotator = sv.ColorAnnotator()
|
|
>>> annotated_frame = color_annotator.annotate(
|
|
... scene=image.copy(),
|
|
... detections=detections
|
|
... )
|
|
```
|
|
|
|
<div class="result" markdown>
|
|
|
|
{ align=center width="800" }
|
|
|
|
</div>
|
|
|
|
=== "Circle"
|
|
|
|
```python
|
|
>>> import supervision as sv
|
|
|
|
>>> image = ...
|
|
>>> detections = sv.Detections(...)
|
|
|
|
>>> circle_annotator = sv.CircleAnnotator()
|
|
>>> annotated_frame = circle_annotator.annotate(
|
|
... scene=image.copy(),
|
|
... detections=detections
|
|
... )
|
|
```
|
|
|
|
<div class="result" markdown>
|
|
|
|
{ align=center width="800" }
|
|
|
|
</div>
|
|
|
|
=== "Dot"
|
|
|
|
```python
|
|
>>> import supervision as sv
|
|
|
|
>>> image = ...
|
|
>>> detections = sv.Detections(...)
|
|
|
|
>>> dot_annotator = sv.DotAnnotator()
|
|
>>> annotated_frame = dot_annotator.annotate(
|
|
... scene=image.copy(),
|
|
... detections=detections
|
|
... )
|
|
```
|
|
|
|
<div class="result" markdown>
|
|
|
|
{ align=center width="800" }
|
|
|
|
</div>
|
|
|
|
=== "Triangle"
|
|
|
|
```python
|
|
>>> import supervision as sv
|
|
|
|
>>> image = ...
|
|
>>> detections = sv.Detections(...)
|
|
|
|
>>> triangle_annotator = sv.TriangleAnnotator()
|
|
>>> annotated_frame = triangle_annotator.annotate(
|
|
... scene=image.copy(),
|
|
... detections=detections
|
|
... )
|
|
```
|
|
|
|
<div class="result" markdown>
|
|
|
|
{ align=center width="800" }
|
|
|
|
</div>
|
|
|
|
=== "Ellipse"
|
|
|
|
```python
|
|
>>> import supervision as sv
|
|
|
|
>>> image = ...
|
|
>>> detections = sv.Detections(...)
|
|
|
|
>>> ellipse_annotator = sv.EllipseAnnotator()
|
|
>>> annotated_frame = ellipse_annotator.annotate(
|
|
... scene=image.copy(),
|
|
... detections=detections
|
|
... )
|
|
```
|
|
|
|
<div class="result" markdown>
|
|
|
|
{ align=center width="800" }
|
|
|
|
</div>
|
|
|
|
=== "Halo"
|
|
|
|
```python
|
|
>>> import supervision as sv
|
|
|
|
>>> image = ...
|
|
>>> detections = sv.Detections(...)
|
|
|
|
>>> halo_annotator = sv.HaloAnnotator()
|
|
>>> annotated_frame = halo_annotator.annotate(
|
|
... scene=image.copy(),
|
|
... detections=detections
|
|
... )
|
|
```
|
|
|
|
<div class="result" markdown>
|
|
|
|
{ align=center width="800" }
|
|
|
|
</div>
|
|
|
|
=== "Mask"
|
|
|
|
```python
|
|
>>> import supervision as sv
|
|
|
|
>>> image = ...
|
|
>>> detections = sv.Detections(...)
|
|
|
|
>>> mask_annotator = sv.MaskAnnotator()
|
|
>>> annotated_frame = mask_annotator.annotate(
|
|
... scene=image.copy(),
|
|
... detections=detections
|
|
... )
|
|
```
|
|
|
|
<div class="result" markdown>
|
|
|
|
{ align=center width="800" }
|
|
|
|
</div>
|
|
|
|
=== "Polygon"
|
|
|
|
```python
|
|
>>> import supervision as sv
|
|
|
|
>>> image = ...
|
|
>>> detections = sv.Detections(...)
|
|
|
|
>>> polygon_annotator = sv.PolygonAnnotator()
|
|
>>> annotated_frame = polygon_annotator.annotate(
|
|
... scene=image.copy(),
|
|
... detections=detections
|
|
... )
|
|
```
|
|
|
|
<div class="result" markdown>
|
|
|
|
{ align=center width="800" }
|
|
|
|
</div>
|
|
|
|
=== "Label"
|
|
|
|
```python
|
|
>>> import supervision as sv
|
|
|
|
>>> image = ...
|
|
>>> detections = sv.Detections(...)
|
|
|
|
>>> label_annotator = sv.LabelAnnotator(text_position=sv.Position.CENTER)
|
|
>>> annotated_frame = label_annotator.annotate(
|
|
... scene=image.copy(),
|
|
... detections=detections
|
|
... )
|
|
```
|
|
|
|
<div class="result" markdown>
|
|
|
|
{ align=center width="800" }
|
|
|
|
</div>
|
|
|
|
=== "Blur"
|
|
|
|
```python
|
|
>>> import supervision as sv
|
|
|
|
>>> image = ...
|
|
>>> detections = sv.Detections(...)
|
|
|
|
>>> blur_annotator = sv.BlurAnnotator()
|
|
>>> annotated_frame = blur_annotator.annotate(
|
|
... scene=image.copy(),
|
|
... detections=detections
|
|
... )
|
|
```
|
|
|
|
<div class="result" markdown>
|
|
|
|
{ align=center width="800" }
|
|
|
|
</div>
|
|
|
|
=== "Pixelate"
|
|
|
|
```python
|
|
>>> import supervision as sv
|
|
|
|
>>> image = ...
|
|
>>> detections = sv.Detections(...)
|
|
|
|
>>> pixelate_annotator = sv.PixelateAnnotator()
|
|
>>> annotated_frame = pixelate_annotator.annotate(
|
|
... scene=image.copy(),
|
|
... detections=detections
|
|
... )
|
|
```
|
|
|
|
<div class="result" markdown>
|
|
|
|
{ align=center width="800" }
|
|
|
|
</div>
|
|
|
|
=== "Trace"
|
|
|
|
```python
|
|
>>> import supervision as sv
|
|
>>> from ultralytics import YOLO
|
|
|
|
>>> model = YOLO('yolov8x.pt')
|
|
|
|
>>> trace_annotator = sv.TraceAnnotator()
|
|
|
|
>>> video_info = sv.VideoInfo.from_video_path(video_path='...')
|
|
>>> frames_generator = get_video_frames_generator(source_path='...')
|
|
>>> tracker = sv.ByteTrack()
|
|
|
|
>>> with sv.VideoSink(target_path='...', video_info=video_info) as sink:
|
|
... for frame in frames_generator:
|
|
... result = model(frame)[0]
|
|
... detections = sv.Detections.from_ultralytics(result)
|
|
... detections = tracker.update_with_detections(detections)
|
|
... annotated_frame = trace_annotator.annotate(
|
|
... scene=frame.copy(),
|
|
... detections=detections)
|
|
... sink.write_frame(frame=annotated_frame)
|
|
```
|
|
|
|
<div class="result" markdown>
|
|
|
|
{ align=center width="800" }
|
|
|
|
</div>
|
|
|
|
=== "HeatMap"
|
|
|
|
```python
|
|
>>> import supervision as sv
|
|
>>> from ultralytics import YOLO
|
|
|
|
>>> model = YOLO('yolov8x.pt')
|
|
|
|
>>> heat_map_annotator = sv.HeatMapAnnotator()
|
|
|
|
>>> video_info = sv.VideoInfo.from_video_path(video_path='...')
|
|
>>> frames_generator = get_video_frames_generator(source_path='...')
|
|
|
|
>>> with sv.VideoSink(target_path='...', video_info=video_info) as sink:
|
|
... for frame in frames_generator:
|
|
... result = model(frame)[0]
|
|
... detections = sv.Detections.from_ultralytics(result)
|
|
... annotated_frame = heat_map_annotator.annotate(
|
|
... scene=frame.copy(),
|
|
... detections=detections)
|
|
... sink.write_frame(frame=annotated_frame)
|
|
```
|
|
|
|
<div class="result" markdown>
|
|
|
|
{ align=center width="800" }
|
|
|
|
</div>
|
|
|
|
## BoundingBoxAnnotator
|
|
|
|
:::supervision.annotators.core.BoundingBoxAnnotator
|
|
|
|
## BoxCornerAnnotator
|
|
|
|
:::supervision.annotators.core.BoxCornerAnnotator
|
|
|
|
## ColorAnnotator
|
|
|
|
:::supervision.annotators.core.ColorAnnotator
|
|
|
|
## CircleAnnotator
|
|
|
|
:::supervision.annotators.core.CircleAnnotator
|
|
|
|
## DotAnnotator
|
|
|
|
:::supervision.annotators.core.DotAnnotator
|
|
|
|
## TriangleAnnotator
|
|
|
|
:::supervision.annotators.core.TriangleAnnotator
|
|
|
|
## EllipseAnnotator
|
|
|
|
:::supervision.annotators.core.EllipseAnnotator
|
|
|
|
## HaloAnnotator
|
|
|
|
:::supervision.annotators.core.HaloAnnotator
|
|
|
|
## HeatMapAnnotator
|
|
|
|
:::supervision.annotators.core.HeatMapAnnotator
|
|
|
|
## MaskAnnotator
|
|
|
|
:::supervision.annotators.core.MaskAnnotator
|
|
|
|
## PolygonAnnotator
|
|
|
|
:::supervision.annotators.core.PolygonAnnotator
|
|
|
|
## LabelAnnotator
|
|
|
|
:::supervision.annotators.core.LabelAnnotator
|
|
|
|
## BlurAnnotator
|
|
|
|
:::supervision.annotators.core.BlurAnnotator
|
|
|
|
## PixelateAnnotator
|
|
|
|
:::supervision.annotators.core.PixelateAnnotator
|
|
|
|
## TraceAnnotator
|
|
|
|
:::supervision.annotators.core.TraceAnnotator
|
|
|
|
## ColorLookup
|
|
|
|
:::supervision.annotators.utils.ColorLookup
|