Skip to main content

Local camera feeds for development with HTTP, RTSP, and optional YOLO human detection.

Project description

devcam

Easy local camera feeds for development and testing. devcam can expose a camera as HTTP MJPEG, publish RTSP, and optionally run YOLO human detection from the same web UI.

Components

Service Port Description
python -m devcam http 1080 Web UI, HTTP MJPEG stream, snapshots, camera controls, optional human detection
python -m devcam rtsp 1081 RTSP publisher (requires ffmpeg + mediamtx)
human_detector/detector.py 1082 Legacy standalone YOLOv8n person detection API

Quick Start

pip install -e .
python -m devcam http

Install YOLO human detection support with the optional vision extra:

pip install -e ".[vision]"

Open http://localhost:1080/ to view the stream, switch cameras, change resolution/FPS, mirror webcam view, turn capture on or off, and enable human detection. Detection is lazy-loaded: the app starts without loading YOLO, and the model loads only when detection is enabled or /api/detection/run is called.

The legacy entrypoint devcam CLI command also works:

devcam http

Camera Server

Captures webcam and broadcasts as HTTP MJPEG or RTSP. Pick one at launch.

python -m devcam {http,rtsp} [--port PORT] [--camera INDEX] [--resolution WxH] [--fps FPS] [--backend {auto,cv2,zed}]
  • HTTP modehttp://localhost:1080/ (web viewer), /stream (MJPEG), /snapshot (single JPEG)
  • RTSP modertsp://localhost:1081/cam (requires ffmpeg + mediamtx)

The HTTP web viewer includes controls for camera selection, resolution, FPS, mirrored webcam display, turning capture on or off, enabling human detection, changing confidence threshold, changing detection rate up to 20 Hz, and drawing detection boxes over the live stream.

Flag Default Description
protocol (required) http or rtsp
--port 1080 / 1081 Stream port
--camera 0 Camera index
--resolution auto WxH e.g. 1280x720
--fps 30 Capture and stream frame rate
--backend auto auto (ZED first, then OpenCV), cv2 (V4L2/USB), zed (ZED SDK)

HTTP Control API

Endpoint Method Description
/api/status GET Current backend, selected camera, requested mode, actual mode, and capture state
/api/cameras GET Available cameras for the active backend
/api/modes GET Common resolution and FPS choices for the UI
/api/config POST Start, stop, mirror, or switch camera settings

Example:

curl -X POST http://localhost:1080/api/config \
  -H 'Content-Type: application/json' \
  -d '{"enabled":true,"camera":0,"width":1280,"height":720,"fps":15,"mirror":true}'

Human Detection API

Human detection runs in the same Flask process against the latest in-memory camera frame. It does not require running the old detector service in a second terminal.

Endpoint Method Description
/api/detection/status GET Detection availability, enabled state, confidence threshold, interval, model loaded state, and errors
/api/detection/config POST Enable/disable detection and update settings
/api/detection/run GET/POST Run YOLO person detection on the latest frame

Configuration example:

curl -X POST http://localhost:1080/api/detection/config \
  -H 'Content-Type: application/json' \
  -d '{"enabled":true,"confidence":0.55,"interval_ms":50}'

interval_ms controls detection cadence. The UI slider supports 1-20 Hz, where 20 Hz is 50 ms.

Detection response shape:

{
  "enabled": true,
  "available": true,
  "human_detected": true,
  "confidence": 0.87,
  "confidence_threshold": 0.55,
  "count": 1,
  "frame_width": 1920,
  "frame_height": 1080,
  "latency_ms": 42.1,
  "detections": [
    {"confidence": 0.87, "bbox": [420.0, 160.0, 780.0, 940.0]}
  ]
}

If ultralytics is not installed, camera streaming still works. Detection endpoints return available: false with a clear error.

Python Package

devcam is packaged with pyproject.toml. For local development:

pip install -e ".[vision]"
devcam http

Build distribution artifacts:

pip install -e ".[dev]"
python -m build

Before publishing, verify the package metadata and artifacts:

python -m twine check dist/*

Publish to TestPyPI first:

python -m twine upload --repository testpypi dist/*

Then publish to PyPI when ready:

python -m twine upload dist/*

Before a real PyPI release, confirm the devcam package name is available, choose a license intentionally, and consider adding a LICENSE file.

Camera Backends

  • cv2 — OpenCV V4L2 for USB webcams
  • zed — ZED SDK for ZED X / ZED X Mini on Jetson (requires pyzed)
  • auto (default) — tries ZED first, falls back to OpenCV

Jetson / ZED X Notes

  • If ZED cameras show as "NOT AVAILABLE", restart the daemon: sudo systemctl restart zed_x_daemon
  • Resolution is always opened at the camera's native mode; --resolution downscales in software
  • --fps 5 or --fps 15 recommended for low-bandwidth use cases

RTSP Setup

One-time setup on macOS/Linux:

# macOS: brew install ffmpeg
# Linux: sudo apt install ffmpeg
bash setup_mediamtx.sh   # downloads mediamtx for this OS/CPU

One-time setup on Windows PowerShell:

Windows setup has not been tested or validated yet.

winget install Gyan.FFmpeg
.\setup_mediamtx.ps1    # downloads mediamtx for Windows/CPU

Each time you use RTSP on macOS/Linux:

./mediamtx               # run in a separate terminal
python -m devcam rtsp

Each time you use RTSP on Windows PowerShell:

.\mediamtx.exe           # run in a separate terminal
python -m devcam rtsp

human_detector

REST API for person detection using YOLOv8n (~6MB model, CPU-only, auto-downloaded).

python human_detector/detector.py [--port PORT] [--preload]
Endpoint Method Input Response
/detect?url=... GET Image URL {human_detected, confidence, count, detections}
/detect POST File upload / raw bytes / JSON {"url":"..."} Same
/health GET {"status": "ok"}

Benchmark

python human_detector/benchmark.py -n 50

Measures detection throughput (Hz) using a pre-fetched snapshot.

macOS Notes

  • Camera permission: System Settings → Privacy & Security → Camera → Terminal
  • All ports are unprivileged (≥1024) — no sudo needed

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

devcam-0.1.0.tar.gz (23.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

devcam-0.1.0-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file devcam-0.1.0.tar.gz.

File metadata

  • Download URL: devcam-0.1.0.tar.gz
  • Upload date:
  • Size: 23.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for devcam-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d6e38366528695b5d4613752947cec6e7ac55da31b817e0392285b3f619c74a4
MD5 589b0dbd5098d94e25d7e4cc716f0bc9
BLAKE2b-256 daefb199eae1e5f34e35fd623180806bd5b955ef8f66658a429719cc7289b75c

See more details on using hashes here.

Provenance

The following attestation bundles were made for devcam-0.1.0.tar.gz:

Publisher: publish.yml on GitAashishG/devcam

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file devcam-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: devcam-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for devcam-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7360898b231484528cdc014fceb2e45e9ba8608083ebe732f435863b0d3c0396
MD5 40c2ce06fb5f409b479da43c8cc0abde
BLAKE2b-256 5e44d60b58d63b245cd7b632eba5a4f8035b920eea87b2c3b429642d59cccfce

See more details on using hashes here.

Provenance

The following attestation bundles were made for devcam-0.1.0-py3-none-any.whl:

Publisher: publish.yml on GitAashishG/devcam

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page