Kinect and processing, have to use frameRate to get a moving image. This can't be right?
in
Integration and Hardware
•
3 months ago
Hi,
I'm using kinect and processing at the moment and have a problem that keeps returning. I use the book 'Making things see' and there are a lot of examples in it.
But, my problem is that with this code it doesn't work. When I run the code it makes one picture of the scene and it seems like the code isn't active and looping after that. So I added frameRate(); to it but I don't think this is the solution to this problem.
The code is about making a line that is made by moving your hand in front of the kinect. I don't get a line. If i run it like this I get the comment that it seems like I'm mixing active and passive. After adding frameRate it runs but doesn't draw a line because frameRate keeps resetting the image.
Help?
import SimpleOpenNI.*;
SimpleOpenNI kinect;
int closestValue;
int closestX;
int closestY;
int previousX;
int previousY;
void setup()
{
frameRate(10);
size(640, 480);
kinect = new SimpleOpenNI(this);
kinect.enableDepth();
}
void draw() {
closestValue = 8000;
kinect.update();
int[] depthValues = kinect.depthMap();
for (int y = 0; y < 480; y++) {
for (int x = 0; x < 640; x++) {
int i = x + y * 640;
int currentDepthValue = depthValues[i];
if (currentDepthValue > 0 && currentDepthValue < closestValue) {
closestValue = currentDepthValue;
closestX = x;
closestY = y;
}
}
}
image(kinect.depthImage(), 0, 0);
stroke(255, 0, 0);
line(previousX, previousY, closestX, closestY);
previousX = closestX;
previousY = closestY;
}
1