generated from roboflow/template-python
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Fix process_video and add test case
#2011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
83c3a05
Fix process_video and add test case
cdeil d91cf18
Simplify test_video.py temp file, itsa OK on Windows letsa hope
cdeil 0500549
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 7ef6772
Merge branch 'develop' into fix/process-video-max-frames-error
Borda cc7fe67
Rename `create_test_video` to `_create_test_video` in `test_video.py`…
Borda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import cv2 | ||
| import numpy as np | ||
|
|
||
| from supervision.utils.video import process_video | ||
|
|
||
|
|
||
| def _create_test_video(path, num_frames, width=20, height=10): | ||
| fourcc = cv2.VideoWriter_fourcc(*"mp4v") | ||
| out = cv2.VideoWriter(path, fourcc, 1.0, (width, height)) | ||
|
|
||
| for _ in range(num_frames): | ||
| frame = np.zeros((height, width, 3), dtype=np.uint8) | ||
| out.write(frame) | ||
|
|
||
| out.release() | ||
|
|
||
|
|
||
| def test_process_video_max_frames_exceeds_total_frames(tmp_path): | ||
| source_path = tmp_path / "source.mp4" | ||
| target_path = tmp_path / "target.mp4" | ||
|
|
||
| _create_test_video(str(source_path), num_frames=5) | ||
|
|
||
| process_video( | ||
| source_path=str(source_path), | ||
| target_path=str(target_path), | ||
| callback=lambda frame, _: frame, | ||
| max_frames=10, | ||
| ) | ||
|
Comment on lines
+24
to
+29
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any assertion or other validation, then it runs?