Skip to main content

MotionFilter

Drop metadata if there hasn't been any significant change in the image.

This module provides an pipeline element to drop metadata if there hasn't been any significant change in the image. This element takes in a threshold parameter that specifies the minimum amount of change in the image that is required to keep the metadata. Additionally, there is a max_delay_ms parameter that specifies the maximum amount of time that can elapse between frames.

Examples:

REST API:

WIP

Configuration File:

short-from : motion-filter:<i-threshold>:<i-max_delay_ms>

threshold of 25 and max_delay_ms of 200:

source:
- address: https://youtu.be/jY86pXeTOLw
- type: youtube
pipeline:
- motion-filter:25:200

MotionFilter Objects

class MotionFilter(Element)

Drop metadata if there hasn't been any significant change in the image.

Attributes:

  • name str - The name of the element.
  • threshold int - The threshold for the amount of change in the image that is required to keep the metadata. 0 - 255 (0 is extremely sensitive, 255 is very insensitive)
  • max_delay_ms int - Maximum amount of time that can elapse between frames.

Examples:

threshold of 25 and max_delay_ms of 200:

ele = MotionFilter(25, 200)

extract_params

 | @staticmethod
| def extract_params(model_params)

Extract the parameters for this element.

Arguments:

  • model_params List[str] - The parameters for this element.

Returns:

  • threshold int - The threshold for the amount of change in the image that is required to keep the metadata.
  • max_delay_ms int - Maximum amount of time that can elapse between frames.

Raises:

  • ExtractParameterException - If the parameters are not valid.

Examples:

params = MotionFilter.extract_params(["25", "200"])
ele = MotionFilter(*params)

process

 | def process(meta)

Drop metadata if there hasn't been any significant change in the image.

This is the main function for this element. it will process the metadata and drop it if there hasn't been any significant change in the image.

Arguments:

  • meta dict - The metadata to process.

Returns:

  • meta dict - The processed metadata.

Examples:

params = MotionFilter.extract_params(["25", "200"])
ele = MotionFilter(*params)
meta = ele.process(meta)