NerfSentry
The turret is a foam dart cannon I rescued from the trash. It has a USB HID interface that was never meant to be programmed by anyone outside the factory. A Logitech C615 webcam is hot-glued on top. Together they track movement, follow people across the room, and then wait for a human to say “fire.”
Tracking is automatic. Firing needs a human in the loop.
How it sees
OpenCV does the detection. A HOG people detector finds humans in the frame, and a background subtractor catches movement. Because the camera is mounted on the turret, the whole visual field shifts every time the turret moves, and a naive detector reads that as motion. So the background model resets after each motor command, and a settling timer lets the image stabilize before detection starts again. I only found that out once it was on my desk, spinning in circles, convinced the wall was an intruder.
How it moves
PyUSB sends HID commands to the turret’s vendor interface. The protocol is simple — directional movement, stop, fire — but the hardware has quirks:
- USB sends throw EIO errors (errno 5) that look fatal but aren’t. The commands land anyway.
- Three of the four limit switches are detectable through the protocol. The right one isn’t. At the right edge the turret just stops responding to right-move commands, and the software has to treat that silence as the boundary.
- There’s no “fire” command. You run the firing motor until it pops and sends a missile flying.
- The fire motor needs an explicit stop command after its cooldown period, or it keeps spinning indefinitely.
- Full-size nerf darts don’t fit the barrels, so they limp a few inches when fired. A few rounds of electrical tape seems to have fixed that.
The interface
It’s a single-page web app, neon green on black. There’s no framework, just HTML, CSS, and enough JavaScript to pipe the MJPEG stream and wire up the controls. It looks like a hacker’s terminal in a movie, which seemed right for a foam dart turret with computer vision.
Flask serves the stream and a REST API: connect, disconnect, nudge in any direction, stop, and fire. Camera controls (zoom, focus, exposure, resolution switching) are wired in too. Because the stream is MJPEG, it’s just an <img> tag that keeps updating. It’s simple and it works everywhere.
The voice challenge
When the sentry locks onto someone and centers on them, it says something first: “Halt. Who goes there?” or “Identify yourself.” The challenge goes to a text-to-speech endpoint on the network (it defaults to the OpenAI-style speech API), runs in a background thread so the aim loop never stalls, and has a cooldown so it doesn’t repeat itself. Centering on a target never fires the turret. The aim loop stops, issues the challenge, and waits for a person to press the button.
The tests
Twenty-three tests cover the turret protocol, the targeting math, and the voice challenge. They run against DummyTurret and DummyCamera, mock hardware interfaces that let you develop and test without the physical turret plugged in. The real turret is plugged into a server and keeps watch over it.
Where it stands
It’s about 1,100 lines of Python and a 500-line HTML page, six commits from March to April 2026, all of them co-authored with Claude. Right now it runs in Docker on a dev machine, with the USB device passed through to the container. The scanner-station design in TallyStow grew out of this project. For cataloging you want the object to move, not the camera, so it swaps the turret for a turntable.
Where it’s going
The plan is to move it to a Raspberry Pi, which is small enough to mount somewhere interesting and powerful enough to run the detection loop. There’s also a sketch for VLM-based detection through Ollama on the GPU infrastructure, trading the HOG detector’s speed for a vision-language model’s judgment on questions like “is that a person or a coat on a chair?”
Why this exists
Because the process is the point. None of this needed to happen: reverse-engineering a USB HID protocol, tuning a motion detector mounted on the thing it’s trying to hold steady, building a cyberpunk UI for a toy that shoots foam. All of it was worth doing. So far it hasn’t fired without permission.