Skip to main content

olab_camera

Camera capture, local recording, and network streaming (MJPEG/WebSocket/WebRTC) for lab robotics projects, plus ArUco, barcode/QR, face-detection, and YOLO computer-vision helpers. Requires olab_utils, resolved automatically from PyPI as a regular dependency.

Migrated from ~/Projects/ub_code/ub_camera (a flat, non-src/-layout single-file module — ub_code never had automated tests) per docs/plans/olab_packages_reorg_plan.md, Migration sequence step 4.

Installing

python3 -m venv venv
source venv/bin/activate
pip install olab-camera

Add extras as needed by appending [...] to the olab-camera line above, one at a time:

Extra Adds Notes
yolo ultralytics (YOLO object detection) Both this extra and the base package depend on plain opencv-python -- no conflicting install.
tracking local SORT, ByteTrack, OC-SORT, and BoT-SORT Detector-agnostic comparison API; no models, hosted inference, or automatic downloads.
rfdetr local RF-DETR detection/segmentation plus Roboflow ByteTrack Supply an existing local checkpoint. Relative names resolve in ~/Projects/olab_models/; absolute paths also work. The usage guide documents an explicit, one-time optional provisioning download. This feature never downloads weights or uses hosted inference at runtime.
barcode pyzbar addBarcode() and addQR(decoder='pyzbar'). Also needs the ZBar system library, which pip can't install: sudo apt install libzbar0 (Linux/Raspberry Pi) or brew install zbar (macOS); Windows wheels bundle it. addQR()'s default decoder='cv2' needs neither.
websocket websockets WebSocket + JPEG streaming.
webrtc aiortc, aiohttp WebRTC streaming.
ros — Dropped as a pip extra (rospy/sensor-msgs aren't on PyPI). To use CameraROS, install ROS via apt/rosdep and source your ROS environment — olab-camera then picks up rospy from that environment's Python path on its own.

all bundles every extra above (yolo, tracking, rfdetr, websocket, webrtc, realsense, barcode, openmv, av) together. Note that av's olab-audio dependency needs PortAudio's headers (portaudio19-dev on Ubuntu/Debian) to build pyaudio from source, and barcode needs the ZBar system library at runtime (see its row above).

Local development, against an olab_code checkout:

pip install -e "packages/olab_utils"
pip install -e "packages/olab_camera"                       # base
pip install -e "packages/olab_camera[yolo,websocket,webrtc]" # + extras

olab-camera depends on plain opencv-python, the same package ultralytics/trackers/rfdetr already require -- installing [yolo], [tracking], [rfdetr], or [all] no longer installs a second, conflicting cv2 distribution (closes #70). ArUco, QR, and face-detection all work on plain opencv-python; only Camera.addROI()'s classic object trackers other than 'MIL' (any case) still need opencv-contrib-python. If you want those:

pip uninstall -y opencv-python opencv-contrib-python
pip install "opencv-contrib-python>=4.10.0"

Installing opencv-contrib-python on top of an existing plain opencv-python install (instead of uninstalling both first) does make the extra trackers available, but leaves two distributions sharing the same cv2/ files -- a later [yolo]/[tracking]/[rfdetr] install, reinstall, or uninstall can then clobber or delete cv2 entirely. Uninstall both first, as above, for a clean result. Note this re-creates the plain-vs-contrib conflict for any of those three extras, since they require plain opencv-python themselves.

Upgrading from an install that predates this change (when olab-utils depended on opencv-contrib-python): the same clean-swap commands apply -- uninstall both opencv-python and opencv-contrib-python, then install opencv-python:

pip uninstall -y opencv-python opencv-contrib-python
pip install "opencv-python>=4.10.0"

After installation:

import olab_camera, olab_utils

GENX320 modes

The OpenMV backend uses the same CameraOpenMV lifecycle and browser-stream interfaces as the other cameras. Select a mode with profile=:

from olab_camera import CameraOpenMV

# Provisional default: normal 320x320 histogram pixels.
cam = CameraOpenMV('/dev/ttyACM0', profile='genx_histogram_preview')

# Histogram pixels with optional on-board movement-region telemetry/overlay.
regions = CameraOpenMV('/dev/ttyACM0', profile='genx_histogram_regions')

# Raw ON/OFF events, rendered back into normal preview frames. Register these
# before start(); they execute away from USB acquisition and are bounded.
raw = CameraOpenMV('/dev/ttyACM0', profile='genx_raw_events')
raw.addEventCallback(lambda batch: print(batch.count))
raw.addEventRecorder(outputDir='genx-session')

Use start() / startStream() / stop() normally. A raw session is separate from histogram acquisition; it supplies typed EVT2.0 batches to callbacks and a derived browser-viewable preview, with explicit drop counters in eventStats. Name the actual OpenMV CDC device explicitly because ACM numbering can change after reconnects.

TLS certificates

Every streaming protocol (including the MJPEG default) serves over HTTPS/WSS. olab_camera auto-generates a fresh, machine-local self-signed certificate the first time you actually start a stream (not when you construct a Camera) at ~/.olab_camera/ssl/ (owner-only permissions), via the cryptography library — no bundled/shared private key, no platform-specific tooling. Capture-only use of a Camera never touches the filesystem for TLS. See docs/deployment.md for custom certificates, fleet deployment via a lab-private CA and per-device leaf certs (zero browser TLS warnings without a shared private key), and reverse-proxy deployment.

Streaming Protocols

Protocol Extra install Typical latency Browser endpoint Multi-client
MJPEG (default) None 200–500 ms https://host:PORT/stream.mjpg Yes
WebSocket + JPEG olab-camera[websocket] 100–300 ms see docs/deployment.md Yes
WebRTC olab-camera[webrtc] 50–150 ms https://host:PORT/webrtc Yes
camera.startStream(port=8000)                     # MJPEG, default
camera.startStream(port=8001, protocol='websocket')
camera.startStream(port=8002, protocol='webrtc')

Further reading

  • Usage tutorial (camera init, ArUco, barcode/QR, face detection, YOLO variants, tracking, frame decoration): docs/usage_guide.md
  • Streaming protocols, custom TLS certs, reverse-proxy deployment: docs/deployment.md
  • Local HTTPS camera/feature browser playground: install olab-playground alongside this package; see packages/olab_playground/README.md in the olab_code checkout.
  • Extending the package (adding a camera class or feature class, code organization, testing your changes): docs/developer_guide.md

Metadata

Release files for olab-camera 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for olab-camera 0.1.0
File Size Uploaded
olab_camera-0.1.0.tar.gz 484.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for olab-camera 0.1.0
File Interpreter ABI Platform
olab_camera-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 893.6 kB

Release files / olab_camera-0.1.0.tar.gz

Download URL olab_camera-0.1.0.tar.gz
Size 484.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e1f9f026056a7df223076259c99af4ed41e56da6faa55c7a7d7e7015721023df
BLAKE2b-256 checksum
How to use checksums
d3b2e3a07ed164ff71d1ed680931abc489217498dafceffc3667f3e042744884
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release files / olab_camera-0.1.0-py3-none-any.whl

Download URL olab_camera-0.1.0-py3-none-any.whl
Size 409.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20db7165c868b25a908214a2f7236da4e7d1bf61ce84e00d1ab4d3a890dbd451
BLAKE2b-256 checksum
How to use checksums
76aae159284a08de9cd2d2a476f24fa0e267946717b6727a2533a390bf49cdb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page