(u_u)

ubuntu18.04:kinect v2 + pylibfreenect2

Categories: [blog]
Tags: [ubuntu], [kinect v2], [python]

GitHub - OpenKinect/libfreenect2: Open source drivers for the Kinect for Windows v2 deviceのインストール

git clone https://github.com/OpenKinect/libfreenect2.git
cd libfreenect2
sudo apt-get install -y build-essential cmake pkg-config
sudo apt-get install -y libusb-1.0-0-dev
sudo apt-get install -y libturbojpeg0-dev
sudo apt-get install -y libglfw3-dev
sudo apt-get install -y beignet-dev
sudo apt-get install -y libva-dev libjpeg-dev
sudo apt-get install -y libopenni2-dev
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2
make
make install
sudo cp ../platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/
./bin/Protonect

Cannot succeed to install · Issue #9 · r9y9/pylibfreenect2 · GitHub

vim ~/.bashrc
export LIBFREENECT2_INSTALL_PREFIX=/home/takuya/freenect2/
export LD_LIBRARY_PATH=$HOME/freenect2/lib:$LD_LIBRARY_PATH
source ~/.bashrc
sudo apt install -y pip3
pip3 install numpy cython 
pip3 install opencv-python
pip3 install pylibfreenect2

サンプルコード
pylibfreenect2/multiframe_listener.py at master · r9y9/pylibfreenect2

もしも以下のようなエラーが表示されたら、

takuya@takuya-PRIMERGY-TX1310-M3:~/libfreenect2/build$ ./bin/Protonect
Version: 0.2.0
Environment variables: LOGFILE=<protonect.log>
Usage: ./bin/Protonect [-gpu=<id>] [gl | cl | clkde | cuda | cudakde | cpu] [<device serial>]
        [-noviewer] [-norgb | -nodepth] [-help] [-version]
        [-frames <number of frames to process>]
To pause and unpause: pkill -USR1 Protonect
[Info] [Freenect2Impl] enumerating devices...
[Info] [Freenect2Impl] 8 usb devices connected
[Info] [Freenect2Impl] found valid Kinect v2 @2:2 with serial 012699142047
[Info] [Freenect2Impl] found 1 devices
libva info: VA-API version 1.4.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_4
libva info: va_openDriver() returns 0
[Info] [VaapiRgbPacketProcessorImpl] driver: Intel iHD driver - 2.0.0
[Info] [Freenect2DeviceImpl] opening...
[Info] [Freenect2DeviceImpl] transfer pool sizes rgb: 20*16384 ir: 60*8*33792
[Info] [Freenect2DeviceImpl] opened
[Info] [Freenect2DeviceImpl] starting...
[Debug] [Freenect2DeviceImpl] status 0x090000: 9855
[Debug] [Freenect2DeviceImpl] status 0x090000: 9855
[Info] [Freenect2DeviceImpl] submitting rgb transfers...
[Info] [Freenect2DeviceImpl] submitting depth transfers...
[Info] [Freenect2DeviceImpl] started
device serial: 012699142047
device firmware: 4.0.3917.0
[Debug] [DepthPacketStreamParser] not all subsequences received 0
[Error] [VaapiFrame] vaGetImage(display, surface, 0, 0, image.width, image.height, image.image_id): the requested RT Format is not supported
Segmentation fault (コアダンプ)

以下を追加する。

vim ~/.bash_profile
export LIBVA_DRIVER_NAME=i965
source ~/.bash_profile

"./bin/Protonect" can not be executed due to VAAPI error · Issue #1051 · OpenKinect/libfreenect2