Python wrapper for USB, spin, Raspi, Jetson Nano cameras. Works on Windows, Raspian (incl Bullseye), JetsonNano, MacOS
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file camera_util-1.4.2.tar.gz.
File metadata
- Download URL: camera_util-1.4.2.tar.gz
- Upload date:
- Size: 145.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88491e1d4dcbf957b8869f187272ac680fb73368a0cadad5376c6bd7df53ec0b
|
|
| MD5 |
2a05548e8e621be94d2c02b229f9d1a5
|
|
| BLAKE2b-256 |
1846109351c5dc7d3e130ca6dc8f15c0334bfc5e3ecf9d0ed6660aa58a01a447
|
File details
Details for the file camera_util-1.4.2-py3-none-any.whl.
File metadata
- Download URL: camera_util-1.4.2-py3-none-any.whl
- Upload date:
- Size: 186.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2812cc4d5b757eadea9020740a2fc20083c202764a9e45ed1f0f1211395eddf
|
|
| MD5 |
9483f881bffce6e539f5f75e97208416
|
|
| BLAKE2b-256 |
04018ccc0639d57d76c4b45e1381e757984bd13be0bab436347f05d0a2792935
|