CUDA

We will start with installing Cuda first :). There are two options to go about this, (i) install Cuda from the package manager by adding the Nvidia repos to the sources list, (ii) Install from .run file. We will be using the package manager for installing Cuda. I have installed Cuda using both the package manager and the .run file; believe when I say this, it is much less of an headache with the package manager.

First lets make sure we are set to install CUDA

lspci | grep -i nvidia

This checks to make sure there is an Nvidia device in your computer. Here is my output...

Navigate to where you downloaded the .deb file ie "cd ~/Downloads/" in the terminal. Run:

sudo dpkg -i cuda-repo-<distro>_<version>_<architecture>.deb

sudo apt-get update

Now here is when things get tricky. Cuda 6 was released a few days ago, and I'm not 100% sure if its gonna play nice with OpenCV. So for now we will go with Cuda 5.5.
To install Cuda 5.5:

sudo apt-get install cuda-5-5

Note: This command did not work for me... it complained about the dependency issues that didn't make a whole lot of sense. The way I installed it was:

sudo apt-get install aptitude
sudo aptitude install cuda-5-5

I allowed aptitude to continue with the installation, as it took care all of the dependency issues for me. I am also not responsible if you wreck your desktop...!!!
Reboot when the installation is finished.

Building and installing the Primesense modules is strangely familiar to that of OpenNI... Once again follow the directions of the README.

Linux:
Requirements:
1) GCC 4.x
From: http://gcc.gnu.org/releases.html
Or via apt:
sudo apt-get install g++
2) Python 2.6+/3.x
From: http://www.python.org/download/
Or via apt:
sudo apt-get install python
3) OpenNI 1.5.x.x
From: http://www.openni.org/Downloads/OpenNIModules.aspx
Building Sensor:
1) Go into the directory: "Platform/Linux/CreateRedist".
Run the script: "./RedistMaker".
This will compile everything and create a redist package in the "Platform/Linux/Redist" directory.
It will also create a distribution in the "Platform/Linux/CreateRedist/Final" directory.
2) Go into the directory: "Platform/Linux/Redist".
Run the script: "sudo ./install.sh" (needs to run as root)
The install script copies key files to the following location:
Libs into: /usr/lib
Bins into: /usr/bin
Config files into: /usr/etc/primesense
USB rules into: /etc/udev/rules.d
Logs will be created in: /var/log/primesense
To build the package manually, you can run "make" in the "Platform\Linux\Build" directory.
Important: Please note that even though the directory is called Linux, you can also use it to compile it for 64-bit targets and pretty much any other linux based environment.

Your window should look similar to this after you specify where the source is and were you want to build the binaries and after pressing configure.

Select the packages you would like install. Hit configure again. Check to make sure that the cmake output is listing dependencies as YES. Otherwise it will not get built with OpenCV. I did have to edit the CUDA_TOOLKIT_ROOT_DIR to /usr/local/cuda-5-5 for cmake to find the correct libraries.

For java:

export JAVA_HOME=/usr/lib/jvm/java-7-oracle

Hit configure once again. If you are satisfied with the results we are ready to build!

Make sure you are in your 'build' directory where the make files reside.