Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
An interesting exercise is to measure the pixels of the user. As discussed in the Measuring Depth section of this chapter, the X and Y positions of the pixels do not coordinate to actual width or height measurements; however, it is possible to calculate them. Every camera has a field of view. The focal length and size of the camera's sensor determines the angles of the field. The Microsoft's Kinect SDK Programming Guide tells us that the view angles are 57 degrees horizontal and 43 vertical. Since we know the depth values, we can determine the width and height of a player using trigonometry, as illustrated in Figure 3-12, where we calculate a player's width.
Figure 3-12. Finding the player real world width
The process described below is not perfect and in certain circumstances can result in inaccurate and distorted values, however, so too is the data returned by Kinect. The inaccuracy is due to the simplicity of the calculations and they do not take into account other physical attributes of the player and space. Despite this, the values are accurate enough for most uses. The motivation here is to provide an introductory example of how Kinect data maps to the real world. You are encouraged to research the physics behind camera optics and field of view so that you can update this code to ensure the output is more accurate.