r/computervision • u/shravanrevanna • Oct 08 '26
Showcase Turned a stock Xiaomi pan/tilt camera into a local object tracker that runs at 0.5Hz
The most useful thing I learned building this: my camera has about 1.4 seconds of dead time between a move command and the picture actually moving.
Setup is a Xiaomi MJSXJ10CM on the firmware it shipped with (4.5.6_0450). I didn't flash it or exploit it. go2rtc v1.9.14 with the go2rtc-xiaomi-control patch gets 1080p HEVC over the LAN, and the pan/tilt motor takes a MISS command with a payload of 1 to 4 for left, right, up and down.
The camera replies acknowledged: true to every command, but that only means it heard you. So I measured the frames instead. I grabbed a frame, sent one step, grabbed another, block-matched to estimate the shift, and compared that against a no-move baseline. Left moved about 40px and right about 36px, so the steps aren't symmetric. Each step shifts the picture 8 to 12% of the frame.
Then I sampled frame difference every 200ms after a single command. I saw nothing at 823ms, movement at 1331ms, and it was settled by 1824ms. Video comes in at 12fps, so a naive tracker would fire about fifteen more commands before the first one lands. The fix is to ignore everything for 2 seconds after each command and use a dead zone of 0.18, which is wider than one step's displacement. Make it any tighter and it oscillates forever.
Detection uses Apple's Vision framework through a ~150-line Swift helper (10 to 30ms, no dependencies), with optional SSD-MobileNetV1 ONNX for the 80 COCO classes.
Two traps cost me time. That ONNX graph returns zero detections, with no error, if you feed it a pre-shrunk 300x300 image. It works fine at native 1280x720. And Vision uses a bottom-left origin, so if you get the flip wrong, tilt inverts and the camera runs away from the target.
In testing, a dragged box around a chair went from 0.76 centring error to 0.21 in 3 steps.
Full write-up with the details: https://blog.shravanrevanna.me/reverse-engineering-a-xiaomi-camera-into-a-self-tracking-robot