SimpleUserTracker using PrimeSense + OpenNI + NiTE in Xcode

Published on

NiTE comes with a bunch of sample projects. This post will show you how to get up and running with the C++ SimpleUserTracker project in Xcode on Mac OS X (Mountain Lion). Once you are set-up, you should be able to swap out the project files for any of the other NiTE or OpenNI sample projects.

  • First off, download and unzip the OpenNI SDK and the NiTE middleware libraries.
  • Create a new Xcode Project for OS X and indicate that it will be a Command Line Tool. Name your project "SimpleUserTracker", make sure the "Type" is set to C++ and "Use Automatic Reference Counting" is not checked.
  • Include the OpenNI and NiTE frameworks by first creating a new Group in the project. To do this, select File -> New -> Group. Call it "Frameworks".
  • Add OpenNI: Right-click on the Frameworks group and select Add Files to "SimpleUserTracker". Browse into Redist in the OpenNI folder that you downloaded and include all the files.
  • Add NiTE: Right-click on the Frameworks group and select Add Files to "SimpleUserTracker". Browse into Redist in the NiTE folder that you downloaded and include all the files.


  • Remove unnecessary linked libraries: select the Target and go to Build Phases. It is likely that Xcode included some .dylibs automatically in Link Binaries With Libraries. Remove everything except for libOpenNI2.dylib and libNiTE2.dylib. Use the "-" symbol to remove a library.
  • Add OpenGL and GLUT: Again under Link Binaries With Libraries, add OpenGL.framework and GLUT.framework by pressing the "+" symbol and searching for the frameworks. Ensure that all the libraries are set to "Required".


  • Next we need to add "Copy Files" Build Phases for the files we added into frameworks. Still in the Target's Build Phases, select Add Build Phase -> Add Copy Files. Set the destination to "Executables". Use the "+" symbol to include all the files in the Frameworks group. Ignore the folders (NiTE2 and OpenNI2) for now.


  • Add another Copy Files build phase and set the destination to "Executables". Set the Subpath to OpenNI2/Drivers and include all the files that are in the OpenNI/Drivers folder.


  • Add another Copy Files build phase and set the destination to "Executables". Set the Subpath to NiTE2 and include all the files that are in the NiTE2 folder. Ignore the Data folder, we'll do it in the next step.


  • Add another Copy Files build phase and set the destination to "Executables". Set the Subpath to NiTE2/Data and include all the files that are in the NiTE2/Data folder.


  • Next we need to include the header files. Create a new Group in the project, select File -> New -> Group. Call it "Includes".
  • Create two sub-Groups under Includes. One called OpenNI and the other NiTE. To do this, right-click on "Includes" and select New Group.
  • Add OpenNI includes: Right-click on the OpenNI sub-group and select Add Files to "SimpleUserTracker". Browse into Include in the OpenNI folder that you downloaded and include all the files.
  • Add NiTE includes: Right-click on the NiTE sub-group and select Add Files to "SimpleUserTracker". Browse into Include in the NiTE folder that you downloaded and include all the files.


  • Delete the main.cpp file that Xcode generated for you. Right-click on main.cpp and select Delete, choose "Move To Trash".
  • Add the C++ code provided by NiTE. Right-click on the project group "SimpleUserTracker" and select Add Files to "SimpleUserTracker". Browse to Samples -> SimpleUserTracker in the NiTE folder you downloaded. Select the main.cpp and NiteSampleUtilities.h files. For Destination, make sure "Copy items into destination's group folder (if needed)" is checked.
  • Build your project, by selecting Product -> Build. Xcode will prompt you to fix two includes, go with the suggested fixes.
  • Plugin your PrimeSense Carmine sensor and run the project.

Your environment should now be setup to run any of the provided NiTE or OpenNI sample projects - simply switch out the project's main files.