Starting the device
Now it's time to initialize the Kinect device in our own application. There will be a lot of Kinect API functions for us to use without any preparatory lessons. But don't worry; you will find that most of them are self-explanatory and easy to understand. Also, we will introduce each function and their parameters in the Understanding the code section.
We will continue working on the framework we have just created, so existing code lines will not be listed here again.
Initializing and using Kinect in C++
Now we can try to find and start the Kinect device in our own C++ framework.
Add the following include files:
#include <MSHTML.h> #include <NuiApi.h> #include <sstream>
Add the necessary global variables for use in all functions:
INuiSensor* context = NULL; HANDLE colorStreamHandle = NULL; HANDLE depthStreamHandle = NULL; std::string hudText;
Add an
initializeKinect()
function, which will be called before the GLUT main loop. It returnsfalse
if the process fails...