from_via_tracks_file#
- movement.io.load_bboxes.from_via_tracks_file(file, fps=None, use_frame_numbers_from_file=False, frame_regexp='(0\\d*)\\.\\w+$')[source]#
Create a
movementdataset from a VIA tracks .csv file.- Parameters:
file (
str|Path) – Path to the VIA tracks .csv file with the tracked bounding boxes. For more information on the VIA tracks .csv file format, see the VIA tutorial for tracking [1].fps (
float|None) – The video sampling rate. If None (default), thetimecoordinates of the resultingmovementdataset will be in frame numbers. Iffpsis provided, thetimecoordinates will be in seconds, i.e. frame numbers divided byfps. Seeuse_frame_numbers_from_filefor which frame is taken as the time origin.use_frame_numbers_from_file (
bool) – If False (default), frame numbers are offset so that the first tracked frame in the file becomes frame 0 in the dataset. If True, frame numbers in the dataset are as specified in the file (in thefile_attributescolumn or in the frame filenames, seeframe_regexp). A True value may be useful if only a subset of the video’s frames were tracked, but you want to keep the start of the video as the time origin of the dataset. In all cases, the spacing between tracked frames is preserved: frames[5, 6, 9]in the file become[0, 1, 4]in the dataset by default, and stay[5, 6, 9]if True.frame_regexp (
str) – Regular expression pattern to extract the frame number from the frame filename, used only if frame numbers are not defined in thefile_attributescolumn. 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.
- Returns:
movementdataset containing the position, shape, and confidence scores of the tracked bounding boxes, and any associated metadata.- Return type:
Notes
Note that the x,y coordinates in the input VIA tracks .csv file represent the the top-left corner of each bounding box. Instead the corresponding
movementdataset holds in itspositionarray the centroid of each bounding box.Additionally, the bounding boxes IDs specified in the “track” field of the VIA tracks .csv file are mapped to the
individualdimension in themovementdataset. The individual names follow the formatid_<N>, with N being the bounding box ID.References
Examples
Create a dataset from the VIA tracks .csv file at “path/to/file.csv”, with the time coordinates in frames, and setting the first tracked frame in the file as frame 0. The spacing between the tracked frames is preserved, so if the file holds data for frames 100, 105, 110, …, the time coordinates will be 0, 5, 10, …
>>> from movement.io import load_bboxes >>> ds = load_bboxes.from_via_tracks_file( ... "path/to/file.csv", ... )
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_via_tracks_file( ... "path/to/file.csv", ... fps=30, ... )
Create a dataset from the VIA tracks .csv file at “path/to/file.csv”, with the time coordinates in frames, and using the same frame numbers as in the VIA tracks .csv file (e.g. frames 100, 105, 110, … stay as is).
>>> from movement.io import load_bboxes >>> ds = load_bboxes.from_via_tracks_file( ... "path/to/file.csv", ... use_frame_numbers_from_file=True, ... )
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 frame 0 in the full video.
>>> from movement.io import load_bboxes >>> ds = load_bboxes.from_via_tracks_file( ... "path/to/file.csv", ... fps=30, ... use_frame_numbers_from_file=True, ... )