From 173719020e016b904218c898270cd070cb266d01 Mon Sep 17 00:00:00 2001 From: SkalskiP Date: Wed, 31 Jan 2024 18:01:42 +0100 Subject: [PATCH 1/4] ready for tests --- supervision/utils/video.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/supervision/utils/video.py b/supervision/utils/video.py index 6be3bffe0..49e25de71 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,17 +221,21 @@ 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.21.0`. Use `FPSMonitor.fps` instead." + ) def __call__(self) -> float: """ Computes and returns the average FPS based on the stored time stamps. @@ -237,7 +243,16 @@ def __call__(self) -> float: 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] From b6ddd21cdb70cf480df102fd735d4388c6807029 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 31 Jan 2024 21:18:42 +0000 Subject: [PATCH 2/4] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto=20?= =?UTF-8?q?format=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/deprecated.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/deprecated.md b/docs/deprecated.md index 994bd1477..b91e14a68 100644 --- a/docs/deprecated.md +++ b/docs/deprecated.md @@ -12,4 +12,4 @@ 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. From da8cc0cbaab4d5ad2fffc828f9659e196da035fd Mon Sep 17 00:00:00 2001 From: SkalskiP Date: Wed, 31 Jan 2024 22:24:17 +0100 Subject: [PATCH 3/4] documentation updated --- docs/deprecated.md | 1 + pyproject.toml | 2 +- supervision/utils/video.py | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/deprecated.md b/docs/deprecated.md index b91e14a68..ac60ea377 100644 --- a/docs/deprecated.md +++ b/docs/deprecated.md @@ -13,3 +13,4 @@ These features are phased out due to better alternatives or potential issues in - `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. +- [`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. \ No newline at end of file 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 49e25de71..2c8eb23b5 100644 --- a/supervision/utils/video.py +++ b/supervision/utils/video.py @@ -234,10 +234,15 @@ def __init__(self, sample_size: int = 30): @deprecated( "`FPSMonitor.__call__` is deprecated and will be removed in " - "`supervision-0.21.0`. Use `FPSMonitor.fps` instead." + "`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: From 2280de707b308cc070ee94afe414145f7a4702be Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 31 Jan 2024 21:27:14 +0000 Subject: [PATCH 4/4] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto=20?= =?UTF-8?q?format=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/deprecated.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/deprecated.md b/docs/deprecated.md index ac60ea377..f9636039f 100644 --- a/docs/deprecated.md +++ b/docs/deprecated.md @@ -13,4 +13,4 @@ These features are phased out due to better alternatives or potential issues in - `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. -- [`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. \ No newline at end of file +- [`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.