pyuvc icon indicating copy to clipboard operation
pyuvc copied to clipboard

Can I build pyuvc on Raspberry PI 3?

Open davidchaozhang opened this issue 5 years ago • 7 comments

Hi:

I tried the library quickly on a Raspberry PI, and I got the compilation failed. My initial impression is that the C compiler/libraries on Pi is not the same as the C compiler/library on Ubuntu, and it is much older.

Any idea of changes I can make to build the library on PI and that I can run 16-bit inputs from a camera?

Thanks,

David

davidchaozhang avatar May 23 '19 13:05 davidchaozhang

What errors do you have?

lukaszog avatar Jul 26 '19 07:07 lukaszog

Hey, I just manged to compile all the dependencies and install the library on a Raspberry Pi 4 (4GB version), running Raspbian Buster (v.10) following the instructions here

However you will need to install libusb beforehand: sudo apt-get install libusb-1.0 I also had OpenCV and CMake installed following the tutorial here

But when trying to run the example.py file I'm getting the following error:
Traceback (most recent call last): File "/home/pi/Downloads/pyuvc/example.py", line 2, in <module> import uvc ImportError: /usr/local/lib/libuvc.so.0: undefined symbol: libusb_handle_events_completed

**Update: Following the suggestion on this issue It seems like Raspbian 10 already has pkg-config pre-installed, or it was installed during one of the updates prior to compiling and installing any of the pyuvc dependencies. as I got 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. response when running sudo apt-get install pkg-config

yurikleb avatar Mar 02 '20 10:03 yurikleb

Update! Just managed to install pyuvc on a fresh setup of Raspbian Buster v.10 (2020-02-13 Release) on Raspberry Pi 4 (4gb) under Python 3.

Using the following commands:

Update Upgrade Debian OS and apt-get package manager:

sudo apt-get update && sudo apt-get upgrade  

Install CMake: sudo apt-get install build-essential cmake unzip pkg-config

Install libusb 1.0-0-dev: sudo apt-get install libusb-1.0-0-dev

Change to your Downloads directory: cd ~/Downloads

Install Pupil-Labs version of libuvc:

git clone https://github.com/pupil-labs/libuvc  
cd libuvc/  
mkdir build  
cd build  
cmake ..  
make && sudo make install  
sudo ldconfig  

Go back to your Downloads Folder: cd ~/Downloads

Install libjpeg-turbo:

wget -O libjpeg-turbo.tar.gz https://sourceforge.net/projects/libjpeg-turbo/files/1.5.1/libjpeg-turbo-1.5.1.tar.gz/download  
tar xvzf libjpeg-turbo.tar.gz  
cd libjpeg-turbo-1.5.1/  
./configure --with-pic --prefix=/usr/local  
sudo make install  
sudo ldconfig  

Install cython and numpy:

sudo pip3 install cython  
sudo pip3 install numpy  

Set UDEV rules:

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

Go back to your Downloads Folder: cd ~/Downloads

Install pyucv:

git clone https://github.com/pupil-labs/pyuvc.git  
cd pyuvc/  
sudo python3 setup.py install  

Connect a USB camera to the Pi

Run the example file to confirm pyuvc was installed and works python3 example.py

yurikleb avatar Mar 24 '20 06:03 yurikleb

Another Update! The above instructions seem to work on Raspberry Pi3 as well.

yurikleb avatar Jun 10 '20 10:06 yurikleb

I tried this today, and I wanted to report the latest build process on the RPi now that a number of years has gone by.

Im happy to report that I was able to get it installed using only apt and pip commands, and no manual compilation like some of the above messages.

sudo apt-get install build-essential cmake unzip pkg-config
sudo apt-get install libusb-1.0-0-dev
sudo apt-get install libjpeg-dev
sudo apt-get install libturbojpeg0-dev
pip install -vvv pupil-labs-uvc --timeout=60 --retries=10

As you can see I added some timeout extensions and retries. Pip really wanted to fail, but adding the verbosity helped me get through the problems. I probably ran the pip command about 3 times before I finally got it.

My hardware: Pi Zero 2W (Same CPU as Pi 3) My Software: Raspbian Lite 64-bit

Distributor ID:	Debian
Description:	Debian GNU/Linux 11 (bullseye)
Release:	11
Codename:	bullseye

kornpow avatar Jan 30 '24 19:01 kornpow

This thread is gold

Hopefully gold in a good way

kornpow avatar Feb 09 '24 20:02 kornpow