Traffic Intersection Analysis

This function block helps you count and log vehicle movements through defined areas of an intersection. It converts tracked detections and polygonal areas into route statistics (for example, "1-2" means a vehicle moved from area 1 into area 2). Designed for easy integration into an inspection scenario, it outputs summarized tracking data ready for export or display.

πŸ“₯ Inputs (sockets)

  • Rectangle - ID List β€” Provide tracked detections (bounding rectangles with tracking IDs).

  • Polygon Areas β€” Provide one or more polygon areas that define the intersection zones to monitor.

  • Reset Tracking Log β€” Boolean input to clear all stored tracking history and counts.

πŸ“€ Outputs (sockets)

  • Tracking Data β€” Aggregated route counts (JSON-like format) showing how many vehicles of each type passed between area pairs (e.g., "1-2": {"car": 3, "bus": 1}).

πŸ•ΉοΈ Controls

  • Reset Tracking Log β€” Trigger this input (for example with a manual switch) to reset all counters and internal history.

  • (Polygon areas are provided via the Polygon Areas socket; use a polygon selection block to define them.)

🎯 Key Features

  • Uses tracked bounding boxes and tracking IDs to associate detections across frames and detect area transitions.

  • Keeps a short recent position history per tracked object to stabilize noisy positions before deciding which polygon area an object occupies.

  • Produces route-based statistics (area-to-area transitions) grouped by vehicle type.

  • Supports multiple polygon areas (each area may have many corner points).

  • Reset option to clear history and counters on demand.

βš™οΈ Running mechanism (high level)

  • The block accepts a list of tracked rectangles with IDs and (optionally) vehicle class names.

  • For each tracked item it computes a representative point (bottom-center of the bounding box) and maintains a short history of recent points for that ID.

  • The representative point (averaged over recent positions) is tested against each supplied polygon area to determine the current area for that vehicle.

  • When a vehicle’s area changes (e.g., from area 1 to area 2), the transition is recorded and the corresponding route counter for that vehicle type is incremented.

  • The aggregated route counts are output as structured data via the Tracking Data socket.

  • Activating the Reset Tracking Log input clears all stored histories and counters.

πŸ“ Usage instructions

  1. Provide tracked detections to the Rectangle - ID List input. Use a tracker that outputs rectangles with stable IDs.

  2. Define intersection regions with polygons and connect them to the Polygon Areas input.

  3. To clear counters and history at any time, send a TRUE signal to the Reset Tracking Log input.

  4. Read the live route statistics from the Tracking Data output and use them for display, logging or export.

πŸ’‘ Tips and Tricks

  • Use Object_Detection_Tracker to produce the Rectangle - ID List input. This block provides tracked rectangles and IDs that are ideal for route analysis.

  • Draw and save polygon areas with Image ROI Polygon Multi and connect its Polygons output to the block’s Polygon Areas input. That block makes it easy to define multiple intersection zones visually.

  • Use Logic Input to provide a manual trigger for Reset Tracking Log when you want to restart counting at known intervals (shift changes, test runs, etc.).

  • For visual verification, connect detections to Draw Detections to overlay rectangles/IDs on the video, then send the resulting image to Show Image to preview results live.

  • Export summarized results for reporting with Data to JSON or CSV Export using the Tracking Data output.

  • If detections are noisy, consider placing a short smoothing pipeline before tracking (for example, ensure the tracker input image is preprocessed with mild denoising filters) so tracked IDs remain stable.

πŸ› οΈ Troubleshooting

  • No transitions recorded: verify that the Rectangle - ID List contains stable tracking IDs across frames (unstable IDs prevent detecting area changes).

  • Incorrect area assignment: confirm polygon coordinates align with the camera view; use Image ROI Polygon Multi to redraw polygons on the actual image.

  • Counters not clearing: ensure the Reset Tracking Log input is receiving a TRUE signal (e.g., from a Logic Input or other control block).

  • Missing vehicle type labels: route counts are grouped by vehicle type when that metadata is provided; ensure your tracker outputs class/type along with IDs.

Last updated

Was this helpful?