6faf505f4b
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
33 lines
988 B
Python
33 lines
988 B
Python
#!/usr/bin/env python3
|
|
"""Auto-detect and start the best available streamer."""
|
|
|
|
import importlib.util
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def main():
|
|
# Check if picamera2 is available and a Pi camera is connected
|
|
if importlib.util.find_spec("picamera2") is not None:
|
|
try:
|
|
from picamera2 import Picamera2
|
|
|
|
# Attempt to create a camera to see if hardware is present
|
|
cam = Picamera2()
|
|
cam.close()
|
|
print("Detected Raspberry Pi camera. Starting picamera2 streamer...")
|
|
subprocess.run([sys.executable, "stream_picamera2.py"] + sys.argv[1:])
|
|
return
|
|
except Exception as e:
|
|
print(f"picamera2 available but camera not detected ({e}).")
|
|
else:
|
|
print("picamera2 not installed.")
|
|
|
|
# Fall back to USB / OpenCV
|
|
print("Falling back to USB camera streamer...")
|
|
subprocess.run([sys.executable, "stream_usb.py"] + sys.argv[1:])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|