Kinect and PCL on Raspberry Pi 3

Standard

In my previous blog post I described how to connect a OPT8241 depth camera from Texas Instruments to a Raspberry Pi 3 and run Point Cloud Library and Voxel SDK.   In this blog post I will describe how to connect a Kinect v1 to a Raspberry Pi 3.

Preliminaries

If your RPi-3 is brand new and does not have Ubuntu Mate running on it, follow this blog post to get Ubuntu Mate 16.04 running on it.  Once you have a RPi-3 running Ubuntu Mate 16.04, follow instruction in the Setup Prerequisites and Build Point Cloud Library sections.

More Prerequisites

To run Kinect with PCL we need to install and build OpenNI and SensorKinect, which requires some additional prerequisites:

     sudo apt-get update
     sudo apt-get install doxygen graphviz g++-multilib

Both doxygen and g++-multilib are needed to build OpenNI and SensorKinect.

Install OpenNI

The install OpenNI, do the following:

     cd      
     mkdir kinect
     cd kinect
     git clone https://github.com/OpenNI/OpenNI.git
     cd OpenNI
     git checkout unstable

and edit the file:

     gedit ./Platform/Linux/Build/Common/Platform.Arm

and delete ‘-mfloat-abi=softfp‘.

Now build and install OpenNI:

     cd ~/kinect/OpenNI/Platform/Linux/CreateRedist
     ./RedistMaker.Arm

Once build completes install it by:

     cd ~/kinect/OpenNI/Platform/Linux/Redist/OpenNI-Bin-Dev-Linux-Arm-V1.5.8.5
     sudo ./install.sh

Install SensorKinect

The install SensorKinect, do the following:

     cd ~/kinect
     git clone https://github.com/avin2/SensorKinect.git
     cd SensorKinect
     git checkout unstable

and edit the file:

     gedit ./Platform/Linux/Build/Common/Platform.Arm

and delete ‘-mfloat-abi=softfp‘.

Now build and install SensorKinect:

     cd ~/kinect/SensorKinect/Platform/Linux/CreateRedist
     ./RedistMaker

Once build completes install it by:

     cd ~/kinect/SensorKinect/Platform/Linux/Redist/Sensor-Bin-Dev-Linux-Arm-v5.1.2.1/
     sudo ./install.sh

Connect Kinect

At this point, Kinect is ready.  You can test it by running this:

     cd ~/kinect/OpenNI/Platform/Linux/Redist/OpenNI-Bin-Dev-Linux-Arm-v1.5.8.5
     ./Sample-NiSimpleRead

You should get something like this:

Frame 98 Middle point is: 5719. FPS: 26.939665
Frame 99 Middle point is: 5719. FPS: 26.937723
Frame 100 Middle point is: 5626. FPS: 27.259674
Frame 101 Middle point is: 5626. FPS: 27.284256
Frame 102 Middle point is: 5719. FPS: 26.628609
Frame 103 Middle point is: 5719. FPS: 26.604128
Frame 104 Middle point is: 5626. FPS: 26.590570
Frame 105 Middle point is: 5719. FPS: 26.623127
Frame 106 Middle point is: 5719. FPS: 26.587439
Frame 107 Middle point is: 5719. FPS: 26.593811
Frame 108 Middle point is: 5719. FPS: 26.917368
...

If you get some error like

Reading config from: '../../Config/SamplesConfig.xml'
Warning: USB events thread - failed to set priority. This might cause loss of data...
Open failed: USB interface is not supported! 

make the following edit:

     cd ~/kinect/SensorKinect/Platform/Linux/Redist/Sensor-Bin-Linux-Arm-v5.1.2.1/Config/
     sudo gedit GlobalDefaultsKinect.ini

and modify `;UsbInterface=2` into `UsbInterface=1`

One can get a visual using guvcview, but first one must do a few things:

     sudo modprobe videodev
     sudo modprobe gspca_main
     sudo modprobe gspca_kinect depth_mode=1

After the above /dev/video0 should appear in system. Now you can launch guvcview and get the below images. The first is from the depth camera and appears to show raw amplitude map of the Kinect structured light pattern. The second is from color camera (YUYV).

screenshot-at-2016-12-07-180556

Figure 1 – Structured light camera image.

screenshot-at-2016-12-07-181153

Figure 2 – RGB camera image.