OpenTraffic commited on
Commit
e982b42
Β·
verified Β·
1 Parent(s): d5e25a0

Create README.md

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