Full screen tracking with Kinect
in
Contributed Library Questions
•
1 year ago
Hey guys,
I'm having difficulty getting the Kinect to track at full screen — I can manage static images to display at full screen but motion-sensitive activity is isolated to the standard Kinect 640 x 480 depth camera parameters in the upper left hand corner of the screen.
I tried swapping out all "int" values to match the screen size (or pretty much any size larger than 640 x 480) but always get an error message: "ArrayIndexOutOfBoundsException". Any ideas for how to solve this?
Thanks in advance for your help!
Library: SimpleOpenNI
Mac OS 10.7.4
I'm having difficulty getting the Kinect to track at full screen — I can manage static images to display at full screen but motion-sensitive activity is isolated to the standard Kinect 640 x 480 depth camera parameters in the upper left hand corner of the screen.
I tried swapping out all "int" values to match the screen size (or pretty much any size larger than 640 x 480) but always get an error message: "ArrayIndexOutOfBoundsException". Any ideas for how to solve this?
Thanks in advance for your help!
Library: SimpleOpenNI
Mac OS 10.7.4
- import SimpleOpenNI.*;
SimpleOpenNI kinect;
int closestValue;
int closestX;
int closestY;
float lastX;
float lastY;
void setup() {
size(screen.width, screen.height);
kinect = new SimpleOpenNI(this);
kinect.enableDepth();
smooth();
background(128, 128, 142);
}
void draw() {
for (int y = 10; y < screen.height; y += 10) {
for (int x = 10; x < screen.width; x +=10) {
point(x, y);
}
}
closestValue = 8000;
kinect.update();
int[] depthValues = kinect.depthMap();
for(int y = 0; y < 480; y++){
for(int x = 0; x < 640; x++){
// reverse x by moving in from
// the right side of the image
int reversedX = 640-x-1;
// reversed x to calculate
// the array index
int i = reversedX + y * 640;
int currentDepthValue = depthValues[i];
// only look for the closestValue winin a range
// 610 (or 2 feet) is the minimum
// 1525 (or 5 feet) is the maximum
if(currentDepthValue > 610 && currentDepthValue < 1525
&& currentDepthValue < closestValue){
closestValue = currentDepthValue;
closestX = x;
closestY = y;
}
}
}
float interpolatedX = lerp(lastX, closestX, 0.3f);
float interpolatedY = lerp(lastY, closestY, 0.3f);
if(closestX != 4 && closestY != 4 && pmouseX !=0 && pmouseY != 0) {
float s = dist(closestX, closestY, pmouseX, pmouseY) + 1;
noStroke();
fill(0, 198, 163, 10);
ellipse(closestX, closestY, s, s);
stroke(255);
point(closestX, closestY);
}
}
void mousePressed(){
background(128, 128, 152);
}
1