Converting the depth unit to millimetre
Until now, we have used the data of the depth stream relatively without knowing its real-world units; in this recipe, however, we are going to show you how it is possible to convert depth data into millimetre units. This could be used for generating point cloud, calculating distance, and so on.
First we try to find the depth value of the center pixel in the depth frame and then use the openni::CoordinateConverter
class to convert this value into a real-world millimetre unit.
Getting ready
Create a project in Visual Studio 2010 and prepare it for working with OpenNI using the Creating a project in Visual Studio 2010 recipe of Chapter 2, OpenNI and C++.
How to do it...
Add the following lines at the top of your source code (just below the
#include
lines):#include <conio.h>
Copy the
ReadLastCharOfLine()
andHandleStatus()
functions here from the last recipe.Then locate the following lines of code:
int _tmain(int argc, _TCHAR* argv[]) {
Write the following...