Add PiCam network streamer with auto-setup for Pi 5

Initial commit of the MJPEG streaming server for Raspberry Pi.
Supports Pi Camera Module (via picamera2), USB webcams (via OpenCV),
and auto-detection of camera type.

Includes:
- `stream_picamera2.py` — optimized Pi CSI camera streamer
- `stream_usb.py` — generic USB camera streamer
- `stream.py` — auto-detects camera and launches correct streamer
- `image-setup/` — SD card imaging scripts and Pi 5 headless setup
  guide for first-boot automation with systemd service
- `requirements.txt` — Python dependencies
This commit is contained in:
2026-05-23 10:39:31 +02:00
commit 6faf505f4b
10 changed files with 778 additions and 0 deletions
+81
View File
@@ -0,0 +1,81 @@
# PiCam Network Streamer
A lightweight MJPEG streaming server for Raspberry Pi. It serves a webpage you can open on any device on your local network to view the live camera feed.
## Pi 5 OS Image Setup
For a fully automated first-boot setup on a **Raspberry Pi 5** with an **IMX219** camera, see the [`image-setup/`](image-setup/) directory. It includes:
- `SETUP_GUIDE.md` — Step-by-step SD card imaging instructions.
- `autosetup.sh` — One-command setup script (installs drivers, dependencies, and auto-starts the streamer as a systemd service).
- `config_camera.txt``config.txt` snippet to force-enable the IMX219 overlay.
## Quick Start
1. **Install dependencies**
```bash
pip install -r requirements.txt
```
2. **Run the streamer**
*Auto-detect (recommended):*
```bash
python stream.py
```
*For the official Raspberry Pi Camera Module (CSI):*
```bash
python stream_picamera2.py
```
*For a USB webcam:*
```bash
python stream_usb.py
```
3. **View the stream**
Open a browser on any device on the same network and go to:
```
http://<raspberry-pi-ip>:5000
```
Replace `<raspberry-pi-ip>` with your Pi's IP address.
## Options
Both scripts accept the same command-line arguments:
| Argument | Description | Default |
|----------|-------------|---------|
| `--host` | Network interface to bind to | `0.0.0.0` |
| `--port` | Port to serve on | `5000` |
| `--width` | Video width in pixels | `640` |
| `--height` | Video height in pixels | `480` |
| `--fps` | Target framerate | `30` |
*USB streamer only:*
| `--device` | Video device index (e.g., `0` for `/dev/video0`) | `0` |
### Examples
Run at 720p on port 8080:
```bash
python stream_picamera2.py --width 1280 --height 720 --port 8080
```
Use a second USB camera:
```bash
python stream_usb.py --device 1
```
## Files
- `stream_picamera2.py` — Optimized streamer for Raspberry Pi Camera Module v2/v3 using `picamera2`.
- `stream_usb.py` — Generic streamer for USB cameras using OpenCV.
- `stream.py` — Auto-detects camera type and launches the correct streamer.
- `requirements.txt` — Python dependencies.
- `image-setup/` — Scripts and guides for preparing a headless Pi 5 OS image with IMX219 support.
- `SETUP_GUIDE.md` — Full imaging and setup instructions.
- `setup-pi.sh` — Run this on a live Pi to install everything and auto-start the streamer.
- `autosetup.sh` — For embedding into a custom SD card image (runs on first boot).
- `firstrun.sh` — Raspberry Pi first-boot trigger script.
- `config_camera.txt` — Snippet to enable the IMX219 overlay.