In an earlier post I explained how to get PrimeSense's NITE up and running and how to use the samples they provided. Now some people might be thinking "cool, but how can I use this?" I thought using NITE hand tracking to control the cursor would be a good and simple demonstration.
The linux kernel provides a means to create userspace input drivers using a feature called uinput. If you compile your kernel with uinput enabled as a module you can then simply:
to load the uinput module. Once the module is loaded you can use the piece of code I've embedded below to convert the coordinates output by the NITE code into actual mouse/cursor movement. In short:
(1) download the code below
(2) save it as ~/kinect/NITE/Nite-22.214.171.124/Samples/SingleControl/main.cpp (you might want to back up the original)
cd ~/kinect/NITE/Nite-126.96.36.199 && make
(4)Note: do the following as root or using sudo
(5)Perform a focus gesture to start the hand tracking (check out my video above to see how to do that)
At this point you should be able to do what I do in the video above. You can also extend the code to generate mouse clicks, keystrokes, etc. Have fun.
At some point dropbox ate the public link for the source code I was using before and in the process of restoring from an old backup the formatting of the code below got a bit mangled... in any case here's a gist of what I salvaged: