Research on a traffic flow statistical algorithm based on YBOVDT and SAM2

Yuanyuan Wang, Zheng Ding, Jiange Liu, William Ka Kei Wu, Md Sharid Kayes Dipu, T. Ma, Yonghao Ma, Haiyan ZhangScientific 2025

Abstract

In the process of urbanization, traffic flow statistics are of great significance to traffic management. Existing solutions often suffer from incomplete functionality and lack effective solutions for core issues, such as the limitations of closed-set object detection and unstable tracking algorithms. This paper proposes a traffic flow statistical method based on YBOVDT (YOLO-World and BOT-SORT-Open Vocabulary Detection and Tracking) and SAM2. By introducing a "Traffic Flow Data Processing and Analysis" module, the framework optimizes five core functions required for traffic monitoring. Experimental results on a custom dataset show that the YOLO-World model achieves a precision of 76.99% and an mAP50 of 70.08%, offering superior recognition accuracy and environmental adaptability compared to YOLO-v3, v5, v6, and v8.

Introduction: The Limitations of Traditional Traffic Monitoring

Traditional traffic monitoring systems are often "brittle." They typically rely on closed-set object detectors (like standard YOLOv5 or v8), which can only recognize categories they were explicitly trained on. If a city needs to track a new type of vehicle or a specific sub-category (e.g., "white van"), the model usually requires expensive retraining.

Furthermore, existing systems struggle with:

  1. Irregular Road Geometry: Standard bounding boxes for "road areas" often include non-road pixels, leading to false positives in stalled-vehicle detection.
  2. Tracking Instability: Older trackers like DeepSORT often lose targets during occlusions or camera shakes.
  3. Functional Incompleteness: Many solutions focus only on counting, failing to integrate speed calculation, density analysis, and stalled-object identification into a single pipeline.

Methodology: The YBOVDT Framework

The authors propose a hybrid architecture nicknamed YBOVDT integrated with SAM2 to address these challenges.

YOLO-World for Open-Vocabulary Detection

Unlike standard detectors, YOLO-World uses a "prompting before detection" approach. It aligns visual features with textual embeddings, allowing users to define new detection categories on the fly without retraining. This flexibility is critical for modern traffic environments where new vehicle types (like electric scooters) frequently emerge.

Architecture of the YOLO-World detector, showing the integration of text and image features.

BOT-SORT and SAM2 Integration

To improve tracking stability, BOT-SORT was chosen over DeepSORT. It incorporates Global Motion Compensation (GMC) to handle camera jitters and uses a more refined state vector to better predict trajectories.

For spatial analysis, the authors utilize SAM2 (Segment Anything Model 2). To solve the "irregular road" problem, they automate SAM2 by using YOLO-World’s road detection boxes as "point prompts," allowing the model to precisely mask the drivable area. When vehicles occlude the road, a Mask Repair Pipeline using Canny edge detection and dilation operations is employed to ensure the road area remains consistent for Intersection over Union (IoU) calculations.

Traffic Flow Data Processing and Analysis

A core contribution of this research is the logic for identifying stalled vehicles. By calculating the IoU between the refined road mask and vehicle masks over time, the system can distinguish between a vehicle stopped at a light and a truly stalled vehicle that remains static over a long duration.

Flowchart of the stalled vehicle (detention object) judgment mechanism.

Experimental Results

The study utilized a mix of standard benchmarks and a new custom dataset, the TFSD (Traffic Flow Statistics Dataset), containing 18,930 images and 122,997 object instances.

  • Detection Accuracy: The YOLO-Worldv2-l model achieved a precision of 76.99% and an mAP50 of 70.08% on the custom TFSD dataset, outperforming YOLO-v3, v5, v6, and v8.
  • Tracking Performance: On the MOT17 benchmark, the integrated BOT-SORT approach showed a continuous upward trend in MOTA (Multiple Object Tracking Accuracy) and HOTA (Higher Order Tracking Accuracy) compared to the ByteTrack baseline.
  • Inference Speed: Despite the complexity, the system is highly efficient. Single-frame processing times ranged from 0.0051s to 0.0121s, meeting the requirements for high-frame-rate real-time monitoring.

Conclusion

While the "mask repair" logic helps with occlusions, it currently only plays a mitigating role and cannot perfectly reconstruct a road mask if it is almost entirely blocked by a large vehicle. Future work will focus on dynamic load balancing to save computational power during quiet periods and further refining the algorithm for deployment on edge computing devices with limited GPU resources.

Summary updated

BibTeX
@inproceedings{wang2025research,
  author = {Yuanyuan Wang and Zheng Ding and Jiange Liu and William Ka Kei Wu and Md Sharid Kayes Dipu and T. Ma and Yonghao Ma and Haiyan Zhang},
  title = {{Research on a traffic flow statistical algorithm based on YBOVDT and SAM2}},
  booktitle = {Scientific},
  year = {2025},
  doi = {10.1038/s41598-025-04336-2},
}
Figure