Proximity Detector

Detect and create groups of objects when they are close to or far from each other.

Overview

The Proximity Detector node detects and creates groups of objects when they are close to or far from each other. This node makes it easy to build common use cases such as Object left behind, Crowd forming, Service times for drive throughs, etc.

This node requires a AI Model Node and a Track Objects Node before it in order to function properly.

Current implementation limitation: the As Objects property value is object, but the script currently checks for objects. Configuring As Objects through the property UI therefore follows the attributes path instead of adding a group object. Use the node's group metadata downstream until this code mismatch is corrected.

Inputs & Outputs

  • Inputs : 1, Media Format : Raw Video
  • Outputs : 1, Media Format: Raw Video
  • Output Metadata : Presence Information

Properties

PropertyDescriptionTypeDefaultRequired
roi_labelsRegion of interest labelstringNo
roisRegion of interest. Conditional on roi_labels. Format: comma-separated normalized x,y coordinate pairs; separate multiple polygons with semicolons (for example, 0.1,0.1,0.9,0.1,0.9,0.9).stringnullNo
proximity_groupsex. car+person,person+person,bag-person. Comma-separated list of group types to detect. Format: A+B (objects of type A which have type B nearby), A-B (objects of type A without any type B nearby).model-labelsnullYes
proximity_modeProximity mode. Options: Object distance (distance): A+B (A with B in distance limit), A-B (A without B in distance limit); Object within (enclosed): A+B (A inside B), A-B (A outside B); Object contains (contains): A+B (A contains B), A-B (A does not contain B).enumdistanceNo
distance_thresholdPixel distance between two objects to be considered as within a '+' group or outside a '-' group. Range: 0-1. Specified as percentage of video source width. Conditional on proximity_mode being distance. Range: minimum 0, maximum 1.0. Step: 0.05. Unit: %.float0.1Yes
merge_modeMerge groups of same or any type that overlap each other within the group distance limit. Options: No merge (no_merge); Same type (same_type); Any type (any_type).enumsame_typeNo
min_group_sizeIgnore groups smaller than this size.number1Yes
min_group_lifespanIgnore groups that exist for less than this amount of time in seconds. Unit: seconds.float1.0Yes
output_modeOutput groups as individual objects or as attributes to the primary object. Options: As Objects (object): Output each group as an individual object with a unique ID; As Attributes (attribute): Adds the 2nd (& subsequent) objects (B) as attributes to the primary object (A).enumobjectNo
group_lifespan_trigger_thresholdSet a trigger when the group lifespan exceeds this time in seconds. Unit: seconds.float5Yes
group_size_trigger_thresholdSet a trigger when the group size exceeds this number.number1Yes
display_groups_modeDisplay groups that meet this criteria on the video. Options: None (none); Above threshold (above_threshold); All (all).enumabove_thresholdNo
display_propertiesDisplay these group properties. Basic includes lifespan and size, intermediate adds group type, detailed adds group ID. Options: Basic (basic); Intermediate (intermediate); Detailed (detailed).enumintermediateNo
display_roiDisplay ROI on video?booltrueNo
tracking_modeThe point to be used as tracking point, refers to the position on the object's bounding box. Options: Centroid (centroid); Top Center (top-center); Bottom Center (bottom-center); Left Center (left-center); Right Center (right-center).enumcentroidNo
object_contain_modeObject containment mode. Options: Bounding Box (bbox): Bounding box inside other object's bounding box; Tracking Point (tracking_point): Selected tracking point (above) inside other object's bounding box; Overlap (bbox_overlap): Bounding box overlaps other object's bounding box.enumtracking_pointNo
negative_attribute_prefixPrefix for negative attributes. For example, if a group of 'car-person' is detected, the person object will be tagged with the attribute -car or no_car. Conditional on output_mode being attribute.string-No

Output Metadata

The fields below are declared by this node's metadata schema; the JSON values are representative examples.

PathTypeDescription
nodes.<node_id>.rois.<roi_label>.current_group_countintegerNumber of proximity groups currently present.
nodes.<node_id>.rois.<roi_label>.groups_entered_deltaintegerWhen one or more new groups enter the ROI
nodes.<node_id>.rois.<roi_label>.groups_above_lifespan_threshold_countintegerNumber of groups older than the configured lifespan threshold.
nodes.<node_id>.rois.<roi_label>.groups_above_lifespan_threshold_deltaintegerWhen one or more groups exceeds lifespan threshold
nodes.<node_id>.rois.<roi_label>.groups_above_size_threshold_countintegerNumber of groups larger than the configured size threshold.
nodes.<node_id>.rois.<roi_label>.groups_above_size_threshold_deltaintegerWhen one or more groups exceeds size threshold
nodes.<node_id>.rois.<roi_label>.coordsarrayArray of pixel coordinates defining the configured ROI or line.
nodes.<node_id>.rois.<roi_label>.groups[].idintegerIdentifier assigned to the proximity group.
nodes.<node_id>.rois.<roi_label>.groups[].labelstringObject-class combination represented by the group.
nodes.<node_id>.rois.<roi_label>.groups[].objectsarrayArray of tracking IDs of objects belonging to the group.
nodes.<node_id>.rois.<roi_label>.groups[].lifespannumberTime in seconds that the group has persisted.
nodes.<node_id>.rois.<roi_label>.objects_of_interest_keysarrayArray of metadata keys that contain object IDs relevant to downstream integrations.
nodes.<node_id>.rois.<roi_label>.descriptionstringHuman-readable summary of the node’s current result.
nodes.<node_id>.typestringIdentifies the node type that produced this metadata.

JSON example

{
  "nodes": {
    "annotate_proximity1": {
      "rois": {
        "roi1": {
          "coords": [],
          "current_group_count": 0,
          "description": "value",
          "groups": [
            {
              "id": 0,
              "label": "person+car",
              "lifespan": 10.0,
              "objects": [123456789,1231121321]
            }
          ],
          "groups_above_lifespan_threshold_count": 0,
          "groups_above_lifespan_threshold_delta": 0,
          "groups_above_size_threshold_count": 0,
          "groups_above_size_threshold_delta": 0,
          "groups_entered_delta": 0,
          "objects_of_interest_keys": []
        }
      },
      "type": "annotate_proximity"
    }
  }
}

Additional details

Object labels and attributes

  • Object labels/classes added: When the output_mode is object output mode, a configured proximity-group label is added as a new object with class 999.
  • Object attribute labels/classes added: When the output_mode is attribute, for positive relationships, each secondary object's label is added to the primary object as an attribute with . replaced by _, retaining the secondary object's class ID. Negative relationships add <negative prefix><secondary label> attribute (also replacing . with _) with class 999 to the primary object.

Did this page help you?