Reading users' bounding boxes and center of mass
In this recipe, we are going to expand on the preceding recipe by showing the bounding box and the center of visual mass (COM) of a user. The bounding box of a user shows the size and location of a user in screen and, for any user, the center of the visual mass is the center of distribution of the pixels.
More precisely, its x position is equal to the average of all the users' pixels x position, and its y position is equal to the average of all the users' pixels y position.
Almost the same is true about its z position, which is equal to the average of all the depth values of users' pixels.
Getting ready
Create a project in Visual Studio and prepare it for working with OpenNI and NiTE using the Create a project in Visual Studio 2010 recipe in Chapter 2, OpenNI and C++, and then configure Visual Studio to use OpenGL using the Configuring Visual Studio 2010 to use OpenGL recipe in the previous chapter.
Then copy the code from the Identifying and coloring...