Download Resume
Approach
Extends Level 7's tracking with per-vehicle speed estimation and a structured data extraction pipeline.
# Pixel displacement between tracked positions / calibrated pixels-per-meter / elapsed time
pixel_dist = ((x_new - x_old)**2 + (y_new - y_old)**2) ** 0.5
meters_per_sec = (pixel_dist / PIXELS_PER_METER) / seconds
mph = meters_per_sec * 2.23694

Explicitly stated as an approximation — true speed requires real camera calibration (e.g., a surveyed lane-width reference), which is stated both in the on-screen video overlay and in terminal output. That honesty is a deliberate part of the narrative: an uncalibrated number presented as precise would undermine credibility the moment someone asks how it was calibrated.

Visual feature: bounding boxes turn red above a configurable mph threshold, green at or below it — recalculated fresh every frame per vehicle, so it toggles live and accurately reflects current speed.

The "Total vehicles tracked" figures below (e.g. 46 in clip 1) are unique track IDs from the same BoT-SORT tracker as Level 7, not a verified physical count — an upper bound, since an occluded vehicle that gets reacquired under a new ID is counted twice. See Level 7 for the full explanation and the production alternative (line-crossing / zone counting).
Real output: clip 1
A sample of the actual per-vehicle rows from this run (47 vehicles tracked total).
IDClassAvg MPHMax MPHMin MPHFramesOver threshold
1car14.123.23.174YES
16car15.324.32.374YES
20bus4.828.70.0147YES
26car18.224.212.149YES
45car17.232.36.579YES
48truck12.522.33.266YES
67car3.68.70.0128no
71car31.333.129.67YES
Clip 1's speeds look like real highway traffic — mostly single digits to low 30s mph. Clip 4, from a different camera angle, reads wildly implausible speeds for the exact same code and math — one vehicle averaging 157 mph, another peaking past 275 mph:
IDClassAvg MPHMax MPHMin MPHFramesOver threshold
8car61.0121.019.577YES
11car99.7206.91.842YES
120car121.8163.081.413YES
139car157.5193.6108.610YES
154car133.3155.178.719YES
157car126.0275.562.37YES
176car118.8243.250.348YES

No camera calibration in either case. That gap is the clearest possible demonstration of why an uncalibrated pixel-to-mph conversion is an approximation, not a measurement — clip 4 flags 158 of its 167 tracked vehicles (95%) as "over threshold," versus 0 of 10 in clip 3, the slowest/most static of the four.

↓ speed_data1.csv (clip 1, realistic) ↓ speed_data4.csv (clip 4, uncalibrated)
Demo Clips
Four tracked clips, in order. Clip 1 matches the realistic speed data above; Clip 4 matches the wildly implausible speed data above.
1

Terminal output

--------------------------------------------------------------------------------
Total vehicles tracked: 46
Vehicles exceeding 10mph threshold: 40
Saved annotated video as output_speed1.mp4
Saved speed data table as speed_data1.csv
2

Terminal output

--------------------------------------------------------------------------------
Total vehicles tracked: 21
Vehicles exceeding 10mph threshold: 20
Saved annotated video as output_speed2.mp4
Saved speed data table as speed_data2.csv
3

Terminal output

--------------------------------------------------------------------------------
Total vehicles tracked: 10
Vehicles exceeding 10mph threshold: 0
Saved annotated video as output_speed3.mp4
Saved speed data table as speed_data3.csv
4

Terminal output

--------------------------------------------------------------------------------
Total vehicles tracked: 167
Vehicles exceeding 10mph threshold: 158
Saved annotated video as output_speed4.mp4
Saved speed data table as speed_data4.csv
Data extraction pipeline

The video isn't just producing a visual — it's extracting structured, exportable data per object, exactly the kind of output a real manufacturing or logistics deployment would need to feed into a dashboard or reporting system.