OpenTraffic commited on
Commit
c54e91f
·
verified ·
1 Parent(s): 5655c90

Create README.md

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