0

I have the Xbox Kinect v2. I need to do the following:

  1. Take a single depth measurement of whatever is in front of it. Think of this like taking a picture, but for depth values.
  2. Output the depth values for each pixel to a file. I'm going to use these values for post processing, so I need each depth value to be associated with an x-y coordinate.

I am new to Kinect for Processing, but I am scouring the documentation and online examples now. I'm hoping someone more experienced can figure this out faster.

JohnSmithy1266
  • 407
  • 1
  • 6
  • 15

1 Answers1

0

With Kinectv2, I had the most success with https://github.com/shiffman/OpenKinect-for-Processing

Use the DepthPointCloud2 example as a base. (ignore the rendermode==2 portion) then modify the if-loops as follows:

 StringList printer = new StringList();
 for (int x = 0; x < kinect2.depthWidth; x += skip) {
   for (int y = 0; y < kinect2.depthHeight; y += skip) {
     int offset = x + y * kinect2.depthWidth;
     PVector point = depthToPointCloudPos(x, y, depth[offset]);
     if (point.mag() != 0) {
       printer.append(point.x +","+ point.y +","+ point.z);
     }
   }
 }
 String[] printOut = printer.array();
 String path = "scan" + counter + ".xyz";
 saveStrings(path, printOut);
 println("Pointcloud :: outputted to file :: " + path);

Basically you set up a StringList, then adding your xyz String to it every time it would otherwise be drawing a point, convert it to a conventional array once the scan is done, and dump it to a .txt/.xyz with saveStrings

Might want to move the entire thing so its triggered by a KeyPressed() instead though.

AiSard
  • 23
  • 2