A simple GUI tool for extracting frames from video files using OpenCV and Tkinter.
- Drag and drop video files or folders for easy selection.
- Supports custom sample rates for frame extraction (frames per second).
- Option to rotate frames (90° clockwise or counterclockwise).
- Adjustable JPEG compression for output frames.
- Batch processing for multiple videos in a folder.
- Python 3.6+
- Libraries:
tkinter,cv2(OpenCV),tkinterdnd2
- Install required libraries:
pip install opencv-python tkinterdnd2
- Place the script in your desired directory.
- Run the script:
python video_frame_extractor.py
- Use the GUI to:
- Select a Video File: Click the "Select Video File" button or drag a video file to the designated area.
- Select a Folder for Batch Processing: Click "Select Folder for Batch Processing" or drag a folder to the designated area.
- Set Parameters:
- Enter the desired sample rate (frames per second).
- Choose a rotation option (No Rotation, Rotate Left 90°, or Rotate Right 90°).
- Adjust the compression level using the slider.
- Click Process Video to process a single file or Batch Process Folder to process all videos in the selected folder.
- Extracted frames are saved in an
outputfolder within the selected folder (for batch processing) or in a new folder named<video_name>_framesnext to the video file.
- Supported video formats include
.mp4,.avi,.mkv,.mov,.flv,.wmv,.mpeg,.mpg, and.3gp. - Compression level ranges from 0 (lowest quality) to 100 (highest quality). The default value is 90.
- The default directory for file dialogs can be changed by modifying the
default_dirvariable in the script.
This tool provides an easy-to-use graphical interface to manage annotated datasets. It includes two main functionalities:
- Split Dataset: Splits a dataset into training, validation, and test sets.
- Merge Dataset: Merges training, validation, and test datasets into a single dataset.
- Splits a dataset into
train,valid, andtestsubsets based on user-defined ratios. - Handles missing labels:
- If an image exists without a corresponding label file, it is still included (assumes no objects are annotated in the image).
- If a label file exists without a corresponding image, the label file is removed, and a notification is printed in the console.
- Organizes the output into a structured format:
├── train │ ├── images │ └── labels ├── valid │ ├── images │ └── labels └── test ├── images └── labels
- Merges separate
train,valid, andtestdatasets into a unified dataset containingimagesandlabels. - Names the merged dataset folder as
merged_<date>(e.g.,merged_2024-11-19).
- Python 3.6+
- Libraries:
tkinterosshutilrandomdatetime
- Install Python 3.6+ if not already installed.
- Save the script as
dataset_tool.py.
Run the script:
python dataset_tool.py- Select Source Folder:
- Choose a folder containing two subfolders:
imagesandlabels.
- Choose a folder containing two subfolders:
- Select Output Folder:
- Choose where the split dataset will be saved.
- Set Ratios:
- Define the
trainandvalidratios (e.g., 0.7 and 0.2). Thetestratio is calculated automatically.
- Define the
- Click Split Dataset.
Output Structure:
- The tool creates three folders:
train,valid, andtest. - Each folder contains
imagesandlabels.
Handling Missing Data:
- Images without labels are included.
- Labels without corresponding images are removed, and their filenames are logged in the console.
- Select
train,valid, andtestFolders:- Choose the folders containing the datasets to merge.
- Select Root Directory:
- Choose a root directory to save the merged dataset.
- The merged dataset is saved in a folder named
merged_<date>inside the selected root directory.
Output Structure:
merged_<date>
├── images
└── labels
- The tool assumes
.jpgimages for label matching. Modify the script if other formats (e.g.,.png) are used. - The
labelsshould be.txtfiles with the same names as their corresponding images.