visiannot.tools.video_loader¶
Summary¶
Module with functions for loading image and video files
Functions¶
Loads video data with openCV |
|
Gets duration of a video file |
|
Reads an image with openCV |
|
Changes the order of an image channels in order to get RGB color, may reverse the first and second axis (in order to transform shape |
API¶
Functions¶
-
visiannot.tools.video_loader.get_data_video(path)[source]¶ Loads video data with openCV
- Parameters
path (str) – path to the video file
- Returns
data_video (cv2.VideoCapture) (
Noneif video file does not exist)nframes (int) – number of frames in the video (0 if video file does not exist)
fps (int or float) - frame rate of the video (-1 if video file does not exist)
-
visiannot.tools.video_loader.get_duration_video(path)[source]¶ Gets duration of a video file
- Parameters
path (str) – path to the video file
- Returns
video file duration in seconds
- Return type
float
-
visiannot.tools.video_loader.read_image(path)[source]¶ Reads an image with openCV
- Parameters
path (str) – path to the image file
- Returns
RGB image array of shape

- Return type
numpy array
-
visiannot.tools.video_loader.transform_image(im, RGB_combination='BGR', flag_transpose=True)[source]¶ Changes the order of an image channels in order to get RGB color, may reverse the first and second axis (in order to transform shape
to
).Particularly useful to display images retrieved with openCV. Indeed, openCV returns images of shape
with BGR
color.- Parameters
im (numpy array) – image array of shape
, where third
axis is a 3-channel colorRGB_combination (str) – order of the color channel (as with openCV)
flag_transpose (bool) – specify if first axis and second axis must be reversed
- Returns
image array of shape
where third axis
is RGB color- Return type
numpy array
If
imis not a numpy array or is not a 3D array, then the output isim.