A tool for video timeline segmentation and annotation.
-v
or--video_path
: path to the video file or directory containing video files, required argument.-c
or--class_cfg
: path to the YAML file with event classes, required argument.-o
or--output_dir
: path to the directory for saving annotations; if not provided, annotations are saved in the same directory as the video being annotated.-s
or--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.yml
In 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 10
In 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.py
script 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 playbacka
or←
Left Arrow: move one frame backwardd
or→
Right Arrow: move one frame forwardw
or↑
Up Arrow: move 10 frames backwards
or↓
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
Enter
again. - Pause the video at the end/start frame of the event (the second marker).
- Press
Enter
again.
- 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-o
parameter. - 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