Skip to main content

A collection of threaded camera capture and streaming utilities.

Supports:

  • USB and laptop internal webcams (OpenCV)

  • RTSP/RTP network streams (GStreamer or FFmpeg fallback)

  • MIPI CSI cameras (Raspberry Pi Picamera2/libcamera, Jetson Nano)

  • Teledyne/FLIR Spinnaker cameras (PySpin)

  • Basler cameras (pypylon)

Storage helpers for HDF5, TIFF, AVI, MKV.

Processing helpers for temporal filtering, background subtraction, and binning.

Full documentation (configs, backends, examples): README.md.

Install

pip install camera-util

Quickstart (OpenCV webcam)

import time
import cv2
from camera.capture.cv2capture import cv2Capture

configs = {
    "camera_res": (640, 480),
    "fps": 30,
    "fourcc": "MJPG",
    "displayfps": 30,
}

camera = cv2Capture(configs, 0)
camera.start()

window_name = "Camera"
cv2.namedWindow(window_name, cv2.WINDOW_AUTOSIZE)
last_display = time.perf_counter()
display_interval = 1.0 / configs["displayfps"]
stop = False
while cv2.getWindowProperty(window_name, cv2.WND_PROP_VISIBLE) >= 0 and not stop:
    frame = None
    if camera.buffer and camera.buffer.avail > 0:
        frame, _ts_ms = camera.buffer.pull(copy=False)
    elif camera.capture is not None:
        _ts_ms, frame = camera.capture.get(block=True, timeout=0.25)

    if frame is None:
        continue

    current_time = time.perf_counter()
    if (current_time - last_display) >= display_interval:
        frame_display = frame.copy()
        cv2.putText(frame_display, f"Capture FPS:{camera.measured_fps:.1f} [Hz]", (10, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255,255,255), 1)
        cv2.imshow(window_name, frame_display)
        if cv2.waitKey(1) & 0xFF == ord("q"):
            stop = True
        last_display = current_time

camera.stop()
cv2.destroyAllWindows()

Raspberry Pi (Picamera2/libcamera)

Two wrappers are provided:

  • piCamera2Capture (threaded, non-Qt)

  • piCamera2CaptureQt (Qt5/Qt6)

Frame delivery model:

  • Frames go into a single-producer/single-consumer ring buffer camera.buffer.

  • Consumers poll (no queue semantics):

if camera.buffer and camera.buffer.avail > 0:
    frame, ts_ms = camera.buffer.pull(copy=False)

The Qt wrapper does not emit a per-frame signal; GUI code typically polls via a QTimer.

Metadata

Release files for camera-util 1.4.2

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

Source distribution (sdist)

Source distribution for camera-util 1.4.2
File Size Uploaded
camera_util-1.4.2.tar.gz 145.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for camera-util 1.4.2
File Interpreter ABI Platform
camera_util-1.4.2-py3-none-any.whl Python 3 none any Details

Total release size: 332.0 kB

Release files / camera_util-1.4.2.tar.gz

Download URL camera_util-1.4.2.tar.gz
Size 145.6 kB
Tags Source
SHA-256 checksum
How to use checksums
88491e1d4dcbf957b8869f187272ac680fb73368a0cadad5376c6bd7df53ec0b
BLAKE2b-256 checksum
How to use checksums
1846109351c5dc7d3e130ca6dc8f15c0334bfc5e3ecf9d0ed6660aa58a01a447
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / camera_util-1.4.2-py3-none-any.whl

Download URL camera_util-1.4.2-py3-none-any.whl
Size 186.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2812cc4d5b757eadea9020740a2fc20083c202764a9e45ed1f0f1211395eddf
BLAKE2b-256 checksum
How to use checksums
04018ccc0639d57d76c4b45e1381e757984bd13be0bab436347f05d0a2792935
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

1.4.2 This release

2 release files

1.4.0

2 release files

1.3.3

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

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