Inspiration
We started out wanting to build a litter heatmap: point AI at public cameras and show where trash builds up, so cities could target cleanup. It didn't hold up. Litter is small and varied, public cameras are too low-resolution and too far away to see it reliably, and there was no labeled data to train or check a detector. We couldn't have stood behind the numbers.
While researching cameras for that idea, we found Caltrans' network of live, public traffic cameras across California. They were clear, steady and pointed at exactly the thing they capture best: vehicles. That changed the question. Cars are one of the biggest sources of urban emissions, and these cameras already watch busy intersections around the clock, but all they show is what a junction looks like.
So we asked: what does the traffic passing through mean for tailpipe emissions, and what evidence supports that number? The litter idea also gave us the rule we built everything around: only show a number we can check.
What it does
Emission Lens watches live Caltrans cameras in Torrance, California, detects and tracks every vehicle, and turns the ones that drive through a measured stretch of road into estimated tailpipe CO₂ and NOₓ, minute by minute.
Two cameras are live: 222 (SR-107 at Carson Boulevard) and 223 (SR-107 at Torrance Boulevard). We tested four. Two passed validation; two undercounted by 29% and 42%, so we left them out instead of showing numbers we knew were wrong.
The dashboard shows a satellite map with an emissions overlay, live camera status, traffic and emissions per minute, a "shorter stops" what-if scenario, and a draft brief for city staff to review. A minute without enough evidence shows "insufficient evidence", never zero. These are estimates of what vehicles emit, not measurements of air quality.
How we built it
1. Reading the video. A Python worker reads each camera's HLS stream at 15 frames per second. The video arrives in bursts of about 10 seconds, so frames are timed by the video's own clock rather than when they arrive.
2. Detecting and tracking. Pretrained YOLO11 finds cars, trucks, buses and motorcycles, running live on an Empire AI H100 GPU slice at about 4–5 ms per frame. ByteTrack links the boxes across frames into one vehicle with a temporary ID.
3. Counting. A vehicle is counted once when the bottom-centre of its box crosses a drawn line, so a car seen in 50 frames counts as one car.
4. Measuring distance. To turn pixels into metres, we matched road markings (crosswalk corners, stripe ends, lane-line ends) between each camera frame and aerial imagery, and fitted a homography: a transform from image points $(u, v)$ to ground points $(X, Y)$ in metres,
$$ \begin{bmatrix} X \ Y \ 1 \end{bmatrix} \sim H \begin{bmatrix} u \ v \ 1 \end{bmatrix}, \qquad H \in \mathbb{R}^{3 \times 3}. $$
We fitted $H$ on most points and held the rest back as a test. Held-back points landed 1.41 m (camera 222) and 1.08 m (camera 223) from their true positions on average. We then drew an entry line at an exact ground distance from the counting line: 20.0 m on 222 and 15.0 m on 223.
5. Calculating emissions. A vehicle that crosses both lines is a completed trip with distance $d$ and time $t$, which includes any stops. Its average speed is
$$ \bar{v} = \frac{d}{t}. $$
We look up California's official CARB EMFAC2025 running-exhaust rate $r_{p,k}(\bar v)$ for pollutant $p$, vehicle category $k$ and that speed (Los Angeles, 2026, in g/km). Each detected class $c$ maps to CARB categories with mileage shares $w_{c,k}$. Minute $m$'s estimate sums over its completed trips:
$$ E_{p,m} = \sum_{i \in m} d_i \sum_{k} w_{c_i,k}\, r_{p,k}(\bar{v}i), \qquad \sum{k} w_{c,k} = 1. $$
CARB's running rates already include normal stops at lights, so we deliberately don't add a separate idle term, which would count idling twice.
6. Stopped time. A vehicle counts as stopped when its box moves less than a per-camera threshold $\tau$:
$$ \frac{\lVert \mathbf{p}t - \mathbf{p}{t-1} \rVert}{\Delta t} \le \tau. $$
We fitted $\tau$ against ground speed from the calibration (under 0.5 m/s stopped, over 1.5 m/s moving). It agrees about 95% of the time on both live cameras. It powers the "shorter stops" scenario.
7. Serving it. A TypeScript backend checks every batch and applies only approved calibrations and class mappings. A Next.js and MapLibre dashboard shows the results. Live, replay and test data never mix.
Challenges we ran into
Frame rate mattered more than model size. At 5 frames per second, cars in heavy traffic moved too far between frames, tracks broke, and counts were up to 59% low. At 15 frames per second, the same line matched a hand count exactly.
Fine-tuning didn't win. We labeled 400 frames and fine-tuned YOLO for pickups, box trucks and Teslas. On 60 human-labeled held-out frames, it scored 83% F1 against the pretrained model's 90%, so we kept pretrained. Our training set was too small and lopsided: mostly cars, few trucks, no tractor-trailers.
Two of four cameras failed. On camera 220 the counting line sits on a stop bar, where queued cars jitter and tracks break. On 228, vehicles are small and far from the camera; moving the line, a larger model and higher resolution didn't close the gap.
Calibrating a tilted camera. Some views have few clear road markings near the camera. Any point on a car, on bare asphalt or under the camera's text overlay was rejected, and we recorded why.
Accomplishments that we're proud of
We counted crossings on held-out footage before turning any camera on. Recall is the share of real vehicles we counted; precision is the share of our counts that were real:
$$ \text{recall} = \frac{TP}{TP + FN}, \qquad \text{precision} = \frac{TP}{TP + FP}. $$
| Camera | Checked against | Recall | Precision | Total count error |
|---|---|---|---|---|
| 222 | Our own hand count, crossing by crossing | 92.4% | 91.0% | +1.5% |
| 223 | Automated assisted review | 91.9% | 96.9% | −5.2% |
The full pipeline runs live from camera to GPU to dashboard, producing real per-minute CO₂ and NOₓ estimates, and every number links back to its evidence and source versions.
What we learned
The most useful environmental number is one someone can question. Timing, which vehicles were observed, segment distance, vehicle-class assumptions and factor versions all change what a number means, so showing them is part of the product.
We also learned to measure before claiming. Our biggest gains came from testing (the frame-rate fix, the held-out checks) rather than from bigger models, and the most honest result we have is choosing to leave two cameras out.
What's next for Emission Lens
- Bring cameras 220 and 228 back through a fresh validation round with relocated lines; their calibrations are already done.
- Measure segments that include the stop bar, where shorter stops would show real savings.
- Replace our assumed sedan/SUV split with CARB mileage shares.
- Run continuously with hosted storage, and adapt it to other public camera networks.