TrafficLab-3D

duy-phamduc68MIT活跃维护

仅用一段 MP4 监控录像和对应的谷歌地图位置,就能重建出数字孪生风格的三维交通场景,把画面里的车辆投影到真实地理坐标上。

Create a digital-twin style traffic visualization using only mp4 CCTV footage and its Google Maps location.

v1.1发布于 2026-03-20 13:00 UTC504star71fork同步于 2026-11-07 07:32 UTC

怎么上手

由 README 提炼,执行前请确认
conda env create -f environment.yml
python main.py
硬件要求按 README 说明

README 未说明显存或 GPU 型号要求,仅说明需先创建 conda 环境再运行 main.py

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用一段 mp4 监控视频和 Google Maps 位置,就能做出数字孪生风格的三维交通可视化

仅用一段 MP4 监控录像和对应的谷歌地图位置,就能重建出数字孪生风格的三维交通场景,把画面里的车辆投影到真实地理坐标上。

核心能力

  • 分阶段标定,建立 CCTV 与卫星图之间的双向投影
  • 支持替换目标检测模型和跟踪器,并调节速度与朝向平滑参数
  • 推理结果存为压缩 json.gz,渲染时无需重复计算
  • 并排同步显示 CCTV 三维框与卫星图地面框、速度和朝向
  • 内置 Location 标签页,可生成标定所需的目录骨架

容易踩的坑

需自行从 Google Drive 下载 YOLO 权重放入 models/,并下载预构建的 location 目录才能直接体验;标定依赖 cctv_{code}.png 和 sat_{code}.png 等关键文件,缺失就无法进行;方法仅适用于单一平面场景,遮挡会导致目标消失

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

