Detectors¶
-
class
movement_detector.detectors.AbstractMovementDetector(video)¶ Abstract class for all movement detectors.
Contains the metadata for all frames in the video.
Each frame’s metadata contains the following fields:
time: The timestamp for the frame in seconds since the start of the video.
moving: Set to True if there is movement in the frame.
outlier: Set to True if the frame is detected to be an outlier according to the detection method. If the detection method does not hold the concept of “outliers”, then all fields must be set to False.
flagged: Set to True for flagged outlier frames, and changed to False upon manual-set of the moving field.
manual_set: Set to True if the moving filed has been manually overwritten.
- Parameters
video (AbstractVideo) – The video object.
-
meta(start, stop=None, field=None)¶ Returns a Pandas DataFrame of the required analysis metadata.
- Parameters
start (int) – Start index (inclusive).
stop (int, optional) – The end index of the query (exclusive).
field (string or list, optional) – Name of field data.
- Returns
Can return a Pandas DataFrame, Series, or any other type, depending on specified indexing.
- Return type
pandas DataFrame, pandas Series, or any other
-
property
meta_built¶ Set to True if the metadata has been built.
-
property
meta_path¶ Path to metadata file.
-
run()¶ Process the video and extract the meta-data.
-
save_meta()¶ Save the metadata to file.
The file path relative to the meta folder is the same as the video’s path relative to the video folder.
-
set_freezing(index)¶ Set metadata of specified frame to freezing.
Frame is marked as user-verified, and flagging is removed.
- Parameters
index (int) – Index of frame which to set as freezing.
-
set_moving(index)¶ Set metadata of specified frame to moving.
Frame is marked as user-verified, and flagging is removed.
- Parameters
index (int) – Index of frame which to set as moving.
-
property
video¶ The video associated with the detector.
-
class
movement_detector.detectors.PixelChangeFD(video, outlier_change_threshold, flag_outliers_buffer, movement_threshold, freezing_buffer, blur_ksize)¶ Pixel Change Freezing Detector
Detects freezing based on pixel-value change ratio from one frame to the next.
First, a Gaussian blur filter is applied to the images. Next, the pixels that have changed between the consecutive frames are detected. Then, bounding-boxes are built around those pixels. Finally the ratio of the area of the bounding boxes to the total area of the image is analyzed to determine if the image should be classified as one containing movement or not.
The exact values for the parameters must be determined on the basis of the analyzed videos. The values will be very different depending on factors such as the size of the moving object, contrast of the object with its background etc.
- Parameters
video (AbstractVideo) – The video to analyze.
outlier_change_threshold (float) – The number of standard deviations from the mean that the change value must be to be considered an outlier.
flag_outliers_buffer (int) – The number of consecutive frames that must be identified as outliers in order to flag all those frames for review.
movement_threshold (float) – A value between 0 and 1. The ratio of pixel-change areas relative to the area of the image above which the frame will be flagged as containing movement.
freezing_buffer (int) – The number of consecutive frames that must be identified as containing freezing in order to the moving field for all those frames to False.
blur_ksize (int) – The size of the Gaussian blur filter. For more information refer to: https://docs.opencv.org/master/d4/d13/tutorial_py_filtering.html
References