File size: 12,453 Bytes
e9d31c2 b330934 e9d31c2 b330934 e9d31c2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | ---
license: apache-2.0
language:
- zh
- en
tags:
- traffic
- perception
- object-detection
- tracking
- intersection
- yolo
- yolo11
- deepsort
- computer-vision
- autonomous-driving
- v1
pipeline_tag: object-detection
library_name: custom
base_model: Ultralytics/yolo11
---
<div align="center">
<img src="https://huggingface.co/buckets/OpenTraffic/opentraffic-perception-engine/resolve/opentraffic-perception-engine-main/figure/LOGO2x.png" width="70%" />
[](https://arxiv.org/abs/XXXX.XXXXX)
[](LICENSE)
[](https://www.python.org/)
[]()
<br/>
[](https://huggingface.co/OpenTraffic-Team)
[](https://github.com/OpenTraffic-Team/Tir)
[](https://github.com/OpenTraffic-Team/Tir/issues/1)
</div>
## TIR β Open-source traffic perception engine for urban intersections
Supports multi-stream RTSP input, YOLO11 + DeepSort detection and tracking, homography-based coordinate transformation, world velocity estimation, lane-level structured output, and radar-reference validation. Designed for Perception-Driven TSC scenarios.
<div align="center">
<img src="https://huggingface.co/buckets/OpenTraffic/opentraffic-perception-engine/resolve/opentraffic-perception-engine-main/figure/Framework.png" width="90%">
</div>
<br/>
**Paper:** https://arxiv.org/abs/XXXX.XXXXX
**Project Page:** https://opentraffic-team.github.io/tir
**HuggingFace:** https://huggingface.co/OpenTraffic-Team
**GitHub:** https://github.com/OpenTraffic-Team/Tir
<br/>
## π Table of Contents
- [π¬ Demo Video](#-demo-video)
- [π’ News](#-news)
- [π TODO List](#-todo-list)
- [π Quick Start](#-quick-start)
- [Environment Requirements](#environment-requirements)
- [Installation](#installation)
- [Start Redis](#start-redis)
- [Prepare Video Streams](#prepare-video-streams)
- [Start the System](#start-the-system)
- [βοΈ Configuration](#οΈ-configuration)
- [Camera Fields](#camera-fields)
- [Global Fields](#global-fields)
- [Example](#example)
- [β¨ Features](#-features)
- [π¦ .so Delivery Version](#-so-delivery-version)
- [ποΈ Redis Data Format](#οΈ-redis-data-format)
- [π Performance](#-performance)
- [π Paper](#-paper)
- [π€ Hugging Face](#-hugging-face)
- [π Social Media](#-social-media)
- [π Citation](#-citation)
- [π License](#-license)
<br/>
## π¬ Demo Video
βΆοΈ [Click to watch the demo video](https://huggingface.co/buckets/OpenTraffic/opentraffic-perception-engine/resolve/opentraffic-perception-engine-main/videos/perception_raw.mp4)
<br/>
## π’ News
- **[2026/05/27]** Restructured README to align with unified English homepage style.
- **[2026/05/15]** Initial release of TIR, supporting real-time multi-direction intersection perception.
<br/>
## π TODO List
- [x] YOLO11 + DeepSort detection and tracking pipeline
- [x] Four-direction (E/S/W/N) data fusion
- [x] Homography matrix pixel β radar world coordinate transformation
- [x] Real-time Redis Stream writing
- [x] Hungarian algorithm cross-modal ID matching (vision β radar)
- [x] In-frame OCR timestamp extraction
- [x] Lane-level structured output
- [x] Radar-reference validation pipeline
- [ ] Release pretrained model weights to HuggingFace
- [ ] Support more intersection configurations
- [ ] Publish technical report / ArXiv paper
- [ ] Web visualization dashboard
- [ ] Support more camera protocols
<br/>
## π Quick Start
### Environment Requirements
| Item | Requirement |
|---|---|
| OS | Linux x86_64 |
| NVIDIA Driver | β₯ 560 |
| CUDA | 12.6 |
| Python | 3.13+ |
| PyTorch | 2.11.0+cu126 |
### Installation
```bash
# Clone the repository
git clone https://github.com/OpenTraffic-Team/opentraffic-perception-engine.git
cd opentraffic-perception-engine-main/opentraffic-TIR
# Install dependencies
pip install -r requirements.txt
```
### Start Redis
```bash
redis-server redis.conf
```
### Prepare Video Streams
**Use mediamtx to serve local video as RTSP:**
```bash
./mediamtx mediamtx.yml
```
**Or use VLC to stream:**
```bash
vlc video.mp4 --sout '#rtp{sdp=rtsp://:8554/test}'
```
**Or use a local video path directly:** Set the `rtsp_url` field in `drivers/config.json` to a local file path (e.g. `input/45_0429.mp4`).
> Test video: https://pan.baidu.com/s/1qULF2WcxUP_l5Cvs9uV-JA Password: 1234
### Start the System
```bash
./run_local.sh
```
Stop:
```bash
./stop_local.sh
```
<br/>
## βοΈ Configuration
Edit `opentraffic-TIR/drivers/config.json`.
### Camera Fields
| Field | Type | Description |
|---|---|---|
| `id` | string | Camera ID, format: `{intersection_id}_{direction}` |
| `rtsp_url` | string | RTSP URL or local video file path |
| `window` | `[x1, y1, x2, y2]` | Detection crop window; use `[0, 0, 1920, 1080]` for full frame |
| `H` | 3Γ3 matrix | Pixel β radar homography matrix |
| `H_inv` | 3Γ3 matrix | Radar β pixel inverse matrix (auto-computed from H if omitted) |
| `radar_variant` | string | Coordinate variant, default `"default"` |
| `radar_redis_key` | string | Redis key for this camera's output |
### Global Fields
| Field | Description |
|---|---|
| `debugMode` | Enable verbose tracking logs |
| `jsonlOutputDir` | JSONL output directory |
| `radarReferenceJsonl` | Radar reference file for validation |
| `matchTargetDir` | Radar JSON output directory for cross-modal ID matching |
| `matchTimeMaxDeltaMs` | Max timestamp matching tolerance (ms) |
| `vehicleMatchMaxDist` | Max vehicle center matching distance (meters) |
| `localRedisConfig.host` | Redis server address |
| `localRedisConfig.password` | Redis password |
| `data_processing.upload_interval_sec` | JSON merge and upload interval (seconds) |
### Example
```json
{
"intersection": {
"id": "HHL_QHDD",
"name": "Honghua Road",
"cameras": [
{
"id": "HHL_QHDD_S",
"rtsp_url": "./input/45_0429.mp4",
"window": [0, 0, 1920, 1080],
"H": [[...], [...], [...]],
"H_inv": [[...], [...], [...]],
"radar_variant": "default",
"radar_redis_key": "origin_info_state:HHL_QHDD"
}
]
},
"debugMode": false,
"jsonlOutputDir": "./control_group_fullspeed_jsonl",
"radarReferenceJsonl": "./reference_radar/HHL_QHDD_S/HHL_QHDD_S_shard_00000.jsonl",
"vehicleMatchMaxDist": 10.0,
"localRedisConfig": {
"host": "127.0.0.1",
"port": 6379,
"db": 0,
"password": "your_password"
},
"data_processing": {
"upload_interval_sec": 1
}
}
```
<br/>
## β¨ Features
### π Vehicle Detection
- Vehicle detection and multi-object tracking (YOLO11 + DeepSort) for intersection video.
- Compatible with RTSP streams and local video files.
- Recognition engine compiled to `.so` for acceleration; outputs structured target IDs for downstream use.
### πΊοΈ World Coordinate Output
- Projects image-space targets into world coordinates.
- Uses calibrated homography matrix (H / H_inv) for pixel-to-world mapping.
- Outputs radar-style coordinates for downstream integration.
### π¨ World Velocity Estimation
- Kalman-filter-based `SimpleVelocityEstimator` estimates target velocity in world coordinates.
- Outputs structured velocity fields (m/s) per tracked vehicle.
- Supports traffic state interpretation and speed comparison against radar reference.
### π£οΈ Lane-Level Output
- Associates detected targets with lane semantics.
- Generates lane-level structured results for consumption by control systems.
### π Timestamp Extraction
- OCR extracts timestamps from video frames for accurate temporal alignment.
### π Cross-Modal ID Matching
- Hungarian algorithm aligns visual targets with external radar data by ID.
<br/>
## π¦ .so Delivery Version
This section applies to the self-contained `.so` delivery package, which runs without the full source code.
### Included Resources
| Resource | Path |
|---|---|
| Input video | `input/45_0429.mp4` |
| Radar reference data | `reference_radar/HHL_QHDD_S/HHL_QHDD_S_shard_00000.jsonl` |
| Python environment | `.venv` |
| Start script | `run_local.sh` |
| Stop script | `stop_local.sh` |
### Running
Start:
```bash
cd /tir-0513-git-so
./run_local.sh
```
Stop:
```bash
cd /tir-0513-git-so
./stop_local.sh
```
### Output Format
Default output directory:
```
control_group_fullspeed_jsonl/HHL_QHDD_S/HHL_QHDD_S_shard_00000.jsonl
```
Output JSONL fields:
| Field | Description |
|---|---|
| `timestamp_ms` | Frame timestamp (milliseconds) |
| `intersection_id` | Intersection ID |
| `camera_id` | Camera ID |
| `source` | Data source |
| `coordinate_space` | Coordinate space |
| `vehicles[].id` | Vehicle ID |
| `vehicles[].center` | Vehicle center coordinates (meters) |
| `vehicles[].speed` | Velocity vector (m/s) |
| `vehicles[].speed_scalar` | Speed scalar (m/s) |
| `vehicles[].lane` | Lane |
| `vehicles[].type` | Vehicle type |
<br/>
## ποΈ Redis Data Format
Results are written to two Redis keys:
- **Snapshot**: `recognition_{camera_id}_snap`
- **Stream**: `recognition_{camera_id}`
Merged four-direction snapshot format (`origin_info_state:{intersection_id}`):
```json
{
"code": "HHL_QHDD",
"name": "Honghua Road",
"recognitionSnap[HHL_QHDD_E]": {
"timestamp": 1734400000.0,
"vehicles": [
{
"id": "42",
"orig_id": "7",
"type": "",
"lane": "",
"center": [12.5, 8.3],
"speed": [3.2, -1.1],
"licenseNum": ""
}
]
}
}
```
| Field | Description |
|---|---|
| `timestamp` | Frame timestamp in seconds (extracted via OCR) |
| `id` | Target ID after radar matching |
| `orig_id` | Original visual tracking ID (before matching) |
| `center` | World coordinates `[x, y]` in meters |
| `speed` | Velocity components `[vx, vy]` in m/s |
| `type` | Vehicle type (if available) |
| `licenseNum` | License plate number (if available) |
<br/>
## π Performance
> Evaluation: historical full-set speed JSONL vs. raw radar JSONL.
### Field Error Comparison
| Field | Mean | Median (p50) | p75 | p90 | Notes |
|---|---|---|---|---|---|
| `timestamp_ms` error (ms) | 25.04 | 26.5 | 37 | 46 | Time delta between video frame and nearest radar frame |
| `vehicles[].center` error (m) | 2.5132 | 1.6251 | 3.1987 | 6.7021 | Spatial position error of matched targets |
| `vehicles[].speed_scalar` error (m/s) | 1.6727 | 0.3176 | 1.7741 | 5.0061 | Speed scalar error of matched targets |
### Field Consistency
| Field | Comparison | Consistency |
|---|---|---|
| `intersection_id` | Exact match | **100%** |
| `camera_id` | Exact match | **100%** |
| `coordinate_space` | Exact match | **100%** |
| `timestamp_ms` | Aligned within 200ms | **100%** |
| `vehicles[].lane` | Exact match with radar | **100%** |
<br/>
## π Paper
- Title: `OpenTraffic Perception System for Perception-Driven TSC`
- Status: `In preparation / pending release`
- Placeholder: `https://arxiv.org/abs/XXXX.XXXXX`
<br/>
## π€ Hugging Face
- Model page: `https://huggingface.co/OpenTraffic-Team`
- Planned releases:
- Packaged perception model
- Sample output results
- Benchmark examples
<br/>
## π Social Media
- GitHub: `https://github.com/OpenTraffic-Team/Tir`
- WeChat Group: [Join Discussion](https://github.com/OpenTraffic-Team/Tir/issues/1)
- X / Twitter: `Coming soon`
<br/>
## π Citation
If TIR is useful for your research, please cite:
```bibtex
@article{tir2026,
title = {TIR: Real-Time Traffic Situation Awareness for Urban Intersections},
author = {OpenTraffic Team},
journal = {arXiv preprint},
year = {2026}
}
```
<br/>
## π License
This project is released under the [Apache 2.0 License](LICENSE).
---
<div align="center">
<b>OpenTraffic Team</b> | Making urban traffic smarter.
</div>
|