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.

 

 

18 thoughts on “Kinect and PCL on Raspberry Pi 3

  1. BJRATI

    Yuehchuan and Victor, editing the UsbInterface=1 value in /usr/etc/primesense/GlobalDefaultsKinect.ini worked for me.

    • Tetran

      Hey where i get the kinect depth data? and where is the programming interface?
      Sorry for the bad english

    • Thanks, effectively, I do have the Xtion 2 🙂
      Trying to follow your instructions now, however, have the latest Raspbian Jessie installed.
      Two things:
      – when I want to install “g++-multilib”, I get the error “Unable to locate package, couldn’t find any package by regex “g++-multilib”
      – secondly, I just read that there are prerequisites from your other article, there I learn that you’re using Ubuntu mate.
      Could these two things be related?

    • Sorry, just delivers nothing. when I do “apt-cache search g++-multilib”, i tried to install g++ without multilib but OS says that I have the most current version already. Seems like g++ is a “better” version of gcc, but I have no clue where to tell the make file to use gcc or g++.

    • g++ is C++ compiler, while g++-multilib is standard library for different architecture for g++. g++ looks at your file name extension, *.cpp, *.cxx are C++ files.

  2. Hi I already follow your post now stock in the step
    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!

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

    and some issue I want to mention
    for install Sensorkinect there is an virtual functuin issue need to solve with this commit
    https://github.com/avin2/SensorKinect/pull/5/commits/94d6ed38751571051b3acbdad4ea874f41deb375

    And when testing the executable Sample-NiSimpleRead ; the path should be under
    /home/ubuntu/kinect/OpenNI/Platform/Linux/Redist/OpenNI-Bin-Dev-Linux-Arm-v1.5.8.5/Samples/Bin/Arm-Debug/

    In your Post is
    cd ~/kinect/OpenNI/Platform/Linux/Redist/OpenNI-Bin-Dev-Linux-Arm-v1.5.8.5 not complete
    that’s it.

    If I solve the issue for usb, I will update.
    Mine invironment is RPi3 with ubuntuMATE 16.04 and ever install ROS Kinetic

Leave a Reply to keyur Cancel reply