pyorc.Video#

class pyorc.Video(fn: str, camera_config: Optional[Union[str, CameraConfig]] = None, h_a: Optional[float] = None, start_frame: Optional[int] = None, end_frame: Optional[int] = None, freq: Optional[int] = 1, stabilize: Optional[List[List]] = 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 (list of lists, optional) – 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. If not set, then no stabilization will be performed

__init__(fn: str, camera_config: Optional[Union[str, CameraConfig]] = None, h_a: Optional[float] = None, start_frame: Optional[int] = None, end_frame: Optional[int] = None, freq: Optional[int] = 1, stabilize: Optional[List[List]] = 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 (list of lists, optional) – 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. If not set, then no stabilization will be performed

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.

get_ms(cap[, split])

set_mask_from_exterior(exterior)

Prepare a mask grid with 255 outside of the stabilization polygon and 0 inside

Attributes

camera_config

CameraConfig object

corners

list of 4 lists (int) with [column, row] locations of area of interest in video objective

end_frame

int, last frame considered in analysis

fps

float, frames per second

freq

returns: int :rtype: frequency (1 in nth frames to select)

h_a

Actual water level [m] during video

mask

returns: Mask of region of interest :rtype: np.ndarray

rotation

stabilize

start_frame

int, first frame considered in analysis