Skip to main content

LoiterDetection

Detects loitering in a pre-defined keep out zone.

This module provides a pipeline element to detect loitering of any bounding box for a period of time. This module can also check for intrusion, and only check for loiter for the intruding bounding boxes.

Examples:

REST API:

WIP

Configuration File:

short-from : loiter-detection:<i-max_age>:<i-min_hits>:<i-history_buffer>:<s-region_to_check>:<f-ratio>: <i-ma_len>:<i-dwell_time>:<s-inside_zones

pipeline:
- person-detection-nano:a:0.3:0.3
- loiter-detection:3:3:50:bottom:0.2:3:15
sources:
- address: videos/loiter_sample.mp4
- type: file

LoiterDetection Objects

class LoiterDetection(Element)

Detects loitering in a pre-defined keep out zone.

Attributes:

  • name str - The name of the element.
  • max_age int - the number of consecutive iterations for which the tracker needs to be maintained for any object after it has stopped being detected.
  • min_hits int - the min length of tracking history (in number of points) for which intersection with violation_zone is checked.
  • history_buffer int - the lenght of the list containing history as a cyclic buffer
  • region_to_check str - the region of the bounding box that should overlap for the intrusion to be registered.
  • ratio float - the ratio of the bbox to be considered in the marked perspective for intrusion to be detected.
  • ma_len int - the average change in a data series over time.
  • dwell_time int - time in seconds for loiter detection.
  • inside_zones str - flag to check for loitering within a zone.

Examples:

ele = LoiterDetection("3", "3", "50", "bottom", "0.2", "3", "15")

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:

  • max_age int - the number of consecutive iterations for which the tracker needs to be maintained for any object after it has stopped being detected.
  • min_hits int - the min length of tracking history (in number of points) for which intersection with violation_zone is checked.
  • history_buffer int - the lenght of the list containing history as a cyclic buffer
  • region_to_check str - the region of the bounding box that should overlap for the intrusion to be registered.
  • ratio float - the ratio of the bbox to be considered in the marked perspective for intrusion to be detected.
  • ma_len int - the average change in a data series over time.
  • dwell_time int - time in seconds for loiter detection.
  • inside_zones str - flag to check for loitering within a zone.

Raises:

  • ExtractParameterException - If the parameters are not valid.

Examples:

params = LoiterDetection.extract_params(["3", "3", "50", "bottom", "0.2", "3", "15"])
ele = LoiterDetection(*params)

process

 | def process(meta)

Process the bounding boxes.

This is the main function for this element. It will take the bounding boxes and check for loiter over a period of time(dwell_time), it also checks for intrusion to flag only intruding bounding boxes for loitering.

Arguments:

  • meta dict - The metadata to process.

Returns:

  • meta dict - The processed metadata.

Examples:

ele = LoiterDetection("3", "3", "50", "bottom", "0.2", "3", "15")
meta = ele.process(meta)