Python bindings for the Pupil Labs fork of libuvc with super fast jpeg decompression using libjpegturbo (utilizing the tubojpeg api).
- cross platform access to UVC capture devices.
- Full access to all uvc settings (Zoom,Focus,Brightness,etc.)
- Full access to all stream and format parameters (rates,sizes,etc.)
- Enumerate all capture devices with device_list()
- Capture instance will always grab mjpeg conpressed frames from cameras.
Image data is returned as Frame object. This object will decompress and convert on the fly when image data is requested. This gives the user the full flexiblity: Grab just the jpeg buffers or have them converted to YUV or Gray or RGB and only when you need.
The Frame class has caching build in to avoid double decompression or conversion.
pip install pupil-labs-uvc
See examples/ for code examples.
pyuvc requires the following dependencies:
- libusb
- libturbo-jpeg
- POSIX Threads for Windows (Windows only, supplied via the pupil-pthreads-win Python module)
Once the dependencies are installed, you can pip install the source tree:
git clone https://github.com/pupil-labs/pyuvc --recursive export FORCE_LOCAL_LIBUVC_BUILD=ON pip install ./pyuvc
Ubuntu/Debian:
apt-get update -y apt-get install -y libusb-1.0-0-dev libturbojpeg-dev
One needs to setup udev rules and add the target user to the plugdev
group to avoid
the privileged access requirement.
echo 'SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", GROUP="plugdev", MODE="0664"' | sudo tee /etc/udev/rules.d/10-libuvc.rules > /dev/null
sudo udevadm trigger
sudo usermod -a -G plugdev $USER
# logout and back in
Homebrew:
brew update brew install libusb jpeg-turbo
Unfortunately, this is currently not possible. See this libusb issue thread for details.
Run the following code in a powershell to install the dependencies (requires 7z to be installed)
pip install build delvewheel
git clone https://github.com/pupil-labs/pyuvc --recursive
cd pyuvc
scripts/download-deps-win.ps1 -DEPS_TMP_PATH tmp
$Env:DEPS_PATHS_LOC = "tmp/dep_paths.json"
python -m build -w # will create a wheel in dist/ folder; insert the wheel path below
python scripts/repair-wheels-win.py $Env:DEPS_PATHS_LOC <wheel location> wheelhouse
pip install wheelhouse/<wheel name>
pyuvc requires the libUSBk driver to be installed for your corresponding camera.
Otherwise, metadata like the product name will be set to "unknown"
.
Please see these instructions on how to manually install libUSBk drivers for your specific camera.