OpenNI 1.5.4
|
Basic Functions: initialize, create a node and read data
The following code illustrates the basic functionality of OpenNI. It initializes a Context object, creates a single Depth node, and reads data from it.
XnStatus nRetVal = XN_STATUS_OK; xn::Context context; // Initialize context object nRetVal = context.Init(); // TODO: check error code // Create a DepthGenerator node xn::DepthGenerator depth; nRetVal = depth.Create(context); // TODO: check error code // Make it start generating data nRetVal = context.StartGeneratingAll(); // TODO: check error code // Main loop while (bShouldRun) { // Wait for new data to be available nRetVal = context.WaitOneUpdateAll(depth); if (nRetVal != XN_STATUS_OK) { printf("Failed updating data: %s\n", xnGetStatusString(nRetVal)); continue; } // Take current depth map const XnDepthPixel* pDepthMap = depth.GetDepthMap(); // TODO: process depth map } // Clean-up context.Shutdown();
Generated on Wed May 16 2012 10:16:06 for OpenNI 1.5.4 by 1.7.5.1