Analysis updated 2026-05-18
Build a single camera distance sensor for a robotics or automation project.
Learn how to send sensor data from a camera to a microcontroller over serial.
Study a working example of camera to microcontroller to screen data flow.
Use as a starting template for a custom embedded vision measurement tool.
| ocfh/monocular-ranging-maixcam-stm32-tjc-screen | alphapixel/eric-graham-1987-juggler-raytracer-1.0 | peng-zhihui/x-cube-usb-pd | |
|---|---|---|---|
| Stars | 55 | 54 | 56 |
| Language | C | C | C |
| Last pushed | — | — | 2018-02-14 |
| Maintenance | — | — | Dormant |
| Setup difficulty | hard | hard | hard |
| Complexity | 4/5 | 2/5 | 5/5 |
| Audience | developer | general | developer |
Figures from each repo's GitHub metadata at analysis time.
Requires assembling and wiring three separate hardware devices and calibrating the distance formula physically.
This repository documents a hardware project that measures distance using a single camera, rather than two cameras or a laser sensor. It combines three components: a MaixCam smart camera running Python and OpenCV, an STM32 microcontroller, and a small serial touchscreen made by a company called Tojiang. The system detects a black rectangular object in the camera's view, works out its distance from the camera using triangle geometry, then sends that measurement over a serial cable to the microcontroller, which forwards it to the screen for display. On the camera side, the code isolates black shapes using color thresholding, filters out noise, and sorts the four corners of a detected shape so it can correct for tilt using a perspective transform. Once the shape is aligned, it calculates distance based on how large the object appears in pixels compared to its known real world size. To avoid overwhelming the microcontroller with data, the code only sends an update when the distance has been stable for over 200 milliseconds and the pixel width has changed by more than 3 pixels, filtering out small jitters. Data travels between devices using a small custom text protocol that looks like $D:distance,W:width,H:height#, with a dollar sign marking the start of a message and a hash mark ending it, making it easy for the microcontroller to find message boundaries in a stream of serial data. The STM32 firmware listens for these messages over UART, parses out the numbers, and checks that they are valid before passing them along to the screen. The project folder is organized into a working camera test area, the finished camera script, the STM32 firmware project for Keil, the screen design files, and a folder of photos showing the assembled hardware. Setup requires physically wiring the camera, microcontroller, and screen together, flashing code to each device separately, and calibrating the measurement formula using a known object and a known distance beforehand. It is aimed at electronics hobbyists and students building embedded vision systems rather than general software developers, and assumes familiarity with microcontroller development tools.
A DIY vision system that uses a single smart camera to measure distance to an object, then shows the reading on a small serial screen via a microcontroller.
Mainly C. The stack also includes Python, OpenCV, NumPy.
The repository includes a LICENSE file but the explanation does not state its terms.
Setup difficulty is rated hard, with roughly 1day+ to a first successful run.
Mainly developer.
This repo across BitVibe Labs
Verify against the repo before relying on details.