Add MJPEG camera server with systemd deployment
- camera/capture.py: V4L2 mmap-based MJPEG frame capture with background thread - camera/mjpeg.py: MJPEG streaming server (multipart/x-mixed-replace) + minimal web UI - camera/app.py: Entry point with argument parsing and signal handling - pyproject.toml: uv project config (no external dependencies) - camera-webui.service: systemd unit for native Pi deployment - README.md: Updated for systemd-only direction with install instructions
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
"""Entry point for the USB camera web UI server.
|
||||
|
||||
Usage::
|
||||
|
||||
uv run python -m camera.app # run directly
|
||||
uv run python -m camera.app --host 0.0.0.0 --port 8080
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import signal
|
||||
import sys
|
||||
|
||||
from camera.mjpeg import run
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="USB Camera Web UI Server")
|
||||
parser.add_argument("--host", default="0.0.0.0", help="Bind address (default: 0.0.0.0)")
|
||||
parser.add_argument("--port", type=int, default=8080, help="Port (default: 8080)")
|
||||
args = parser.parse_args()
|
||||
|
||||
# Handle shutdown gracefully
|
||||
def _signal_handler(signum, frame):
|
||||
print(f"\nReceived signal {signum}, shutting down...")
|
||||
sys.exit(0)
|
||||
|
||||
signal.signal(signal.SIGINT, _signal_handler)
|
||||
signal.signal(signal.SIGTERM, _signal_handler)
|
||||
|
||||
print(f"Starting camera web UI on http://{args.host}:{args.port}")
|
||||
print("Press Ctrl+C to stop")
|
||||
run(host=args.host, port=args.port)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user