Line Crossing Counter

Counts how many particular tracked objects crossed each line

Overview

The Line Counter node keeps track of the number of objects that cross a virtual line in the video, the direction they cross it in, and adds the line counting metadata to the frame metadata. This node makes it easy to build common use cases such as People counting, Parking lot occupancy counting, etc.

This node supports Lines with one or more segments, allowing you to be as granular as you need for your counting needs.

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

Inputs & Outputs

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

Properties

PropertyDescriptionTypeDefaultRequired
line_labelsList of labels for each line.listnullYes
linesList of lines in the video across which objects will be tracked. Each line can have multiple segments defined by two or more points (x1,y1,x2,y2,x3,y3). Must correspond to labels defined in line_labels.multilinenullYes
objects_to_trackObject types and classes to be counted. Accepts object labels defined in the AI model (e.g. 'car', 'person') and classifier attributes (e.g. 'car.red'). Leave blank to count all objects.model-labelnullNo
crossing_bufferInterval in seconds during which subsequent line crossings by the same object will be ignored.float0.5Yes
display_lineControls whether line information will be displayed on the video stream.booltrueNo
display_objectsControls whether objects will be displayed on the video stream.booltrueNo
tracking_modePoint on object used to determine line crossing. Options: "centroid", "top-center", "bottom-center", "left-center", "right-center".enum"centroid"No
dir1_labelLabel for Direction 1 (blue color in the lines widget).stringnullNo
dir2_labelLabel for Direction 2 (red color in the lines widget).stringnullNo
add_object_attributesAdd specified labels as attributes to objects that cross the line. Options: "none", "direction", "line", "line_direction".enum"none"No
persistent_storageIf true, analytics will be persisted to disk and restored when pipeline restarts.boolfalseNo

Metadata

Metadata PropertyDescription
nodes.<node_id>Describes the Lines monitored by this node, and their properties. \nFormat : as defined in the table below. \n \n<node_id> for Line Counter Nodes is of the form annotate_line_counterX (ex. annotate_line_counter1)

Example

"nodes": {
    "annotate_line_counter1": {
        "type": "annotate_line_counter",
        "lines": {
            "<line_label>": {
                "dir1_label": "entry",
                "dir2_label": "exit",
                "coords": [[<point1_x>, <point1_y>],[<point2_x>, <point2_y> ]],
                "total_objects_crossed": <number>,
                "total_objects_crossed_delta": <number>,
                "dir1_objects_crossed": <number>,
                "dir1_objects_crossed_delta": <number>,
                "dir2_objects_crossed": <number>,
                "dir2_objects_crossed_delta": <number>,
                "cur_dir1_objects": [ <object_tracking_id>,<object_tracking_id> ],
                "cur_dir2_objects": [ <object_tracking_id>,<object_tracking_id>  ]
            }
        }
    }
}

Format

KeyTypeDescription
<line_label>Array of dictionariesContains information about this specific line
<line_label>.coordsDictionaryContains the coordinates for this line \n \npoint1_x, point1_y : Coordinates of one endpoint \npoint2_x, point2_y : Coordinates of the other endpoint
<line_label>.total_objects_crossedIntegerNumber of objects seen crossing this line since the start of the pipeline
<line_label>.total_objects_crossed_deltaIntegerNumber of objects seen crossing this line between last frame and this frame (both directions)
<line_label>.dir1_objects_crossedIntegerNumber of objects seen crossing this line, in one direction since the start of the pipeline
<line_label>.dir1_objects_crossed_deltaIntegerNumber of objects seen crossing this line between last frame and this frame in the direction 1
<line_label>.dir2_objects_crossedIntegerNumber of objects seen crossing this line, in the other direction since the start of the pipeline
<line_label>.dir2_objects_crossed_deltaIntegerNumber of objects seen crossing this line between last frame and this frame in the direction 2
<roi_label>.cur_dir1_objectsList of object IDsInformation about the objects currently crossing the line in the first direction \n \nobject_tracking_id : Unique identifier for a specific object, as specified by object.id property (see AI Model Node )
<roi_label>.cur_dir2_objectsList of object IDsInformation about the objects currently crossing the line in the other direction \n \nobject_tracking_id : Unique identifier for a specific object, as specified by object.id property (see AI Model Node )