#!/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()