Ozan Güven

iMotion

Car speed camera built on macOS Continuity integration

A computer vision-based speed camera using an iPhone to detect, track, and estimate vehicle speeds in real time.

Category
project
Year
2026
Tools
Python, OpenCV, Ultralytics YOLO, macOS Continuity Camera
Status
Finished but admittedly unpolished

Overview

I was inspired by a viral tweet in which a Chinese student turned an old system camera into a traffic speed camera. I thought it was interesting and wanted to give it a shot myself. Though, I had a few hurdles I needed to overcome:

Unlike the original setup, my camera positioning had to be angled because it doesn't face the road directly, and I had a large tree between my camera and the road, right in the middle of the view.

Full camera view with the tree in the middle, tracked cars and a debug readout of frame rates

Approach

The system was built in Python using OpenCV and Ultralytics YOLO for vehicle detection and tracking. I used my iPhone's camera feed to capture video and supply it wirelessly through macOS Continuity Camera.

To calculate vehicle speeds, there is a visual calibration system based on known physical measurements of the road. By selecting the corresponding points in the camera image and mapping them to their real-world positions, I could establish a relationship between coordinates in the image and physical distances using perspective transformation (homography).

Detected vehicles were then tracked across frames, allowing their movement through the image space to be translated to real-world distances over time. These measurements were then used to estimate vehicle speeds in km/h.

I did also add additional functionality like trajectory prediction so the feed would look stable even when cars became unrecognizable behind the tree, but I ended up removing that because it was inaccurate too often. Since the cars are obstructed for such a short period of time, I doubt that they would manage to make any considerable changes in speed that wouldn't be caught before or after the occlusion.

Calibration view with four corner points marked on the road
Calibration: selecting points in the image that correspond to known positions on the road.
Close-up of tracked cars, one moving at 36 km/h and parked cars at 0 km/h

Outcome

The result was a fucntional traffic speed camera that could detect and track vehicles and estimate their speeds from a wireless, live iPhone camera feed.

However, this is one project where if I do find reason or time I would absolutely want to get back to it in order to improve things like stability and speed accuracy.

The reason that I haven't done that already is because my setup makes both the development and user experience a bit more troublesome than the original setup that I was inspired by.