Skip to main content

roboflex.webcam_uvc

Support for web cameras on linux - actually just a thin wrapper around libuvc, so if your camera supports libuvc, you should be good to go.

System dependencies

apt-get install libusb-1.0-0-dev
apt-get install libjpeg-dev

# ...or, on mac:

brew install libusb

pip install

pip install roboflex.webcam_uvc

Import

import roboflex.webcam_uvc as rcw

Nodes

There is only one: WebcamSensor

# all parameters optional: below are the defaults
webcam_sensor = rcw.WebcamSensor(
    width,
    height,
    fps,
    device_index = -1,
    format = UVC_FRAME_FORMAT_ANY,
    name = "WebcamSensor",
)

# must be started!
webcam_sensor.start()

# you can do this:
webcam_sensor.print_device_info()

Messages

from roboflex.webcam_uvc import WebcamDataRGB

API:

# the timestamp just before reading from device
message.t0 -> Float

# the timestamp just after reading from device
message.t1 -> Float

# the capture time from the device
message.capture_time -> Float

# the sequence number from the device
message.sequence -> Int

# numpy array of shape=(width, height, channels), dtype=short
message.rgb -> np.ndarray

DYNOFLEX:

# the timestamp just before reading from device
message["t0"] -> Double

# the timestamp just after reading from device
message["t1"] -> Double

# the capture time from the device
message["t"] -> Double

# the sequence number from the device
message["s"] -> Double

# numpy array of shape=(width, height, channels), dtype=short
message["rgb"] -> np.ndarray

Other

Description of a device:

from roboflex.webcam_uvc import DeviceDescriptor

dd.idVendor -> int
dd.idProduct -> int
dd.bcdUVC -> int
dd.serialNumber -> str
dd.manufacturer -> str
dd.product -> str

# you probably just want to print it:
str(dd)

Free function: get list of connected devices (webcams) - list of DeviceDescriptor, above.

get_device_list() -> [DeviceDescriptor]

Available frame formats: pass to constructor of WebcamSensor for the format parameter.

from roboflex.webcam_uvc import uvc_frame_format

uvc_frame_format.UVC_FRAME_FORMAT_ANY
uvc_frame_format.UVC_FRAME_FORMAT_UNCOMPRESSED
uvc_frame_format.UVC_FRAME_FORMAT_COMPRESSED

# YUYV/YUV2/YUV422: YUV encoding with one luminance value per pixel and
# one UV (chrominance) pair for every two pixels.
uvc_frame_format.UVC_FRAME_FORMAT_YUYV
uvc_frame_format.UVC_FRAME_FORMAT_UYVY

# 24-bit RGB
uvc_frame_format.UVC_FRAME_FORMAT_RGB
uvc_frame_format.UVC_FRAME_FORMAT_BGR

# Motion-JPEG (or JPEG) encoded images
uvc_frame_format.UVC_FRAME_FORMAT_MJPEG
uvc_frame_format.UVC_FRAME_FORMAT_H264

# Greyscale images
uvc_frame_format.UVC_FRAME_FORMAT_GRAY16
uvc_frame_format.UVC_FRAME_FORMAT_GRAY8

# Raw colour mosaic images
uvc_frame_format.UVC_FRAME_FORMAT_BY8
uvc_frame_format.UVC_FRAME_FORMAT_BA81
uvc_frame_format.UVC_FRAME_FORMAT_SGRBG8
uvc_frame_format.UVC_FRAME_FORMAT_SGBRG8
uvc_frame_format.UVC_FRAME_FORMAT_SRGGB8
uvc_frame_format.UVC_FRAME_FORMAT_SBGGR8

# YUV420: NV12
uvc_frame_format.UVC_FRAME_FORMAT_NV12

# Number of formats understood
uvc_frame_format.UVC_FRAME_FORMAT_COUNT

Linux webcam help

Access denied to your webcam?

First, list your usb devices and find your webcam:

lsusb

For me, I see:

Bus 002 Device 025: ID 32e4:9230 HD USB Camera HD USB Camera

create a file called '50-usb-webcam.rules' in /etc/udev/rules.d with a single line:

SUBSYSTEM=="usb", ATTR{idVendor}="HD USB Camera", ATTR{idProduct}="HD USB Camera", MODE="0666"

then

udevadm control --reload-rules && udevadm trigger

Metadata

Release files for roboflex.webcam-uvc 0.1.8

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

Source distribution (sdist)

Source distribution for roboflex.webcam-uvc 0.1.8
File Size Uploaded
roboflex_webcam_uvc-0.1.8.tar.gz 13.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for roboflex.webcam-uvc 0.1.8
File Interpreter ABI Platform
roboflex_webcam_uvc-0.1.8-cp311-cp311-macosx_15_0_arm64.whl CPython 3.11 CPython 3.11 macOS 15.0+ ARM64 Details

Total release size: 249.7 kB

Release files / roboflex_webcam_uvc-0.1.8.tar.gz

Download URL roboflex_webcam_uvc-0.1.8.tar.gz
Size 13.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a4cd8f95b8a468303c242277086fa004de9bc8b2f8f21efd345a58fec4040c9e
BLAKE2b-256 checksum
How to use checksums
936eaccecadc9c6a4bc4b1313ec68b9aa87f2d37e68f79fa4f775afc5a4265bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Release files / roboflex_webcam_uvc-0.1.8-cp311-cp311-macosx_15_0_arm64.whl

Download URL roboflex_webcam_uvc-0.1.8-cp311-cp311-macosx_15_0_arm64.whl
Size 236.6 kB
Tags CPython 3.11 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
6b27ad08c0204755dc0df549697e14c1a4589a72223def4ccb3d684c3c73fad3
BLAKE2b-256 checksum
How to use checksums
e82ef55b7359ce381c00b1fa5517e296e0921f4fe06a44307f8c3a67b1bf7180
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Release history Release notifications | RSS feed

This release

0.1.8 This release

2 release files

0.1.7

2 release files

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

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