Ofxkinect PointCloud setting a threshold

#1

Hi,
Is there a way to set threshold value to the point cloud generated by kinect such that I can get points only in a certain distance range ?

I have been going through the example file and trying to figure out how do i make the mesh add vertex within a threshold

int step = 10;
for ( int y = 0; y < h; y += step) {
for ( int x = 0; x < w; x += step) {
if (kinect.getDistanceAt(x, y) > 0) {
mesh.addColor(kinect.getColorAt(x,y));
mesh.addVertex(kinect.getWorldCoordinateAt(x, y));
}
}
}

I am very new to OF

#2

this will check the value you get from kinect.getDistanceAt(x,y) to be between your minThreshold and maxThreshold integers.

int step = 10;
int minThresh = 100; //  change this for front clipping
int maxThresh = 1000; // change this for back clipping
for ( int y = 0; y < h; y += step) {
  for ( int x = 0; x < w; x += step) {
    if (kinect.getDistanceAt(x, y) > minThresh && kinect.getDistanceAt(x, y) < maxThresh) {
      mesh.addColor(kinect.getColorAt(x,y));
      mesh.addVertex(kinect.getWorldCoordinateAt(x, y));
    }
  }
}

btw if you use three ``` before and after a code segment then it will render your text as code

1 Like
#3

This Works!
Can’t thank you enough :slight_smile:

If not for folks like you, I would have given up on OF

1 Like
#4

really happy to help, post more questions if you have them :smiley:

I posted a video tutorial walk thru on youtube looking at the kinect and oF

sourcecode is online here;

1 Like