-
-
Notifications
You must be signed in to change notification settings - Fork 388
add Random Frame Extractor #464
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,57 @@ | ||||||
| import cv2 | ||||||
| import os | ||||||
| import random | ||||||
| import uuid | ||||||
| import argparse | ||||||
|
|
||||||
| def extract_random_frames(video_path, num_frames=15, output_folder="./datasets/images"): | ||||||
mhafizazh marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| # Create output directory if it doesn't exist | ||||||
| os.makedirs(output_folder, exist_ok=True) | ||||||
|
|
||||||
| # Load video | ||||||
| cap = cv2.VideoCapture(video_path) | ||||||
| if not cap.isOpened(): | ||||||
| print("Error: Could not open video.") | ||||||
|
||||||
| print("Error: Could not open video.") | |
| print(f"Error: Could not open video at path: {video_path}") |
Copilot
AI
Jul 21, 2025
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.
This condition should be save_idx > len(selected_frames) or removed entirely. The current logic could cause early termination when save_idx exceeds num_frames, but save_idx starts at 1 while num_frames represents the count.
| if save_idx > num_frames: | |
| if save_idx > len(selected_frames): |
Uh oh!
There was an error while loading. Please reload this page.