How to install and use OpenNI2

I use OpenNI to read from a Primesense RD1.09 depth camera. Ubuntu has OpenNI library packages in its archive, but this is the older OpenNI 1.x. I find its API and device support lacking and so prefer to use OpenNI2. Also, there is no need to build the newer OpenNI2 from source since pre-built packages are available.

Installing and using OpenNI2 with Primesense is easy:

  • Download: The pre-built SDK file for your Linux can be downloaded from the OpenNI homepage. It is available for x86, x64 and ARM. I downloaded the x64 SDK file and unzipped it.

  • OpenNI directory: Your OpenNI code and programs will look for header and library files from this unzipped directory. So, move it to a suitable location. I like to keep it in ~/lib

  • Install: Run the installer from the unzipped directory:

$ sudo ./

All this does is to place the UDEV rules for the Primesense camera in /etc/udev/rules.d. Your camera is now ready to be used!

  • Camera detection: Plug in your depth camera to a USB port on your computer. Check if the camera is detected using lsusb command. My camera is listed as ASUS in this listing when it is detected.

  • Simple viewer: Run the simple viewer provided in OpenNI. You should be able to view depth and color (RGB) images now:

$ cd Tools
$ ./NiViewer
  • Device error: If NiViewer failed with a no devices found error, then a solution I discovered is described here.

  • Color image error: If NiViewer only shows depth image, but no color image: this sometimes happens. Unplug and plug in the camera and try again.

  • Header and libraries: You will find a OpenNIDevEnvironment file containing the paths for two environment variables: OPENNI2_INCLUDE and OPENNI2_REDIST. Use these include and library paths when you build your own C++ code that uses OpenNI. To link with OpenNI libraries add the -lOpenNI2 directive.

  • Sample C++ project: If you need help starting off, I have a CMake project with code for reading from Primesense camera here.

Tried with: OpenNI, Primesense RD1.09 and Ubuntu 14.04

2 thoughts on “How to install and use OpenNI2”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s