This is a wrapper around libuvc
the USB video class, for USB-connected cameras.
Install pyuvc and all its dependencies:
sudo apt-get install libusb-1.0 cython
- Install libturbojpeg from source (there are some related packages available, but not the one libuvc depends on)
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 libuvc from source (no package available yet for raspbian)
git clone https://github.com/ktossell/libuvc
cd libuvc
mkdir build
cd build
cmake ..
make && sudo make install
sudo ldconfig
import uvc
import logging
logging.basicConfig(level=logging.INFO)
dev_list = uvc.device_list()
print("devices: ", dev_list)
cap = uvc.Capture(dev_list[0]['uid'])
print(dir(cap))
frame = None
cap.frame_mode = (1920, 1080, 30)
with open("out.mjpg","wb+") as fd:
for i in range(300):
print("frame ", i)
frame = cap.get_frame_robust()
fd.write(frame.jpeg_buffer)
frame = None
fd.close()
print("done writing")
cap = None