Install OpenKinect
There is a lot of information online documenting the installation of these two libraries, particularly the Installation Guide for OpenCV and the Getting Started Guide for OpenKinect but this page will go over the general installation instructions for Ubuntu. Luckily, OpenKinect is in the main Ubuntu repositories, so all that is needed is:
$ sudo apt-get install freenect
and if you want the python bindings:
$ sudo apt-get install python-freenect
The source code can also be installed directly from their git website with:
$ git clone git://github.com/OpenKinect/libfreenect.git
however this option also requires building the source, so only do this if you have experience with git or refer to the Getting Started Guide for OpenKinect.
Install OpenCV
It is slightly more complex to install the OpenCV library. Assuming you have all the prerequisite libraries and tools (please check the Getting Started guide if you are not sure) you must first go to the OpenCV SourceForge page to download the tarball (again for Linux/Ubuntu only - please Google installation instructions for your particular operating system if yours differs). This is the most recent edition at the time of writing (5/16/12), but they typically release large revisions every year.
To untar (assuming OpenCV 2.4):
$ tar -xvjf OpenCV-2.4.0.tar.bz2
Another option is to get the latest developmental release by using a Subversion client:
$ svn co http://code.opencv.org/svn/opencv/trunk/opencv
Then after 'cd'-ing into the newly created directory, you have to configure it using cmake as follows:
$ mkdir release
$ cd release
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ..
Again, this is meant to be a very quick runthrough of the installation process and is definitely not meant to be comprehensive. Please refer to the links to the installation guides of the individual libraries for any questions or help.
Example Makefile
all: your_file_names
CFLAGS=-fPIC -g -Wall `pkg-config --cflags opencv`
LIBS = `pkg-config --libs opencv`
INCLUDE = -I/usr/local/include/libfreenect
FREE_LIBS = -L/usr/local/lib -lfreenect
your_additional_includes.o: your_additional_includes.c
$(CXX) -c your_additional_includes.c
your_project_name: additional_includes.o your_project_name.cpp
$(CXX) $(INCLUDE) $(CFLAGS) $? -o $@ $(LIBS) $(FREE_LIBS)
clean:
rm -rf *.o your_project_name
If this is confusing, here is the actual makefile we used:
all: ye_ge423_proj
CFLAGS=-fPIC -g -Wall `pkg-config --cflags opencv`
LIBS = `pkg-config --libs opencv`
INCLUDE = -I/usr/local/include/libfreenect
FREE_LIBS = -L/usr/local/lib -lfreenect
netapi.o: netapi.c
$(CXX) -c netapi.c
ye_ge423_proj: netapi.o ye_ge423_proj.cpp
$(CXX) $(INCLUDE) $(CFLAGS) $? -o $@ $(LIBS) $(FREE_LIBS)
clean:
rm -rf *.o ye_ge423_proj