0f423fccd635f598f7540561cfcd4821bba3b52d
- capture.py: detect faces with haar cascades (cv2.CascadeClassifier), draw green rectangles on frames before streaming - capture/haarcascades/: bundled haar cascade XML - README.md: document face detection feature and opencv dependency
usb-camera-webui
Live MJPEG video feed from a USB webcam, served through a minimal web UI, running on a Raspberry Pi 5.
Quick start
# Install dependencies
sudo apt install -y python3-opencv python3-v4l2
# Run directly
python3 -m camera.app --host 0.0.0.0 --port 8080
Open http://localhost:8080 in a browser. Faces visible in the camera view are marked with green rectangles.
Systemd service
The app runs natively on the Pi via a systemd unit.
Install
# Install dependencies
sudo apt install -y python3-opencv python3-v4l2
# Copy the service unit
sudo cp camera-webui.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now camera-webui
Check status
sudo systemctl status camera-webui
journalctl -u camera-webui --follow
Uninstall
sudo systemctl disable --now camera-webui
sudo rm /etc/systemd/system/camera-webui.service
sudo systemctl daemon-reload
Architecture
┌──────────────┐ ┌──────────────┐ ┌──────────┐
│ V4L2 mmap │───▶│ capture.py │───▶│ MJPEG │
│ (V4L2 API) │ │ + face det. │ │ server │
└──────────────┘ └──────────────┘ │ :8080 │
└──────────┘
│
┌─────▼─────┐
│ Browser │
│ (MJPEG img)│
└───────────┘
capture.pyopens/dev/video0via V4L2 mmap buffers, dequeues MJPEG frames in a background thread, runs face detection (haar cascades, downscaled for speed), draws green rectangles, and stores the processed frame.mjpeg.pyserves the MJPEG stream (multipart/x-mixed-replace) via Python's built-inhttp.serverwith threading. Only new frames are sent.app.pyis the entry point: argument parsing, signal handling, and server launch.
Hardware
| Item | Details |
|---|---|
| Camera | Logitech C505 HD Webcam (046d:08e3) |
| Device | /dev/video0 (USB/UVC) |
| Format | MJPEG 1280×720 |
| Board | Raspberry Pi 5, Debian 12 (bookworm) |
Dependencies
python3-opencv— OpenCV for face detection (haar cascades, JPEG encode/decode)python3-v4l2— V4L2 Python bindings for camera access- No pip packages needed
Description
USB/UVC webcam live feed + web UI on a Raspberry Pi 5. Deliberately separate from camera-webui (Orin/IMX219) so two Codex agents can work without colliding.
Languages
Python
100%