# automaticdai/rpi-object-detection: a Raspberry Pi OpenCV reference for eight detection demos

> This MIT-licensed Python repository collects camera tests, motion detection, colour, shape, ORB and face tracking plus YOLO and TensorFlow Lite demos for Raspberry Pi. It is a teaching scaffold, not a packaged library, and the README is thinner than the script list suggests.

**automaticdai/rpi-object-detection** — Real-time object detection and tracking with Raspberry Pi and OpenCV!

- Repository: https://github.com/automaticdai/rpi-object-detection
- Stars: 312 · Forks: 70
- Language: Python
- License: MIT
- Published: 2026-09-17 · Updated: 2026-09-17 · Language: en
- Canonical page: https://hysenlabs.com/projects/automaticdai-rpi-object-detection

## What rpi-object-detection actually gives you

The README frames the project as "a starting point for using RPi & CV in your own DIY / maker projects". That wording is accurate about the scope. You are not installing a library with a stable import surface; you are cloning eight small applications that each demonstrate one technique against a live camera feed.

The intended audience is a maker or student with a Raspberry Pi and a camera who wants to see a detection loop run end to end before writing their own. The README argues the case for cameras over other sensors directly: computer vision "allows you to track complicated objects that would otherwise not be possible with other types of sensors (infrared, ultrasonic, LiDAR, etc)". If your problem is "is something moving in this frame" or "where is the red object", the classic OpenCV scripts here answer it without a neural network or a model download.

The repository is also explicitly cross-platform. The README notes the code is Python and OpenCV, so it runs on x86/x64 PCs, IPCs, Jetson boards, Banana Pi, BeagleBoard and similar Linux hardware. The Raspberry Pi is the target, not a hard requirement, which matters when you want to prototype on a laptop before moving to the Pi.

## The eight src directories and the pipeline behind each one

The repository layout is one directory per technique under src/: camera-test, motion-detection, object-tracking-color, object-tracking-shape, object-tracking-feature, face-detection, object-detection-yolo and object-detection-tflite. Each is a standalone script, so there is no shared module to learn and no configuration file spanning the project.

Motion detection is the only pipeline the README describes in detail, and the description is worth reading because it is the template the other scripts follow. Current and previous frames are converted to grayscale, Gaussian-blurred to suppress sensor noise, then compared with a per-pixel cv2.absdiff. The diff is thresholded and dilated, then passed through cv2.findContours. Only connected regions with area at or above MIN_MOTION_AREA count as motion, and MOTION_CONSECUTIVE_FRAMES acts as a debounce that rejects one-frame transients. Every threshold sits as a constant at the top of the script, which the README presents as a deliberate trade: you tune sensitivity against false positives without editing the loop.

The other directories lean on standard OpenCV calls. Shape tracking uses cv2.HoughCircles() for circles and cv2.findContours() plus cv2.approxPolyDP() for triangles and rectangles, with MIN_CONTOUR_AREA filtering small contours and the approximation epsilon and Canny thresholds configurable at the top of the script. Feature tracking uses ORB, chosen, the README says, for calculation speed to enable real-time detection. Face detection uses a Haar cascade. Colour tracking works in HSV and lets you click the object to build a colour range, which you can then hard-code so you do not repeat the picking step on the next run.

The two neural directories are different in kind. object-detection-yolo is built on Ultralytics YOLO and the README points to Ultralytics' own "Quick Start Guide: Raspberry Pi with Ultralytics YOLO11" for instructions rather than reproducing them. object-detection-tflite is the TensorFlow Lite path. Both are marked in the README as RPi 3/4/5 only.

## Installing on a Raspberry Pi and running the first script

The repository ships an install.sh at the top level and a requirements.txt listing matplotlib, numpy, opencv-contrib-python, opencv-python, packaging, pillow, pyparsing, python-dateutil, scipy, six and ultralytics. The README's install section is titled "Install the environment" and the script is the intended entry point. Run it from the repository root:

```bash
bash install.sh
```

If you prefer to install the dependencies yourself, requirements.txt is the manifest. Expect a long build on a Pi Zero or Pi 2, because opencv-contrib-python and ultralytics are the heavy entries:

```bash
pip install -r requirements.txt
```

Confirm the camera and OpenCV environment before anything else. The camera-test directory is exactly for this, and the README says you should see a pop-up window with video from your USB camera if the setup is correct. If the window does not appear, check both the environment and the camera connection. The README does not give the script filename, so list the directory first:

```bash
ls src/camera-test
```

Once video appears, the next step is the motion script, since it needs no model and no colour calibration. The README does not print the filename for this directory either, so check it the same way:

```bash
ls src/motion-detection
```

If frames are slow, the README's remedy is to reduce the camera resolution, naming 160 x 120 as the fallback for weaker boards. The exact key or flag for that is in the individual script rather than in a shared config, so open the file you are running and look for the resolution setting near the top.

## Where the board choice and the missing releases bite

