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
| Property | Description | Type | Default | Required |
|---|---|---|---|---|
line_labels | Line Labels | string | — | No |
lines | Lines. Conditional on line_labels. Format: comma-separated normalized x0,y0,x1,y1 coordinates; separate multiple lines with semicolons. | string | null | No |
objects_to_track | ex. car, person, car.red. Object types and classes to be counted. Leave blank to count all. | model-labels | null | No |
crossing_buffer | Interval during which subsequent line crossings by the same object will be ignored. Unit: seconds. | float | 0.5 | Yes |
flow_rate_interval | Time interval for calculating flow rate (objects per interval). Set to 0 to disable flow rate calculation. Unit: seconds. | float | 0 | No |
trigger_events | Trigger these Events when an object crosses the line. Options: Disabled (null); Object crossed line (crossed); Object crossed line Dir 1 (crossed_dir1); Object crossed line Dir 2 (crossed_dir2). | enum | null | No |
event_template | Template for the event name. Leave blank to use defaults. Available variables: {object_type}, {object_attributes}, {line}, {direction}. | string | null | No |
add_object_attributes | Add specified labels as attributes to objects that cross the line. Options: None (none); Direction (direction); Line (line); Line_Direction (line_direction). | enum | none | No |
display_line | Display line on video? | bool | true | No |
display_objects | Display objects on video? | bool | true | No |
tracking_mode | Tracking mode. Options: Centroid (centroid); Top center (top-center); Bottom center (bottom-center); Left center (left-center); Right center (right-center). | enum | centroid | No |
dir1_label | Label for Direction 1 (blue color in the lines widget). | string | null | No |
dir2_label | Label for Direction 2 (red color in the lines widget). | string | null | No |
persistent_storage | Persist analytics across restarts? | bool | false | No |
Events
Triggering specific events using trigger_events and event_template fields allows you to add Events to metadata. These Events can then be processed by downstream nodes to publish metrics to a Dashboard, or send notifications or trigger alarms / bookmarks.
Output Metadata
The fields below are declared by this node's metadata schema; the JSON values are representative examples.
| Path | Type | Description |
|---|---|---|
nodes.<node_id>.lines.<line_label>.dir1_label | string | Configured label for line-crossing direction 1. |
nodes.<node_id>.lines.<line_label>.dir2_label | string | Configured label for line-crossing direction 2. |
nodes.<node_id>.lines.<line_label>.total_objects_crossed | integer | Cumulative number of objects that crossed the line in either direction. |
nodes.<node_id>.lines.<line_label>.total_objects_crossed_delta | integer | When one or more objects cross the line in either direction |
nodes.<node_id>.lines.<line_label>.dir1_objects_crossed | integer | Cumulative number of objects that crossed in direction 1. |
nodes.<node_id>.lines.<line_label>.dir1_objects_crossed_delta | integer | When one or more objects cross the line in direction 1 (blue arrow) |
nodes.<node_id>.lines.<line_label>.dir2_objects_crossed | integer | Cumulative number of objects that crossed in direction 2. |
nodes.<node_id>.lines.<line_label>.dir2_objects_crossed_delta | integer | When one or more objects cross the line in direction 2 (red arrow) |
nodes.<node_id>.lines.<line_label>.coords | array | Array of pixel coordinates defining the configured ROI or line. |
nodes.<node_id>.lines.<line_label>.cur_dir1_objects | array | Array of tracking IDs of objects currently crossing in direction 1. |
nodes.<node_id>.lines.<line_label>.cur_dir2_objects | array | Array of tracking IDs of objects currently crossing in direction 2. |
nodes.<node_id>.lines.<line_label>.flow_rate_interval | integer | Time window in seconds used to calculate flow rates. |
nodes.<node_id>.lines.<line_label>.total_flow_rate | integer | Number of crossings in either direction during the flow-rate window. |
nodes.<node_id>.lines.<line_label>.dir1_flow_rate | integer | Number of direction 1 crossings during the flow-rate window. |
nodes.<node_id>.lines.<line_label>.dir2_flow_rate | integer | Number of direction 2 crossings during the flow-rate window. |
nodes.<node_id>.events_delta | integer | When one or more Line Crossing events are triggered |
nodes.<node_id>.events | array | Array of event names generated by this node for the current frame. |
nodes.<node_id>.type | string | Identifies the node type that produced this metadata. |
JSON example
{
"nodes": {
"annotate_line_counter1": {
"events": [],
"events_delta": 0,
"lines": {
"line1": {
"coords": [[<point1_x>, <point1_y>],[<point2_x>, <point2_y> ]],
"cur_dir1_objects": [ <object_tracking_id>,<object_tracking_id> ],
"cur_dir2_objects": [ <object_tracking_id>,<object_tracking_id> ],
"dir1_flow_rate": 0,
"dir1_label": "example",
"dir1_objects_crossed": 0,
"dir1_objects_crossed_delta": 0,
"dir2_flow_rate": 0,
"dir2_label": "example",
"dir2_objects_crossed": 0,
"dir2_objects_crossed_delta": 0,
"flow_rate_interval": 0,
"total_flow_rate": 0,
"total_objects_crossed": 0,
"total_objects_crossed_delta": 0
}
},
"type": "annotate_line_counter"
}
}
}Object labels and attributes
- Object labels/classes added: None.
- Object attribute labels/classes added: Depending on
add_object_attributes, the configured line label (35001), crossing direction label (35002), or<line>_<direction>label (35003).
Updated 6 days ago
