3D Point Cloud Capture with Kinect
Kinect connects well with Processing via USB, and Dan Shiffman’s tutorial covers all aspects of Kinect except how to record a motion sequence. Here, based on Shiffman’s code, is the code to get nice .csv files out of Kinect at about 10 frames per second. The key part is to write each vertex on a new line with nice commas, and to save the file each time we come to the end of the vertex array:
String[] p ;
p[int(offset)] = point.x+", "+point.y+", "+point.z; saveStrings("../3D/captures/"+date+"/frame"+frameCounter+".csv", p);
Note how the “../3D/captures/” creates a nice directory for each capture session, which starts and stops with the “r“ key. That’s important because it’s easy to get a huge pile of messy files otherwise. The “s” key saves a single frame, the “v” key turns preview on and off. Turning the preview off accelerates the frame rate, which means slower, smoother movements.
To make this program run, you also need the latest version of the openkinect library for Processing.
import org.openkinect.processing.*;
import java.nio.FloatBuffer;
The resulting point clouds can be beautifully loaded into Maya as particles using a small python script, and then they can be rendered out like any other particle system.
The Python script will be posted here shortly.