Saturday, December 15, 2012

how to compile OpenNi and SensorKinect on arm processors

I got a small Arm architecture pc few days ago and wanted to use it to control a Kinect (which is still not completely working).
The first step I took was to compile the OpenNi and SensorKinect which took me a while to figure out 


here a quick log of what worked for me : 

first the needed packages

sudo apt-get update
sudo apt-get install gcc-multilib libusb-1.0.0-dev git-core build-essential
sudo apt-get install doxygen graphviz default-jdk freeglut3-dev libopencv-dev
}


 Install OpenNi

cd ~/
mkdir kinect
cd kinect
git clone git://github.com/OpenNI/OpenNI.git
cd OpenNI 


check the version in the README file (if it's 1.5.2.X you need to use the unstable to avoid  XnListT fault error when recompiling)
git checkout unstable

emacs -nw /Platform/Linux/Build/Common/Platform.Arm

and delete the `-mfloat-abi=softfp`.

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

(if you get an error on the Returning Values of cale_jobs_number)
emacs -nw Redist_OpenNI.pysearch for 'MAKE_ARGS += ' -j' + calc_jobs_number()` and change to `MAKE_ARGS += ' -j1′`

cd ~/kinect/OpenNI/Platform/Linux/Redist/OpenNI-Bin-Dev-Linux-Arm-v1.5.4.0
If the verson is lower than 1.5.4.0 and you swithced to the unstable recheck what you did when executing 'git checkout unstable'.

sudo ./install.sh

So far so good, now the driver:

cd ~/kinect git clone git://github.com/avin2/SensorKinect.git
emacs -nw ~/kinect/SensorKinect/Platform/Linux/Build/Common/Platform.Arm

and remove `-mfloat-abi=softfp`

emacs -nw ~/kinect/SensorKinect/Platform/Linux/CreateRedist/RedistMakerand if you are getting the same error as before modify
  make -j$(calc-jobs_number) -C ../Build into make -j1 -C ../Build 
cd ~/kinect/SensorKinect/Platform/Linux/CreateRedist
./RedistMaker

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

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

if you get the following error : 
~/kinect/OpenNI_unstable/Platform/Linux/Redist/OpenNI-Bin-Dev-Linux-Arm-v1.5.4.0/Samples/Bin/Arm-Release$ ./Sample-NiSimpleRead 
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!

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

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

then install the driver (thanks kai franke for the comment)
cd ~/kinect/SensorKinect/Platform/Linux/Redist/Sensor-Bin-Linux-Arm-v5.1.2.1
sudo ./install.sh


Now in principle one should see the depth data

I see data coming out 
Frame 37 Middle point is: 3659. FPS: 0.000000
Frame 38 Middle point is: 3864. FPS: 0.000000
Frame 39 Middle point is: 3907. FPS: 0.000000
Frame 40 Middle point is: 3907. FPS: 0.000000
Frame 41 Middle point is: 2252. FPS: 0.000000
Frame 42 Middle point is: 2281. FPS: 0.000000
Frame 43 Middle point is: 2297. FPS: 0.000000
Frame 44 Middle point is: 2252. FPS: 0.000000
Frame 45 Middle point is: 1287. FPS: 0.000000
Frame 46 Middle point is: 3821. FPS: 0.000000
Frame 47 Middle point is: 3864. FPS: 23.233110
Frame 48 Middle point is: 3907. FPS: 23.364748
Frame 49 Middle point is: 3907. FPS: 23.113655
Frame 50 Middle point is: 2478. FPS: 22.716246
Frame 51 Middle point is: 2496. FPS: 22.822172
Frame 52 Middle point is: 2496. FPS: 22.725554

but if I try with a GUI no depth map appearing


java -jar org.OpenNI.Samples.SimpleViewer.jar
Warning: USB events thread - failed to set priority. This might cause loss of data...
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (os_linux_zero.cpp:270), pid=3814, tid=1090290800
#  fatal error: caught unhandled signal 11
#
# JRE version: 6.0_24-b24
# Java VM: OpenJDK Zero VM (20.0-b12 mixed mode linux-arm )
# Derivative: IcedTea6 1.11.1
# Distribution: Ubuntu precise (development branch), package 6b24-1.11.1-4ubuntu2
# An error report file with more information is saved as:
# /home/miniand/kinect/OpenNI/Platform/Linux/Redist/OpenNI-Bin-Dev-Linux-Arm-v1.5.4.0/Samples/Bin/Arm-Release/hs_err_pid3814.log
#

Hope someone find this first step useful and if someone already solved the depth image mistery let me know... 

alex barchiesi

13 comments:

  1. Thanks a lot for this tutorial :)
    Would you mind adding the commands
    cd ~/kinect/SensorKinect/Platform/Linux/Redist/Sensor-Bin-Linux-Arm-v5.1.2.1
    sudo ./install.sh
    after switching the USB interface. It is obvious that you need to do that but if you just follow the tutorial, one might not think about that

    ReplyDelete
    Replies
    1. Thanks for the comment, did you succeed in having the GUI working ?
      what machine are you using by the way ?

      ciao ale

      Delete
    2. This comment has been removed by the author.

      Delete
    3. I am using gumstix on a TurtleCore. I did not try to get the GUI to work, my goal is to get the turtlebot stack on ROS groovy working. Since they changed the dependencies very recently, I might need to recompile. Will do that over night today.

      Delete
  2. Edit the file under ~/kinect/SensorKinect/Platform/Linux/Redist/Sensor-Bin-Linux-Arm-v5.1.2.1

    The line :
    ;UsbInterface=2
    as
    UsbInterface=1

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. This didn't work in my system. Any other suggestion?

      Delete
  3. Hi,

    I followed your tutorial to run the Kinect on my Beaglebone but when I run ./Sample-NiSimpleRead I get the message: UpdateData failed: A timeout has occurred when waiting for new data!

    Do you have any clue as to why?

    ReplyDelete
  4. I got the message : UpdateData failed: A timeout has occurred when waiting for new data!

    Do you have any solution?

    ReplyDelete
  5. hello, thank you, I'm trying to compile SensorKinect on the raspberry pi 3, and I'm getting this error:
    make[1]: *** [Arm-Release/XnSensorDepthGenerator.o] Error 1
    make[1]: Leaving directory '/home/hamzapi3/kinect/SensorKinect/Platform/Linux/Build/XnDeviceSensorV2'
    Makefile:48: recipe for target 'XnDeviceSensorV2' failed
    make: *** [XnDeviceSensorV2] Error 2
    make: Leaving directory '/home/hamzapi3/kinect/SensorKinect/Platform/Linux/Build'

    ReplyDelete
  6. I also ran across the same error as the post above me.

    Find the solution here https://github.com/avin2/SensorKinect/pull/5/files

    Change the two files and it should compile fine.

    ReplyDelete
  7. This comment has been removed by a blog administrator.

    ReplyDelete
  8. This comment has been removed by a blog administrator.

    ReplyDelete