Skip to content

Instantly share code, notes, and snippets.

@kamend
Created April 4, 2014 09:58
Show Gist options
  • Save kamend/9971557 to your computer and use it in GitHub Desktop.
Save kamend/9971557 to your computer and use it in GitHub Desktop.
This is how to generate point cloud mesh from the rawDepthPixels data, using Openframeworks and KinectCommonBridge
mesh.clear();
mesh.setMode(OF_PRIMITIVE_POINTS);
for(int x=0;x<640;x+=2) {
for(int y=0;y<480;y+=2) {
int index = x + y * 640;
short depth = kinect.getRawDepthPixelsRef().getPixels()[index];
if(depth > minDistance && depth < maxDistance) {
Vector4 world = NuiTransformDepthImageToSkeleton(x,y,kinect.getRawDepthPixelsRef().getPixels()[index] << 3,NUI_IMAGE_RESOLUTION_640x480);
float scale = 500.0f;
mesh.addVertex(ofVec3f(world.x,world.y,-world.z)*scale);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment