A lightweight, headless Python solution to stream near real-time video from ZWO ASI cameras to a web browser. Designed for Raspberry Pi 5 (running Raspberry Pi OS Bookworm 64-bit) over SSH, with no window manager required.
- Web-based View: View the camera feed on any device (phone/laptop) via
http://<PI_IP>:5000. - Headless: Runs entirely via terminal/SSH; no HDMI monitor or X11/Wayland desktop needed.
- MJPEG Streaming: Low-latency video feed utilizing Flask and OpenCV.
- Automated Setup: Includes a script to handle virtual environments and dependencies automatically.
- Camera: ZWO ASI Camera (USB 3.0 recommended).
- Drivers: ZWO ASI SDK (Required for the
.solibrary file).
Clone this repository or create a directory for your scripts:
mkdir -p ~/allsky_focusaid_stream
cd ~/allsky_focusaid_streamThis script requires the compiled C library libASICamera2.so to communicate with ZWO cameras. You must extract the ZWO SDK and copy the appropriate ARMvX library to this folder based on the Pi you have. The repo has the ARMv8 version included that is suitable for Pi4 and 5 running 64-bit Raspberry Pi OS.
ZWO SDK URL: https://dl.zwoastro.com/software?app=DeveloperCameraSdk&platform=windows86®ion=Overseas
Based on the standard extraction path of the library in the SDK, copy the correct library:
cp ASI_Camera_SDK/ASI_Camera_SDK/ASI_linux_mac_SDK_V1.41/ASI_linux_mac_SDK_V1.41/lib/armv8/libASICamera2.so .Note: If your extracted SDK path differs, simply locate the
libASICamera2.sofile inside thelib/armv8(or the folder suitable for your Pi version) folder of the SDK and copy it into the~/allsky_focusaid_streamdirectory.
Ensure the setup script has permission to run:
chmod +x pi_zwo_streamer.shThe pi_zwo_streamer.sh script is an all-in-one tool. It will:
- Check for system dependencies (OpenCV).
- Create/Activate a Python Virtual Environment (
venv). - Install Python libraries (
zwoasi,flask,opencv). - Generate the streaming script (
zwo.py). - Launch the stream.
To run it:
./pi_zwo_streamer.shIf you have already run the setup once and just want to restart the stream:
# 1. Activate the virtual environment
source venv/bin/activate
# 2. Run the python script directly
python zwo.py-
Ensure your computer or smartphone is on the same local network as the Pi.
-
Find your Pi's IP address by running:
hostname -I -
Open a web browser and navigate to:
http://<YOUR_PI_IP>:5000(Example:
http://192.168.1.50:5000)
To change camera settings (Exposure, Gain, High Speed Mode), edit the generated zwo.py file:
nano zwo.pyLook for the configuration block near the top:
# Camera Settings
GAIN = 300 # Range: 0 to ~600 (Higher = Brighter/Noisier)
EXPOSURE_US = 20000 # Exposure in microseconds (20000 = 20ms)| Issue | Solution |
|---|---|
| ModuleNotFoundError | You are not in the virtual environment. Run source venv/bin/activate or use ./setup_zwo.sh. |
| Error initializing library | The libASICamera2.so file is missing. Ensure it is in the same folder as zwo.py. |
| No cameras found | Check USB connection. Try a USB 3.0 (blue) port. Ensure your power supply (27W) is sufficient. |
| Black Image | Increase GAIN or EXPOSURE_US in the script settings. |
