Kinect tracks the nearest 3d point
in
Contributed Library Questions
•
8 months ago
hello
there is a fragment from simple open ni library example : alternative 3d viewpoint.
In this , i simply want to use the nearest 3d point value from the kinect.
------------------------------------------
PImage rgbImage = context.rgbImage();
int[] depthMap = context.depthMap();
int steps = 3; // to speed up the drawing, draw every third point
int index;
PVector realWorldPoint;
color pixelColor;
strokeWeight(steps);
translate(0,0,-1000); // set the rotation center of the scene 1000 infront of the camera
PVector[] realWorldMap = context.depthMapRealWorld();
for(int y=0;y < context.depthHeight();y+=steps)
{
for(int x=0;x < context.depthWidth();x+=steps)
{
index = x + y * context.depthWidth();
if(depthMap[index] > 0)
{
// get the color of the point
pixelColor = rgbImage.pixels[index];
stroke(pixelColor);
// draw the projected point
realWorldPoint = realWorldMap[index];
point(realWorldPoint.x,realWorldPoint.y,realWorldPoint.z);
// make realworld z negative, in the 3d drawing coordsystem +z points in the direction of the eye
println(max(realWorldPoint.z));
}
}
}
// draw the kinect cam
context.drawCamFrustum();
}
---------------------
i use realWorldPoint in this case, but realWorldPoint is a PVector array.
max using is for float[] and int[] , i can't use it with realWorldPoint.z ? realWorldPoint.z is a float array, isn't it?
thanks for your attention
1