pyorc.Video#
- class pyorc.Video(fn, camera_config=None, h_a=None, start_frame=None, end_frame=None, stabilize=None, mask_exterior=None)[source]#
Video class, inheriting parts from cv2.VideoCapture. Contains a camera configuration to it, and a start and end frame to read from the video. Several methods read frames into memory or into a xr.DataArray with attributes. These can then be processed with other pyorc API functionalities.
- Parameters:
fn (str) – Locally stored video file
camera_config (pyorc.CameraConfig, optional) – contains all information about the camera, lens parameters, lens position, ground control points with GPS coordinates, and all referencing information (see CameraConfig), needed to reproject frames on a horizontal geographically referenced plane.
h_a (float, optional) – actual height [m], measured in local vertical reference during the video (e.g. a staff gauge in view of the camera)
start_frame (int, optional) – first frame to use in analysis (default: 0)
end_frame (int, optional) – last frame to use in analysis (if not set, last frame available in video will be used)
stabilize (optional) – If set to a recipe name, the video will be stabilized by attempting to find rigid points and track these with Lukas Kanade optical flow. “fixed” for FOV that is meant to be in one place, “moving” for a moving FOV.
mask_exterior (list of lists,) – set of coordinates, that together encapsulate the polygon that defines the mask, separating land from water. The mask is used to select region (on land) for rigid point search for stabilization.
- __init__(fn, camera_config=None, h_a=None, start_frame=None, end_frame=None, stabilize=None, mask_exterior=None)[source]#
Video class, inheriting parts from cv2.VideoCapture. Contains a camera configuration to it, and a start and end frame to read from the video. Several methods read frames into memory or into a xr.DataArray with attributes. These can then be processed with other pyorc API functionalities.
- Parameters:
fn (str) – Locally stored video file
camera_config (pyorc.CameraConfig, optional) – contains all information about the camera, lens parameters, lens position, ground control points with GPS coordinates, and all referencing information (see CameraConfig), needed to reproject frames on a horizontal geographically referenced plane.
h_a (float, optional) – actual height [m], measured in local vertical reference during the video (e.g. a staff gauge in view of the camera)
start_frame (int, optional) – first frame to use in analysis (default: 0)
end_frame (int, optional) – last frame to use in analysis (if not set, last frame available in video will be used)
stabilize (optional) – If set to a recipe name, the video will be stabilized by attempting to find rigid points and track these with Lukas Kanade optical flow. “fixed” for FOV that is meant to be in one place, “moving” for a moving FOV.
mask_exterior (list of lists,) – set of coordinates, that together encapsulate the polygon that defines the mask, separating land from water. The mask is used to select region (on land) for rigid point search for stabilization.
Methods
__init__
(fn[, camera_config, h_a, ...])Video class, inheriting parts from cv2.VideoCapture.
get_frame
(n[, method, lens_corr])Retrieve one frame.
get_frames
(**kwargs)Get a xr.DataArray, containing a dask array of frames, from start_frame until end_frame, expected to be read lazily.
plot_rigid_pts
([ax])Plots found rigid points (column, row) for stabilization and their path throughout the frames in time on an axes object.
set_mask_from_exterior
(exterior)Attributes
CameraConfig object
list of 4 lists (int) with [column, row] locations of area of interest in video objective
int, last frame considered in analysis
float, frames per second
h_a
Actual water level [m] during video
mask
returns: Mask of region of interest :rtype: np.ndarray
int, first frame considered in analysis