A tool for video timeline segmentation and annotation.
-vor--video_path: path to the video file or directory containing video files, required argument.-cor--class_cfg: path to the YAML file with event classes, required argument.-oor--output_dir: path to the directory for saving annotations; if not provided, annotations are saved in the same directory as the video being annotated.-sor--frames_skip: number of frames to skip during playback; if not provided, the default value of 1 is used.
python labeller.py -v data -c classes.ymlIn this example, the script will process all video files in the data directory, use event classes from classes.yml, and save annotations in the same directory as the source videos, skipping 10 frames during playback.
python labeller.py -v video.mp4 -c configs/classes.yml -o annotations -s 10In this example, the script will run with the video.mp4 file, use event classes from configs/classes.yml, and save annotations in the annotations directory, skipping 10 frames during playback.
Usage Instructions
- Run the
labeller.pyscript with the required parameters. - A video window with a timeline will appear. The script can be run on a single video or a directory of videos. In the latter case, the script will process each video sequentially.
- Use the following keys to navigate the video:
Space: start/stop playbackaor←Left Arrow: move one frame backwarddor→Right Arrow: move one frame forwardwor↑Up Arrow: move 10 frames backwardsor↓Down Arrow: move 10 frames forward
- Marking the start and end frames can be done in any order (e.g., [start, end] or [end, start]). Events can be annotated in two ways:
- Using text input for event id:
- Pause the video at the start/end frame of the event.
- Press
Enter. - Enter the event id.
- Confirm by pressing
Enteragain. - Pause the video at the end/start frame of the event (the second marker).
- Press
Enteragain.
- Using keyboard input for event class id (works with single-character ids):
- Pause the video at the start/end frame of the event.
- Press the key corresponding to the event id.
- Pause the video at the end/start frame of the event (the second marker).
- Press
Enter.
- Using text input for event id:
- To finish annotation and save the annotations, press the
\key. Annotations will be saved in the file within the directory specified by the-oparameter. - To cancel the video annotation, press
Esc.
System Requirements
- Python version 3.8 or higher
- Libraries opencv and yaml for Python
You can install the required libraries using:
pip install opencv-python pyyaml