The README is unusually direct about hardware limits, and it is the strongest part of the documentation. Raspberry Pi 1 Model B, Pi 2, Pi Zero and Pi 3/4/5 are all listed as supported, with the caveat that "different boards will have very varied performances". The README calls Pi 3/4/5 preferable because of their CPUs and says Pi 1/2 "may be struggling and produce very low FPS". Both neural directories, YOLO and TensorFlow Lite, are restricted to Pi 3/4/5 only.

That restriction is the honest boundary of the project. If you are holding a Pi Zero or a first-generation Model B and your goal is neural object detection, this repository will not get you there; the classic OpenCV scripts are what remain available, and even those may need the 160 x 120 resolution fallback. The README does not publish FPS figures for any board, so you cannot size a deployment from the documentation alone.

The second limitation is packaging. The repository has no releases, no version tags and no published package, so there is no pinned version to depend on and no changelog to read before upgrading. A clone is a snapshot of master. The last push was on 2026-04-18. The README also does not document rollback, a supported Python range beyond "Python >= 3.6.9", or how the scripts behave when OpenCV is upgraded underneath them. Treat the code as a reference you fork and own, not as something you track upstream.

## rpi-object-detection versus a general YOLO deployment

The obvious alternative for anyone searching for YOLO on a Pi is to skip this repository and follow the Ultralytics Raspberry Pi guide directly, which is in fact what the README tells you to do for the YOLO directory. The difference in approach is real. Ultralytics gives you an installable Python package with a documented model API, model export and a maintained release cycle. This repository gives you a single script that calls that package and shows the surrounding camera capture and display loop.

Which one you want depends on what you are missing. If you already know how to open a camera with Picamera2 or cv2.VideoCapture and draw boxes on frames, the Ultralytics guide is the shorter path and you inherit their support. If you are new to the capture side, this repository's value is the eight worked examples of frame handling, thresholding and contour work that sit around the model call, plus the non-neural techniques you may not have considered. Motion detection with cv2.absdiff costs almost nothing compared to a YOLO inference pass, and for many maker projects it is enough.

The trade is maintenance. Ultralytics is a company-backed project with releases; this is a personal reference repository whose last push was on 2026-04-18. Choosing it means choosing to maintain your fork.

## Licence, dependencies and what an upgrade costs

The repository is MIT licensed, which is permissive and imposes few obligations beyond retaining the copyright notice and permission text. That covers the code in this repository. It does not cover the models or the libraries you pull in alongside it, and the README raises that point itself for the YOLO directory: it advises you to "double check if you need to use it in a commercialised project". Ultralytics YOLO is distributed under its own terms, which are not the same as MIT, so a commercial deployment needs its own review of that dependency. This is a description of the licensing situation, not legal advice.

Upgrade cost is dominated by the dependency list. requirements.txt pins nothing, so a fresh pip install -r requirements.txt resolves to whatever is current, and opencv-python, opencv-contrib-python and ultralytics all move quickly. There is no lock file and no recorded combination of versions known to work. If you need reproducibility, freeze the resolved versions yourself after the first successful install.

Because there are no releases, there is also no upgrade path in the conventional sense. Updating means pulling master and diffing the scripts you have modified against the new versions, by hand. If you have already tuned thresholds in your copies, that diff is the real cost.

## Conclusion

Adopt this repository if you want a working reference for Raspberry Pi OpenCV pipelines and intend to read and edit the scripts rather than import a package. Do not adopt it if you need a documented API, versioned releases or a maintained abstraction layer: there are no releases and the last push was on 2026-04-18. Before building on it, open the script for the demo you care about and confirm the thresholds at the top of the file match your camera and lighting, since the README exposes only MIN_MOTION_AREA, MOTION_CONSECUTIVE_FRAMES, MIN_CONTOUR_AREA and the Canny and epsilon settings by name.

## FAQ

### Can I use YOLO on my Raspberry Pi with rpi-object-detection?

Yes, but only on Raspberry Pi 3, 4 or 5. The README marks the object-detection-yolo directory as RPi 3/4/5 only and points to the Ultralytics Raspberry Pi guide for the YOLO setup itself.

### Can a Raspberry Pi run LiDAR for object detection?

The repository does not cover LiDAR. Its README mentions LiDAR only as a contrasting sensor type, arguing that camera-based computer vision can track objects that infrared, ultrasonic or LiDAR sensors cannot handle.

### Is the Raspberry Pi 5 overkill for rpi-object-detection?

The README does not address cost or overkill. It lists Raspberry Pi 3/4/5 as preferable because of their more powerful CPUs and says Pi 1/2 may struggle and produce very low FPS.

## Sources

- [automaticdai/rpi-object-detection on GitHub](https://github.com/automaticdai/rpi-object-detection)
- [Issues](https://github.com/automaticdai/rpi-object-detection/issues)
- [License: MIT](https://github.com/automaticdai/rpi-object-detection/blob/master/LICENSE)
- [README](https://github.com/automaticdai/rpi-object-detection/blob/master/README.md)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/automaticdai-rpi-object-detection
