Foreword: I am still in a Christmas mood. ;-) And considering a really huge interest in such "sparkling marriage" (Delphi and Kinect) and a very positive feedback from you guys, - I made some quick changes in the 3D demo, (which you should already know well), and added even more cool features. This is what was done:
- Most important thing: now you can grab 3D frames (3D data + 2D mapping), save it and run on a computer without Kinect! No need to have any drivers installed. You can give this program to your friends and they will be able to see your 3D pictures! :-)
- 2D to 3D mapping is fixed. It's still not ideal, but much better then before.
- You can switch on/off 2D and3D viewing mode. Pretty handy.
- It is possible to manage motor and change tilt of the Kinect.
- Newest version of Kinect.pas is included (Simon J Stuart - thank you for the update! More info about TKinect project is here)
- Bug fixed here and there.
EXE is precompiled as usual, so can be used right away. Here is the link to EXE and the source code in Delphi:
How to save/load3D frame
It's pretty easy actually. Select Frame --> Save from the main menu (you didn't expected anything else, yea?), then give a name without file extension. Program will grab the current frame and create 2 BMP files: one for 2D and the other for the 3D data (yes, they are just regular BMP files).
Those files would have a special suffix inside. A keywords: _KinectRGB and _KinectDepth.
If you want to open a frame: go to Frame --> Load and point to any of those two files. Program would find it's way to load them properly :-)
3D view on/off
There is nothing to explain here really.
Some sample images are included in the package (e.g. a nice 3D view of my corridor) :-)
This is it. Have fun and definitely drink enough to celebrate a New Year properly!
Well well well... All signs in the Sky and on the Earth clearly say: it's a Christmas time! So it's time to have some rest and fun, and definitely nothing can be better then to spend some time with family and a new toy. ;-) Actually it's my son who got the XBox with the Kinect, but well... let parents have some fun too, right!
It's not like I am trying to reinvent the wheel (there are plenty of applications using Kinect on PC), but recently I did not find any nice examples of how this incredibly cool thing can be used with Delphi. And you don't think I can leave it "just like that", don't you? ;-) So see the results below (video) and so more technical details of both applications (2D and 3D visualization). So as for today there will be no hacking, boys and girls, but just pure awesome 3D-virtual-reality joy... :-)
Ok, so you want to try to get those samples tweak them probably and run your own code? There is nothing more simple:
- Computer (PC) with hardware accelerated graphic card (anything with OPENGL hardware rendering).
- Kinect controller :-)
- Kinect windows drivers (NUI Group) http://nuigroup.com/...
- Simon J Stuart's TKinect component for Delphi taken from here: http://www.lakraven.com/... (you did EXCELLENT work, dude!)
- Super fast Delphi 2D Image processing library graphics32: http://www.graphics32.org/...
- GLScene (Delphi OPENGL library): http://glscene.sourceforge.net/...
Everything is installing like a charm. Some subtle obstacles with GLScene, but nothing too complicated to be mentioned really. Important: Before you run anything - be sure that the Kinect device is recognizable by your computer (check it in you Device Management panel).
Ach, almost forgotten: take the source files of my applications from here:
- 2D data visualization: http://itsecuritylab.eu/files/kinect/kinect_delphi_2d.zip
- 3D data visualization: http://itsecuritylab.eu/files/kinect/kinect_delphi_3dpoints.zip
Running all that stuff
Now you can try to compile and test both applications. More details about how those application can be used you have already seeing in the movie. Pre-compiled exe files are already included into ZIP packages, just for your convenience. So at the end this is what we have:
2D data visualization
The experiment showing how to collect, process and draw the Kinect's data on the screen. Rather typical,- you've seen it before for sure. Additional challenge was to write a function which would be able to "track blobs" - areas on the screen with similar pixels. This is needed to track your hands, fingers, nose or whatever you want to use. It is far far from ideal, but surprisingly works!
One more remark: this DOF function, selecting pixels in certain 3D range - is a part of the application, not the Kinect hardware.
I also hope you will forgive me such eeee... "untypical" way of getting depth data from pixel's color by such innocent transformation: RGB -> HLS -> [custom function] -> range [0..255]
3D data visualization
You can see my room (and actually yours too) in 3D in wobbling 3D virtual screen, containing tiny colorful dots :-) Do you like my Xmass tree?
So you see, Delphi is so nice and (important!) easy language (appropriate for lazy coders), so even writing pretty complex applications can take you just couple of hours. I also hope now even more people will start playing with Kinect and do some cool things, [so more happiness will come on Earth this Christmas, etc, etc.]. Remember: You are the controller®. Amen. :-)
This is it. Let me know it you like those crazy apps, and well... Have a nice Christmas and a happy New Year! :-)