afc2dd7fff
#199 DLPack export: - frame.dlpack_y() / .dlpack_uv() — explicit multi-plane access для NV12 - frame.__dlpack__() / __dlpack_device__() — protocol для torch/cupy - Capsule deleter правильно держит refcount на frame_keep_alive, releases shape/strides arrays. CUDA pointer принадлежит frame. #200 Health/stats counters: - frames_received, timeouts, errors — per-call counters - last_seq, gap_count — proxy для drop count (NEWEST_ONLY mode) - last_frame_pts_ns - stats() — snapshot dict для MQTT health publish - counted в pybind layer т.к. C API не expose'ит ring_occupancy #201 Per-subscriber CUDA stream + thread-safety: - consumer_stream kwarg в subscribe() — int (cudaStream_t pointer) - subscriber.consumer_stream property - Thread-safety contract в docstring CuframesSubscriber - next_frame() передаёт consumer_stream_ в cuframes_subscriber_next #202 Smoke test + docs: - 10/10 pytest passed (расширен +2 теста на consumer_stream) - docs/python.md (~250 строк): quick start, API reference, integration с PyTorch/CuPy, reconnect-loop pattern, per-stream usage, pitch alignment, thread-safety, error taxonomy, backpressure, Phase 0 limitations Verify build + tests: cmake -B build-python -DBUILD_PYTHON_BINDINGS=ON cmake --build build-python -j pytest python/tests/ -v # 10/10 Закрывает Phase 0 issue gx/cuframes#6. Разблокирует goldix-smart-home/yolo-world-detector Phase 1. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
cuframes — Python bindings
Status: WIP (Phase 0 skeleton — issue gx/cuframes#6)
Это пакет Python-обёрток над libcuframes (C ABI). Цель — позволить
downstream ML/CV пайплайнам (yolo-world-detector, zone-motion, custom
скриптам) подписываться на cuframes без CPU round-trip: получать NV12
frames прямо как CUDA pointer / torch.Tensor (DLPack export, zero-copy).
Текущий статус (что уже работает в этом skeleton)
- Module import:
import cuframesзагружает_native.so - Версия:
cuframes.version_string(),cuframes.protocol_version() - Enums:
PixelFormat,SubscriberMode - Иерархия исключений:
CuframesError+ 8 subclasses (publisher gone, frame timeout, device lost, и т. д.)
Что в работе (см. tasks #198-#202)
CuframesSubscriber+CuframesFramelifecycle- DLPack export →
torch.from_dlpack,cupy.from_dlpack - Context manager (
with cuframes.subscribe(key) as sub:) - Per-subscriber CUDA stream
- Health/stats properties (
ring_occupancy,drop_count) - Thread-safety contract документация
Build (dev)
Standalone wheel:
cd python/
pip install -e . --no-build-isolation
Через корневой CMake-проект (вместе с libcuframes):
cmake -B build -DBUILD_PYTHON_BINDINGS=ON
cmake --build build -j
Зависимости
libcuframes≥ 0.4 (линкуется из соседнего CMake target)- CUDA Toolkit 12+
pybind112.13+ (берётся через FetchContent при CMake-сборке)- Python 3.10+
- Опционально:
torch>=2.4илиcupy-cuda12x>=13для DLPack-потребителей
Лицензия
LGPL-2.1+ (как у libcuframes).