diff --git a/docs/deprecated.md b/docs/deprecated.md index 994bd1477..f9636039f 100644 --- a/docs/deprecated.md +++ b/docs/deprecated.md @@ -12,4 +12,5 @@ These features are phased out due to better alternatives or potential issues in - `Color.green()` is deprecated and will be removed in `supervision-0.22.0`. Use `Color.GREEN` instead. - `Color.blue()` is deprecated and will be removed in `supervision-0.22.0`. Use `Color.BLUE` instead. - [`ColorPalette.default()`](draw/color.md/#supervision.draw.color.ColorPalette.default) is deprecated and will be removed in `supervision-0.22.0`. Use [`ColorPalette.DEFAULT`](draw/color.md/#supervision.draw.color.ColorPalette.DEFAULT) instead. -- `BoxAnnotator` is deprecated and will be removed in `supervision-0.22.0`. Use [`BoundingBoxAnnotator`](annotators.md/#supervision.annotators.core.BoundingBoxAnnotator) and [`LabelAnnotator`](annotators.md/#supervision.annotators.core.LabelAnnotator) instead. \ No newline at end of file +- `BoxAnnotator` is deprecated and will be removed in `supervision-0.22.0`. Use [`BoundingBoxAnnotator`](annotators.md/#supervision.annotators.core.BoundingBoxAnnotator) and [`LabelAnnotator`](annotators.md/#supervision.annotators.core.LabelAnnotator) instead. +- [`FPSMonitor.__call__`](utils/video.md/#supervision.utils.video.FPSMonitor.__call__) is deprecated and will be removed in `supervision-0.22.0`. Use [`FPSMonitor.fps`](utils/video.md/#supervision.utils.video.FPSMonitor.fps) instead. diff --git a/pyproject.toml b/pyproject.toml index 4d5f8bb50..f6557c87f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "supervision" -version = "0.18.0" +version = "0.19.0rc1" description = "A set of easy-to-use utils that will come in handy in any Computer Vision project" authors = ["Piotr Skalski "] maintainers = ["Piotr Skalski "] diff --git a/supervision/utils/video.py b/supervision/utils/video.py index 6be3bffe0..2c8eb23b5 100644 --- a/supervision/utils/video.py +++ b/supervision/utils/video.py @@ -8,6 +8,8 @@ import cv2 import numpy as np +from supervision.utils.internal import deprecated + @dataclass class VideoInfo: @@ -219,25 +221,43 @@ def __init__(self, sample_size: int = 30): ```python import supervision as sv - frames_generator = sv.get_video_frames_generator('source.mp4') + frames_generator = sv.get_video_frames_generator(source_path=) fps_monitor = sv.FPSMonitor() for frame in frames_generator: # your processing code here fps_monitor.tick() - fps = fps_monitor() + fps = fps_monitor.fps ``` - """ + """ # noqa: E501 // docs self.all_timestamps = deque(maxlen=sample_size) + @deprecated( + "`FPSMonitor.__call__` is deprecated and will be removed in " + "`supervision-0.22.0`. Use `FPSMonitor.fps` instead." + ) def __call__(self) -> float: """ + !!! failure "Deprecated" + + `FPSMonitor.__call__` is deprecated and will be removed in + `supervision-0.22.0`. Use `FPSMonitor.fps` instead. + Computes and returns the average FPS based on the stored time stamps. Returns: float: The average FPS. Returns 0.0 if no time stamps are stored. """ + return self.fps + @property + def fps(self) -> float: + """ + Computes and returns the average FPS based on the stored time stamps. + + Returns: + float: The average FPS. Returns 0.0 if no time stamps are stored. + """ if not self.all_timestamps: return 0.0 taken_time = self.all_timestamps[-1] - self.all_timestamps[0]