Capturing raw data from depth-sensing cameras

Now that you have installed the prerequisite libraries and drivers, we will demonstrate how to capture raw data from your depth-sensing camera.

How to do it...

To capture sensor data directly in a binary format, implement the following function:

void writeDepthBuffer(openni::VideoFrameRef depthFrame){ static int depth_buffer_counter=0; char file_name [512]; sprintf(file_name, "%s%d.bin", "depth_frame", depth_buffer_counter); openni::DepthPixel *depthPixels = new openni::DepthPixel[depthFrame.getHeight()*depthFrame.getWidth()]; memcpy(depthPixels, depthFrame.getData(), depthFrame.getHeight()*depthFrame.getWidth()*sizeof(uint16_t)); std::fstream myFile (file_name, std::ios::out |std::ios::binary); myFile.write ...

Get OpenGL Data Visualization Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.