from_file#
- movement.io.load_bboxes.from_file(file_path, source_software, fps=None, use_frame_numbers_from_file=False, frame_regexp='(0\\\\d*)\\\\.\\\\w+$')[source]#
Create a
movement
bounding boxes dataset from a supported file.At the moment, we only support VIA-tracks .csv files.
- Parameters:
file_path (pathlib.Path or str) – Path to the file containing the tracked bounding boxes. Currently only VIA-tracks .csv files are supported.
source_software ("VIA-tracks".) – The source software of the file. Currently only files from the VIA 2.0.12 annotator [1] (“VIA-tracks”) are supported. See .
fps (float, optional) – The video sampling rate. If None (default), the
time
coordinates of the resultingmovement
dataset will be in frame numbers. Iffps
is provided, thetime
coordinates will be in seconds. If thetime
coordinates are in seconds, they will indicate the elapsed time from the capture of the first frame (assumed to be frame 0).use_frame_numbers_from_file (bool, optional) – If True, the frame numbers in the resulting dataset are the same as the ones specified for each tracked bounding box in the input file. This may be useful if the bounding boxes are tracked for a subset of frames in a video, but you want to maintain the start of the full video as the time origin. If False (default), the frame numbers in the VIA tracks .csv file are instead mapped to a 0-based sequence of consecutive integers.
frame_regexp (str, optional) – Regular expression pattern to extract the frame number from the frame filename. By default, the frame number is expected to be encoded in the filename as an integer number led by at least one zero, followed by the file extension. Only used if
use_frame_numbers_from_file
is True.
- Returns:
movement
dataset containing the position, shape, and confidence scores of the tracked bounding boxes, and any associated metadata.- Return type:
References
Examples
Create a dataset from the VIA tracks .csv file at “path/to/file.csv”, with the time coordinates in seconds, and assuming t = 0 seconds corresponds to the first tracked frame in the file.
>>> from movement.io import load_bboxes >>> ds = load_bboxes.from_file( >>> "path/to/file.csv", >>> source_software="VIA-tracks", >>> fps=30, >>> )