A computer-vision cat deterrent — a Raspberry Pi watches the counter, recognizes a cat in real time, and triggers a servo-driven puff of air from a 3D-printed, fully parametric stand.

Overview
Cat Countermeasure keeps cats off the kitchen counter without anyone having to be there. A Raspberry Pi 4 with a Pi Camera watches the protected area and runs an on-device object-detection model. When it's confident a cat is in view, an MG996R servo presses the nozzle of a compressed-air can for a short, startling burst — then backs off.
Everything is custom: a nine-part 3D-printed stand generated from a parametric Fusion 360 script, an adjustable camera mast with a tilt pivot, a servo carriage that slides to fit different cans, and a hardened Python service that runs unattended at boot.
Key Features
Challenge
A device that acts on its own in a home has to be right, and has to be safe. One-frame false positives from a cushion or a shadow can't trigger it, a cat that sits still can't empty the can, and it must never fire while a person is nearby. The hardware had to print without supports on a standard bed, hold the can upright, route a short camera ribbon cleanly, and stay quiet and harmless at rest — even if the software crashes.
Solution
I wrote the controller as a tested Python package. EfficientDet-Lite0 runs on LiteRT directly on the Pi, and a trigger engine requires a cat in 3 of the last 5 frames, then enforces a cooldown, a per-visit burst cap and an hourly limit. People always win: a person seen anywhere in the frame at a lower confidence bar blocks spraying and aborts a burst mid-press. The servo runs on hardware PWM with every exit path — normal finish, error, shutdown or the physical ARM switch — returning it to rest, and systemd's watchdog and an ExecStopPost hook park it even after a crash. The stand is generated by a parametric Fusion 360 script: change the can's diameter or height and every part regenerates, with a jointed assembly and scripted motion renders. A calibration CLI, a dry-run mode that logs and snapshots without moving the servo, and a frame-by-frame debug view make it easy to tune on site.
Results
The result is a self-contained, set-and-forget appliance: it boots straight into watching, explains every decision in its logs, and recovers on its own from camera drop-outs and hangs. Detection, trigger rules, burst timing and the full camera-to-servo loop are covered by unit and end-to-end tests, and the whole stand prints on a 220 mm bed with no supports.
In Motion
Gallery


