Video

class movement_detector.video.AbstractVideo(file_path)

Interface definition for the video classes.

This class defines the public methods that a video class must expose to be compatible with the movement detectors.

Parameters

file_path (Path) – The path to the video file.

abstract property frame_rate

The video’s frame rate.

Returns

Return type

float

abstract property frame_shape

The shape of a single frame.

Returns

Return type

tuple

abstract get_frame(i)

Returns the frame at index i.

Parameters

i (int) – Index of desired frame.

Returns

The frame as a NumPy array.

Return type

NumPy array

abstract get_frame_time(i=None)

Returns the video-time for the frame i in seconds.

Parameters

i (int) – Index of desired frame time.

Returns

The time in seconds since start of video.

Return type

float

abstract mean()

Computes the pixel-wise mean for the frames in the video.

Returns

Numpy array with the pixel-wise mean values.

Return type

NumPy array

abstract std()

Computes the pixel-wise standard deviation of the video frames.

Returns

Numpy array with the pixel-wise standard deviation values.

Return type

NumPy

abstract sum()

Computes the pixel-wise sum of the frames in the video.

Returns

Numpy array with the pixel-wise sum values.

Return type

NumPy array

abstract property vid_duration

The duration of the video in seconds.

Returns

Return type

float

class movement_detector.video.CvVideo(file_path)

OpenCV implementation of the video class interface.

OpenCV provides the most optimized algorithms for video processing. For efficiency, the implementation resorts to lazy evaluation and caching of the compute-intensive operations.

property frame_rate

The video’s frame rate.

Returns

Return type

float

property frame_shape

The shape of a single frame.

Returns

Return type

tuple

get_frame(i=None)

Returns the frame at index i.

Parameters

i (int) – Index of desired frame.

Returns

The frame as a NumPy array.

Return type

NumPy array

get_frame_time(i=None)

Returns the video-time for the frame i in seconds.

Parameters

i (int) – Index of desired frame time.

Returns

The time in seconds since start of video.

Return type

float

mean()

Computes the pixel-wise mean for the frames in the video.

Returns

Numpy array with the pixel-wise mean values.

Return type

NumPy array

std()

Computes the pixel-wise standard deviation of the video frames.

Returns

Numpy array with the pixel-wise standard deviation values.

Return type

NumPy

sum()

Computes the pixel-wise sum of the frames in the video.

Returns

Numpy array with the pixel-wise sum values.

Return type

NumPy array

property vid_duration

The duration of the video in seconds.

Returns

Return type

float