How to get yourself set up for kinect developing (on Ubuntu):
1) Download CodeBlocks
The example programs from openframeworks are formatted for codeblocks, and it has a nice IDE, so make your life easier, and download it.
sudo apt-get install codeblocks
2) Download libusb
This is to communicate with the kinect
sudo apt-get install libusb-1.0-0-dev
3) Download openframeworks
This is the main development API we'll be using. I makes a lot of special effects easier. Make a folder called openframeworks on your desktop and extract the contents there
If you are running ubuntu on a 32-bit machine: http://www.openframeworks.cc/versions/preRelease_v0.062/of_preRelease_v0062_linux_FAT.tar.gz
If you are running ubuntu on a 64-bit machine: http://www.openframeworks.cc/versions/preRelease_v0.062/of_preRelease_v0062_linux64_FAT.tar.gz
The commands below take care of most of the libraries openframeworks needs
sudo openframeworks/scripts/linux/ubuntu/install_dependencies.sh
sudo openframeworks/scripts/linux/ubuntu/install_codeblocks.sh
4) Download arturo's ofxKinect
This is an openframeworks example project file that communicates with the kinect. This creates a folder ofxKinect with a kinectExample.cbp file inside
cd openframeworks/apps/examples
sudo apt-get install git-core
git clone https://github.com/arturoc/ofxKinect.git
cd ofxKinect
sudo codeblocks
NOTE: Codeblocks will do weird things sometimes if not run as sudo.
5) Set up fakenect (skip to 6 if you have a kinect attached to your computer)
Now download a fakenect video/depth info. file
http://dl.dropbox.com/u/15736519/thanksgiving0.tar.bz2
Unpack the contents of thanksgiving to the thanksgiving0 folder on your desktop
git clone https://github.com/OpenKinect/libfreenect.git
cd libfreenect
mkdir build
sudo apt-get install cmake
cd build
cmake ..
make
cd lib
cp fakenect ~/Desktop -R
mkdir legitnect ~/Desktop
cp libfreenect.so* ~/Desktop/legitnect
export LD_PRELOAD=/home/<YOUR USERNAME>/Desktop/fakenect/libfreenect.so.0.0.1
export FAKENECT_PATH=/home/<YOUR USERNAME>/Desktop/thanksgiving0
NOTE: Replace <YOUR USERNAME> in the path above with your username
Open src/ofxKinect/src/ofxKinect.cpp and make this change:
void ofxKinect::update(){
if(!kinectContext){
return;
}
freenect_process_events(kinectContext); <<<ADD THIS LINE
Now go to Project->Build Options... click the Linker settings tab, and in the Other linker options window add:
-rdynamic /home/<Your username>/Desktop/fakenect/libfreenect.so.0.0
=====OR======
-rdynamic /home/<Your username>/Desktop/legitnect/libfreenect.so.0.0
...depending on whether you have a kinect attached to the computer or not.
In the project panel on the left, go to addons->ofxKinect->libfreenect and remove file from the project.
Now build and compile. When you run the program from the command line, add
export LD_PRELOAD=<path to either fakenect's libfreenect.so.0.0 or regular libfreenect.so.0.0>
export FAKENECT_PATH=<path to your pre-recorded RGB/depth info>
then run the program.
6) Debug the program in CodeBlocks
In codeblocks, go to File->Open... and navigate to openframeworks/apps/examples/ofxKinect/ and choose kinectExample.cbp. Hit F9 to compile and build the program.
You should see output from the pre-recorded thanksgiving scene you downloaded, along with the depth information.
Open up testApp.cpp and start hacking away!
NOTE: Most likely Codeblocks won't compile the file on the first try. If you get this error message:
WARNING: Can't read file's timestamp: /home/geroge/Desktop/OpenFrameworks/apps/examples/ofxKinect/src/ofxKinect/libs/libfreenect/accelerometers.c
WARNING: Can't read file's timestamp: /home/geroge/Desktop/OpenFrameworks/apps/examples/ofxKinect/src/ofxKinect/libs/libfreenect/inits.c
WARNING: Can't read file's timestamp: /home/geroge/Desktop/OpenFrameworks/apps/examples/ofxKinect/src/ofxKinect/libs/libfreenect/motors.c
Linking console executable: bin/kinectExample_debug
g++: obj/Debug/src/ofxKinect/libs/libfreenect/accelerometers.o: No such file or directory
g++: obj/Debug/src/ofxKinect/libs/libfreenect/inits.o: No such file or directory
g++: obj/Debug/src/ofxKinect/libs/libfreenect/motors.o: No such file or directory
Then open kinectExample.cbp in gedit and delete the following lines:
<Unit filename="src/ofxKinect/libs/libfreenect/accelerometers.c">
<Option compilerVar="CC" />
<Option virtualFolder="addons/ofxKinect/libfreenect/" />
</Unit>
<Unit filename="src/ofxKinect/libs/libfreenect/inits.c">
<Option compilerVar="CC" />
<Option virtualFolder="addons/ofxKinect/libfreenect/" />
</Unit>
<Unit filename="src/ofxKinect/libs/libfreenect/motors.c">
<Option compilerVar="CC" />
<Option virtualFolder="addons/ofxKinect/libfreenect/" />
</Unit>
Then you might get an error like this:
ld||cannot find -lunicap|
Type:
sudo apt-get install libunicap-2 libunicapgtk-2 libucil-2 ucview
Go to Project->Build Options... then the Linker Settings tab, and in the Link Libraries window, choose unicap and click the delete button. Click ok to leave the Build Options window.
Now, in the Projects window on the left side of the screen, right click on the kinectExample project, and choose Add a file... Add ofxKinect/src/ofxKinect/libs/libfreenect/tilt.c
Now, open ofxKinect.cpp, and comment out ofSleepMillis(20); in ofxKinect::threadedFunction(). This takes care of a flicker problem.
7) Get the helloWorld Kinect program put together by the hive
http://www.hive13.org/svn/helloKinect/
You'll have to have a username and password. Email someone at the hive to get one.