Files
fegger 6faf505f4b 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
2026-05-23 10:39:31 +02:00

3.4 KiB

Pi 5 + IMX219 OS Image Setup Guide

This guide walks you through setting up a Raspberry Pi 5 with an IMX219 camera module (Camera Module v2) to run the PiCam streamer.

If you already have Raspberry Pi OS running on your Pi 5:

  1. Copy the project to your Pi (via USB drive, scp, or git clone).
  2. Run the setup script:
    cd piCam/image-setup
    chmod +x setup-pi.sh
    ./setup-pi.sh
    
  3. Done. The streamer will start automatically and will auto-start on every boot.

Open http://<pi-ip>:5000 in your browser.


Option B: Prepare an SD Card Image from Scratch

1. Download Raspberry Pi OS

Download the latest Raspberry Pi OS (64-bit) from the official site:

https://www.raspberrypi.com/software/operating-systems/

Recommended: Raspberry Pi OS with Desktop or Lite if you want a headless server.

2. Flash the OS to SD Card

Use the official Raspberry Pi Imager:

https://www.raspberrypi.com/software/

Steps in Imager:

  1. Choose OS → Raspberry Pi OS (64-bit)
  2. Choose Storage → Your SD card
  3. Click the gear icon (⚙️) to open Advanced Options and configure:
    • Hostname: picam (or your preference)
    • Enable SSH: ☑️ (Use password authentication or public key)
    • Set username/password: pi / your-password
    • Configure Wi-Fi: Enter your SSID and password
    • Set locale: Your timezone and keyboard layout
  4. Click Write

3. Enable Camera Hardware

After flashing, the SD card will show a bootfs partition. You need to ensure camera support is enabled.

For Raspberry Pi OS Bookworm and later:

The IMX219 is usually auto-detected. However, if you need to force it, open bootfs/config.txt and add to the end:

# IMX219 Camera Module v2
dtoverlay=imx219

Note: On Pi 5, the camera uses the CSI/DSI connector. Make sure the flat cable is oriented correctly (blue tape facing away from the USB ports on Pi 5).

4. Copy the Project Files

Copy the contents of this image-setup folder to the SD card:

# Linux/macOS example (adjust paths as needed)
cp -r /path/to/piCam/image-setup/* /media/YOUR_USERNAME/bootfs/

Specifically, ensure these files are placed on the bootfs partition:

  • autosetup.sh → root of bootfs/
  • firstrun.sh → root of bootfs/

5. Boot the Pi

Insert the SD card into the Pi 5, connect power, and wait 2-3 minutes for the first-boot setup to complete.

6. Access the Stream

Once booted, find the Pi on your network:

ping picam.local

Then open in a browser:

http://picam.local:5000

Troubleshooting

Issue Solution
Camera not detected Run libcamera-hello --list-cameras to verify hardware detection
Green tint on image Normal under some lighting; adjust AWB in picamera2 config
Low framerate Reduce resolution or ensure GPU memory isn't too low
picamera2 not found Run sudo apt install -y python3-picamera2

Automated First-Boot Setup

If you copied the provided files to bootfs, the system will:

  1. Expand the filesystem
  2. Update all packages
  3. Install camera drivers, Python dependencies, and Flask
  4. Enable the camera interface
  5. Auto-start the streaming server on boot

Monitor progress by SSHing in:

ssh pi@picam.local
tail -f /var/log/picam-setup.log