From cc7de0edb776a2293c8ad2f18535fd57eb9d4202 Mon Sep 17 00:00:00 2001 From: LinasKo Date: Mon, 26 Aug 2024 14:40:43 +0300 Subject: [PATCH 1/2] rename manual_seek to iterative_seek --- supervision/utils/video.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/supervision/utils/video.py b/supervision/utils/video.py index 51462c803..1a290bbe9 100644 --- a/supervision/utils/video.py +++ b/supervision/utils/video.py @@ -117,7 +117,7 @@ def __exit__(self, exc_type, exc_value, exc_traceback): def _validate_and_setup_video( - source_path: str, start: int, end: Optional[int], manual_seek: bool = False + source_path: str, start: int, end: Optional[int], iterative_seek: bool = False ): video = cv2.VideoCapture(source_path) if not video.isOpened(): @@ -128,7 +128,7 @@ def _validate_and_setup_video( start = max(start, 0) end = min(end, total_frames) if end is not None else total_frames - if manual_seek: + if iterative_seek: while start > 0: success = video.grab() if not success: @@ -145,7 +145,7 @@ def get_video_frames_generator( stride: int = 1, start: int = 0, end: Optional[int] = None, - manual_seek: bool = False, + iterative_seek: bool = False, ) -> Generator[np.ndarray, None, None]: """ Get a generator that yields the frames of the video. @@ -158,7 +158,7 @@ def get_video_frames_generator( video should generate frames end (Optional[int]): Indicates the ending position at which video should stop generating frames. If None, video will be read to the end. - manual_seek (bool): If True, the generator will manually seek to the + iterative_seek (bool): If True, the generator will seek to the `start` frame by grabbing each frame, which is much slower. This is a workaround for videos that don't open at all when you set the `start` value. @@ -174,7 +174,7 @@ def get_video_frames_generator( ... ``` """ - video, start, end = _validate_and_setup_video(source_path, start, end, manual_seek) + video, start, end = _validate_and_setup_video(source_path, start, end, iterative_seek) frame_position = start while True: success, frame = video.read() From 7e9dca632b16ade85426fe7a442d443b146920bd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 26 Aug 2024 11:41:59 +0000 Subject: [PATCH 2/2] =?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 --- supervision/utils/video.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/supervision/utils/video.py b/supervision/utils/video.py index 1a290bbe9..455ca21c7 100644 --- a/supervision/utils/video.py +++ b/supervision/utils/video.py @@ -174,7 +174,9 @@ def get_video_frames_generator( ... ``` """ - video, start, end = _validate_and_setup_video(source_path, start, end, iterative_seek) + video, start, end = _validate_and_setup_video( + source_path, start, end, iterative_seek + ) frame_position = start while True: success, frame = video.read()