diff --git a/docs/detection/tools/line_zone.md b/docs/detection/tools/line_zone.md index 49961f0f..07070a26 100644 --- a/docs/detection/tools/line_zone.md +++ b/docs/detection/tools/line_zone.md @@ -2,6 +2,14 @@ comments: true --- -# LineZone +
+

LineZone

+
-:::supervision.detection.line_counter.LineZone +:::supervision.detection.line_zone.LineZone + +
+

LineZoneAnnotator

+
+ +:::supervision.detection.line_zone.LineZoneAnnotator \ No newline at end of file diff --git a/docs/detection/tools/polygon_zone.md b/docs/detection/tools/polygon_zone.md index b532451b..cbe76c20 100644 --- a/docs/detection/tools/polygon_zone.md +++ b/docs/detection/tools/polygon_zone.md @@ -2,7 +2,9 @@ comments: true --- -# PolygonZone +
+

PolygonZone

+
:::supervision.detection.tools.polygon_zone.PolygonZone diff --git a/docs/detection/tools/smoother.md b/docs/detection/tools/smoother.md index 1573617e..8076be13 100644 --- a/docs/detection/tools/smoother.md +++ b/docs/detection/tools/smoother.md @@ -1,6 +1,5 @@ --- comments: true -status: new --- # Detection Smoother diff --git a/supervision/__init__.py b/supervision/__init__.py index 96116283..693609c3 100644 --- a/supervision/__init__.py +++ b/supervision/__init__.py @@ -35,7 +35,7 @@ from supervision.dataset.core import ( ) from supervision.detection.annotate import BoxAnnotator from supervision.detection.core import Detections -from supervision.detection.line_counter import LineZone, LineZoneAnnotator +from supervision.detection.line_zone import LineZone, LineZoneAnnotator from supervision.detection.tools.csv_sink import CSVSink from supervision.detection.tools.inference_slicer import InferenceSlicer from supervision.detection.tools.polygon_zone import PolygonZone, PolygonZoneAnnotator diff --git a/supervision/detection/line_counter.py b/supervision/detection/line_zone.py similarity index 91% rename from supervision/detection/line_counter.py rename to supervision/detection/line_zone.py index 8f09f219..d8c6dbaa 100644 --- a/supervision/detection/line_counter.py +++ b/supervision/detection/line_zone.py @@ -14,6 +14,12 @@ class LineZone: This class is responsible for counting the number of objects that cross a predefined line. + + !!! warning LineZone uses the `tracker_id`. Read @@ -25,7 +31,28 @@ class LineZone: to inside. out_count (int): The number of objects that have crossed the line from inside to outside. - """ + + Example: + ```python + import supervision as sv + from ultralytics import YOLO + + model = YOLO() + tracker = sv.ByteTrack() + frames_generator = sv.get_video_frames_generator() + start, end = sv.Point(x=0, y=1080), sv.Point(x=3840, y=1080) + line_zone = sv.LineZone(start=start, end=end) + + for frame in frames_generator: + result = model(frame)[0] + detections = sv.Detections.from_ultralytics(result) + detections = tracker.update_with_detections(detections) + crossed_in, crossed_out = line_zone.trigger(detections) + + line_zone.in_count, line_zone.out_count + # 7, 2 + ``` + """ # noqa: E501 // docs def __init__( self, diff --git a/supervision/utils/video.py b/supervision/utils/video.py index 2c8eb23b..2314a7e2 100644 --- a/supervision/utils/video.py +++ b/supervision/utils/video.py @@ -28,7 +28,7 @@ class VideoInfo: ```python import supervision as sv - video_info = sv.VideoInfo.from_video_path(video_path='video.mp4') + video_info = sv.VideoInfo.from_video_path(video_path=) video_info # VideoInfo(width=3840, height=2160, fps=25, total_frames=538) @@ -75,14 +75,14 @@ class VideoSink: ```python import supervision as sv - video_info = sv.VideoInfo.from_video_path('source.mp4') - frames_generator = sv.get_video_frames_generator('source.mp4') + video_info = sv.VideoInfo.from_video_path() + frames_generator = sv.get_video_frames_generator() - with sv.VideoSink(target_path='target.mp4', video_info=video_info) as sink: + with sv.VideoSink(target_path=, video_info=video_info) as sink: for frame in frames_generator: sink.write_frame(frame=frame) ``` - """ + """ # noqa: E501 // docs def __init__(self, target_path: str, video_info: VideoInfo, codec: str = "mp4v"): self.target_path = target_path @@ -147,7 +147,7 @@ def get_video_frames_generator( ```python import supervision as sv - for frame in sv.get_video_frames_generator(source_path='source_video.mp4'): + for frame in sv.get_video_frames_generator(source_path=): ... ``` """ @@ -191,8 +191,8 @@ def process_video( ... process_video( - source_path='...', - target_path='...', + source_path=, + target_path=, callback=callback ) ```