This is a playground project to try out some features of the OpenNI2 project along with the primesense python wrapper on a Raspberry Pi 3 Model B+. As a sensor I am using the ASUS Xtion PRO LIVE.
- Raspberry Pi 3 Model B+
- ASUS Xtion PRO LIVE RGB and depth sensor
As a first step I wanted the Raspberry Pi (with Raspbian installed), OpenNI2 and the ASUS sensor to be working together successfully. To test that I used the sample program SimpleRead which comes with the OpenNI2 project (inside the Samples
subfolder). To be able to execute it I had to build and install the OpenNI2 SDK on my Raspberry Pi.
First I cloned the OpenNI2 project's develop branch onto my Raspberry Pi.
git clone --single-branch -b develop https://github.com/occipital/OpenNI2.git
Then I installed the dependencies listed in the prerequisites section of the OpenNI2 README.
Next I had to make some adjustments to be able to compile and afterwards install OpenNI2 successfully. The sources that helped me to figure it out are listed below.
- OpenNI2 README itself, especially the build prerequisites when building for Linux and the packaging part.
- Getting Raspberry Pi, OpenNI2, and Asus Xtion Pro Live To Work Together
- Depth Imaging with the Asus Xtion Pro Live Sensor and the KIPR Link (Part 1)
- OpenNI2.2 ARM Binaries on Raspberry Pi
- Problem when run 'ReleaseVersion.py': subprocess.CalledProcessError
- Issue running ReleaseVersion.py
- GCC 7.2 Array subscript is below array bounds
- in file
/OpenNI2/ThirdParty/PSCommon/BuildSystem/Platform.Arm
- I commented out line 4
CFLAGS += -march=armv7-a -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp #-mcpu=cortex-a8
and instead addedCFLAGS += -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard
- commented out line 12
DEFINES += XN_NEON
- I commented out line 4
- in file
/OpenNI2/Packaging/ReleaseVersion.py
- in lines 198 and 202 I changed the make calls by replacing the part where it says
'-j' + calc_jobs_number()
by just-j1
- furthermore I passed another parameter
ALLOW_WARNINGS=1
to the make calls
- in lines 198 and 202 I changed the make calls by replacing the part where it says
After those changes in the sources I was able to compile by navigating inside the folder /OpenNI2/Packaging
and then performing the command sudo python2 ReleaseVersion.py Arm
.
The results of the build can be found inside the folder OpenNI2/Packaging/Final
.
I extracted the installer archive inside the folder /usr/local/src
. By navigating inside the extracted folder and calling sudo chmod +x install.sh
and sudo ./install.sh
I was able to install the OpenNI2 SDK.
Next I tried out the example program SimpleRead
by navigating inside the folder Samples/Bin
and then calling sudo ./SimpleRead
. The result was a continuous stream of sensor data similar to one of the resources I used.
Next I tested some sample projects using the primesense python wrapper and OpenCV to get some visual results. The original examples can be found here and are only customized a little bit.
To be able to run the examples I followed this guide to install OpenCV on my Raspberry Pi, first. Inside the virtual environment cv
(created during the guide) I also installed the primesense
package using the command pip install primesense
.
The different stream examples can be found inside the examples subfolder. To run one example just run main.py
and pass one of the available stream types (rgb
, depth
or ir
) as a positional argument (e.g. python main.py rgb
).