Skip to main content

Roboflex Library that supports UVC-Compatible Webcams

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

roboflex_webcam_uvc-0.1.7.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

roboflex_webcam_uvc-0.1.7-cp311-cp311-macosx_15_0_arm64.whl (231.1 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

File details

Details for the file roboflex_webcam_uvc-0.1.7.tar.gz.

File metadata

  • Download URL: roboflex_webcam_uvc-0.1.7.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for roboflex_webcam_uvc-0.1.7.tar.gz
Algorithm Hash digest
SHA256 e26d8cb38c4ef2d336f76386c9042c6407a5b35ae28e5a58e815994cdad800f7
MD5 cc0c3634a623118b3db20f6c5201019d
BLAKE2b-256 361a8f67513469e445ab6c8db397a91db8c0a6220a2bcc87af3c13516cee618e

See more details on using hashes here.

File details

Details for the file roboflex_webcam_uvc-0.1.7-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for roboflex_webcam_uvc-0.1.7-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 523d9bfa4f79b2bb8bafba243b33322e3df03092420a4b8f16b2488a437cb871
MD5 979f6448a38b3abddaa9bd9255fc1b76
BLAKE2b-256 88b85db35f8283dd40221fd21d5e0869388a27836d1fa5bfc5d8f68f19586b31

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page