2 个版本v1.1
  1. v1.1最新正式版2026-03-20 · 2026-03-20 13:00 UTC

    TrafficLab 3D v1.1

    Release Summary

    Version 1.1 focuses on a structural codebase refactor and an expanded library of supplemental resources. The transition from a research prototype to a more stable architecture improves maintainability and performance.

    Key Changes

    • Codebase Refactor: Completed a full rewrite for better architectural stability and future scalability.
    • Resource Update: Added several new pre-constructed location codes to the resource drive for testing and visualization.
    • Kinematics: Initial refinements to tracking constraints for smoother object visualization.

    Project Resources

    Setup

    1. Update dependencies: conda env create -f environment.yml.
    2. Place models in models/ and location data in location/.
    3. Launch via python main.py.

    Developed by Yuk | [yuk068.github.io](https://yuk068.github.io)

  2. v1.02026-03-09 · 2026-03-09 21:52 UTC
    查看更新说明

    TrafficLab 3D v1.0

    Research Prototype and Proof-of-Concept

    This is the initial release of TrafficLab 3D, an end-to-end traffic analysis suite designed to demonstrate advanced computer vision and digital twin synchronization using only standard MP4 CCTV footage and Google Maps data.

    The project prioritizes accessibility, allowing students and individual investigators to generate high-fidelity 3D visualizations, including speed, orientation, and floor box projections, without requiring professional camera calibration or synchronized high-quality satellite imagery.

    Core Functionality

    • Calibration Pipeline: A three-phase process (Undistort, Homography, and Parallax) to establish a two-way projection between the CCTV domain and the satellite map. Supports custom SVG and ROI discard strategies.
    • Inference Hub: A dedicated interface for managing object detection (YOLOv8/v11) and tracking. Outputs are saved in compressed .json.gz format to ensure storage efficiency and decouple heavy computation from rendering.
    • Visualization Engine: A synchronized side-by-side view of CCTV and SAT panels. Features 3D bounding boxes and real-time kinematics visualization via a comprehensive toolbar and keyboard shortcuts.

    Current Status

    This version (v1.0) is released as a proof-of-concept research prototype. While the core features for calibration and visualization are functional, the codebase is currently undergoing a significant refactor to improve maintainability and performance.

    Note: The current projection method is designed for and restricted to singular flat planar environments.

    Getting Started

    1. Environment: Install the necessary dependencies via conda env create -f environment.yml.
    2. Resources: Pre-trained models and sample location folders for testing are available in the Google Drive.
    3. Execution: Run python main.py and navigate the tabs to begin the calibration or visualization process.

    Roadmap for v1.1

    • Complete rewrite of the codebase for better architectural stability.
    • Research into smoother, physically-constrained kinematics for object tracking.
    • Refined and potentially automated calibration options.

    Developed by Yuk | Yuk's Blog | TrafficLab 3D v1.0 Demo

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    TrafficLab 3D

    TrafficLab puts accessibility at the forefront, with just access to mp4 CCTV footage and knowing where that location is on Google Maps, anyone can create a fancy digital twin demo that demonstrates advanced computer vision, especially for students, individual investigators, and enthusiasts who might not have access to camera calibration and synchronized high quality satellite imagery.

    Demo

    Release: v1.1

    Developed by Yuk

    Complementary resources:

    It is very recommended that you read through this README if you want to run this program on your own machine. Click here to jump to Getting Started

    Project Status and Future Direction

    Important: This repository represents the initial Proof of Concept (PoC) for TrafficLab 3D. While the tool is functional for academic and demonstration purposes, the current codebase is an experimental, monolithic prototype. Instead of archiving this repository to focus on a rewrite, I am keeping development open to anyone who shares the vision of scaling this framework. The immediate goal is refactoring the project into a modular architecture, and improving it especially with what I was able to learn from this PoC. Please contact me first if you are interested in developing this vision with me!

    Contributions and Collaboration

    If you want to help transition this project to a maintainable ecosystem, contributions are welcome:

    • Architecture: Advice on structural decoupling and data schemas is encouraged via GitHub Issues.
    • Code: Before submitting a Pull Request, please open an Issue to describe the optimization or refactoring step so we can align on the direction.
    • Methodology: To understand the underlying theory first, please refer to the academic report or the blog post.
    TrafficLab-3D/
    ├── location/
    │   └── {location_code}/
    │       ├── footage/
    │       │   └── *.mp4
    │       │
    │       ├── illustrator/                 (optional, Adobe Illustrator assets)
    │       │   ├── layout_{location_code}.ai
    │       │   ├── roi_{location_code}.ai
    │       │   └── *.ai
    │       │
    │       ├── G_projection_{location_code}.json
    │       ├── cctv_{location_code}.png     (critical!)
    │       ├── sat_{location_code}.png      (critical!)
    │       ├── layout_{location_code}.svg   (optional)
    │       └── roi_{location_code}.png      (optional)
    │
    ├── media/                               (resources for README and Introduction tab)
    │
    ├── trafficlab/                                 (main codebase)
    │
    ├── models/                              (object detection & tracker models)
    │   └── *.pt                             (YOLO checkpoints)
    │
    ├── output/
    │   └── model-{model_name}_tracker-{tracker_name}/
    │       └── {config-name}/
    │           └── {location_code}/
    │               └── *.json.gz             (inference outputs)
    │
    ├── environment.yml
    ├── inference_config.yaml
    ├── prior_dimensions.json
    └── main.py
    

    Introduction

    TrafficLab is an end-to-end traffic analysis suite that covers:

    • Calibration: Establishing a two way projection between any CCTV and its satellite map, with support for custom SVG.
    • Inference: Easily swap object detection models and object tracker along with numerous kinetics and comprehensive control of arguments.
    • Visualization: A "digital twin" experience with side-by-side, synchronized view of CCTV with 3D bounding boxes and satellite view with floor box, speed, and orientation.

    WelcomeTab

    Get started by navigating to any tabs on the top left corner of the program.

    Functionality

    TrafficLab functionalities are spread across 3 main tabs, you can navigate to any of these tabs without losing work on another, below are brief description of each of the tabs.

    Calibration Tab

    CalibrationStart

    Calibration Tab produces G Projection JSON files (refer to the report) which helps establish a two-way projection between the CCTV and SAT (satellite) domain, it presents a comprehensive, backwards compatible stage-based calibration process comprising of the following stages:

    • Phase 1: Undistort
      • Pick Stage: Quickly validate and initialize construction/reconstruction of G Projection for a given location code.
      • Lens Stage: Configure intrinsics matrix K.
      • Undistort Stage: Adjust distortion coefficients obeying the Brown-Conrady distortion model (5 coefficients).
      • Validation 1: You can confirm the distortion and intrinsics, concluding the Phase.
    • Phase 2: Homography
      • Homography Anchors Stage: Manual pair point based homography computation with RANSAC solver.
      • Homography FOV Stage: Check the warped CCTV overlaid on the SAT map, which also doubles up as a FOV polygon for intuitive visualization.
      • Validation 2: Click a ground contact point in CCTV and see it shows up on SAT map.
    • Phase 3: Parallax
      • Parallax Subjects Stage: Establish Head and Ground Contact point of 2 Subjects, input their height, calculate the camera's position.
      • Distance Reference Stage: Enter the distance (obtainable from Google Maps/Earth) to establish pixel per meter ratio.
      • Validation 3: Click head point, enter height, see ground contact point in CCTV and actual position on SAT map.
    • Optional:
      • SVG Stage: Compute affine matrix between SVG and SAT.
      • ROI Stage: Choose a discard strategy for ROI.
    • Final Validation: Test how 2D bounding box converts to 3D box in CCTV and floor box in SAT.
    • Save Stage: Confirm saving a G Projection for the location code.

    CalibrationEnd

    Note: Location Code:

    You will have to prepare the necessary folders and files to perform calibration, there is also a Location Tab to help you with creating the barebone location folder, ready for calibration. you can create custom SVG and ROI using Adobe Illustrator, refer to the blog post/Youtube video for a more detailed guide on crafting said resources.

    LocationTab

    Inference Tab

    InferenceTab

    Inference Tab is a Hub for you to keep track of all your production of the output JSON files, these files are what are actually used by the visualization engine, eliminating the need to perform demanding computation on top of heavy rendering. For arguments, you will control them through inference_config.yaml and prior_dimensions.json in the project's root. JSON will be saved as the compressed .json.gz format for storage efficiency. Controllable arguments includes:

    • Object detection model.
    • Object tracker.
    • Speed and orientation smoothing kinematics.

    Visualization Tab

    VisualizationTab

    The visualization engine for the output JSON files, features comprehensive controls via a tool bar and keyboard shortcuts, flexible side by side view of CCTV and SAT panel.

    Getting Started

    Install the necessary conda/venv environment, then run main.py:

    conda env create -f environment.yml
    python main.py
    

    In this Google Drive, you can find:

    • Some finetuned YOLOv8-s and YOLOv11-s models for the models/ folder.
    • Two folders of the same location code with their projection constructed, 1 with SVG and 1 without. If you want more pre-constructed projections of different locations then contact me. Put these in location/.
    • UPDATE: I've added quite a few more pre-constructed location code that I used myself in my testing to the Drive. Feel free to load them into TrafficLab, run inference, and see the visualization!
    • One preprocessed .json.gz output file ready for visualization (need the 119NH folder in location/ from the same Drive).

    This project was inspired by the paper Rezaei et al. 2023

    Run Configs

    If you do want to configure your own model and adjust kinematics, you will have to inspect the inference_config.yaml and prior_dimensions.json files.

    Open Problems

    • This method only works on a singular flat planar environment.
    • The data is very "physics-ignoring", it mostly take output from detector and tracker as-is, which can be noisy:
      • Occulsion will make an object behind it disappear (eg. a large bus, truck covering a sedan, pedestrian).
      • The vehicle 3D boxes does not follow any vehicle model, ensuring they adhere to something like a kinematic bicycle model will eliminate a lot of problems where vehicle boxes just rotates or teleport randomly.
      • A user can't just appear or disappear in the middle of the scene, some entry/exit annotations could help with this.
    • Crafting the initial G-Projection and SVG Map is still a very tedious task.

    Changelog

    • v1.0: Initial release.
    • v1.1: Refactored codebase and bug fixes.

    Long-term Vision

    I wish to scale this idea to be city-wide, with automatic calibration + continuous detector & tracker improvement. Eventually being sufficient for high-fidelity downstream tasks such as simulation, digital twin, natural language query, reinforcement learning, etc...