Tuesday, April 26, 2011

Loose details about coding for the Kinect with OpenNI


Documentation


The first thing to be said here is that if you're looking for an API reference, I haven't been able to find it online. However, it's all on a help file in OpenNI's start menu group.

When it comes to OpenNI documentation, there's plenty of it, even though it's not very good, in general. The most extreme example of this I've found is
typedef XnUInt16 XnLabel
Defines the label type
Okay, PrimeSense... your users can read C. They can see that it defines a label type. What they want to know is: what does it label? Why is the label an unsigned 16-bit integer and not, say... a string? You need to go look at the code samples in order to figure that one out. In this case, it turns out that it is a label for which user is present in each image pixel. A pixel containing a 0 has no user present, a pixel containing a 1 belongs to user 1, and so on.

From reading the documentation, it's also not very clear when, exactly, the callbacks are called. For instance, the LostUser callback isn't called until roughly ten seconds after the user has left the frame, although it will be called immediately if the sensor is completely obscured.

The "Psi" pose

The Kinect provides an OpenNI UserGenerator, capable of pose detection. The only pose it can detect is named "Psi". This appears in the samples as a magic constant, without a single comment, which makes you wonder where it came from or which pose it is. It turns out that there actually is documentation describing this, but not in the API reference or the user guide, where you might look. It's actually in a PDF document called "NITE Algorithms", in NITE's program group, but I'll save you the time. You need to be standing up, with your arms making a 90º angle with your torso, and your forearms and hands pointing up, making you look like the greek letter, psi. Starting from this pose, and after a ~3 second calibration, you'll be able to track the user's skeleton.

And that's it, for today. I hope you found this useful.

Getting started with coding for the Kinect on Windows

Microsoft's Kinect has generated a lot of interest in the scientific and mod community and the good news is, it's not very hard (for a C or C++ programmer) to get started with coding for it, even if you don't want to wait until the official API is released, later this spring.

Tuesday, March 1, 2011

A quick heads-up for people migrating to Visual C++ 2010

If you've been using an older version of Visual C++, you've probably had a solution with one or more library projects you've written, and a project for the main program. To link these together, you probably right-clicked the main program's project, selected "Project Dependencies..." from the menu, chose whatever libraries you wanted the main project to link with, and you were done.

I've tried doing this in VC++ 2010, only to be baffled by a pretty large list of unresolved external symbols, even for libraries I was sure I'd set as dependencies. Fortunately, a Google search turned up these forum threads, where I've learned that you should now add the dependencies at "Project Properties -> Common Properties -> Framework and References", instead of using "Project Dependencies". So... why was this changed around? Was there something so wrong with the previous approach?

Saturday, February 5, 2011

Super Meat Boy, or how losing can be fun

You're in for something different today: a game review.




If you are not aware of it, Super Meat Boy is an award-winning independent game which is sure to strike a chord with you, if you like old school platformers, and probably even if you don't. It is, in a word, brilliant. And really hard. In fact, I'm pretty sure it is the hardest game I've ever played in my 10+ years of gaming. So what is it about, and what makes it so compelling?