We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi!
My sketch works but when I try to add the Kinect I can't get it to work. Ideally I'd like to project the piece and have people be able to play with it. Right now it's not possible. Not sure what I'm doing wrong. Please help! Thanks!
import org.openkinect.freenect.*;
import org.openkinect.processing.*;
Kinect kinect;
int f, num = 50, vari = 25;
float sz;
int col[] = new int[num];
boolean save;
// Depth image
PImage depthImg;
// Which pixels do we care about?
// These thresholds can also be found with a variaty of methods
float minDepth = 996;
float maxDepth = 2493;
// What is the kinect's angle
float angle;
void setup() {
size(640, 480);
colorMode(HSB, 255, 50, 50);
frameRate(2.5);
for (int i=0; i<num; i++) {
col[i]= (int) random(255);
}
kinect = new Kinect(this);
kinect.initDepth();
angle = kinect.getTilt();
// Blank image
depthImg = new PImage(kinect.width, kinect.height);
}
void draw() {
background(#FFFFFF);
for (int i=0; i<num; i++) {
float x = width/2 + random(-vari, vari);
float y = height/2 + random(-vari, vari);
pushMatrix();
translate(x, y);
stroke(col[i], 100, 100, 50);
strokeWeight(width/5);
noFill();
sz = width/5;
ellipse(x, y, sz, sz);
popMatrix();
}
image(kinect.getDepthImage(), 0, 0);
// Calibration
//minDepth = map(mouseX,0,width, 0, 4500);
//maxDepth = map(mouseY,0,height, 0, 4500);
// Threshold the depth image
int[] rawDepth = kinect.getRawDepth();
for (int i=0; i < rawDepth.length; i++) {
if (rawDepth[i] >= minDepth && rawDepth[i] <= maxDepth) {
depthImg.pixels[i] = color(255);
} else {
depthImg.pixels[i] = color(0);
}
}
// Draw the thresholded image
depthImg.updatePixels();
image(depthImg, kinect.width, 0);
//Comment for Calibration
fill(0);
text("TILT: " + angle, 10, 20);
text("THRESHOLD: [" + minDepth + ", " + maxDepth + "]", 10, 36);
//Calibration Text
//fill(255);
//textSize(32);
//text(minDepth + " " + maxDepth, 10, 64);
}
// Adjust the angle and the depth threshold min and max
void keyPressed() {
if (key == CODED) {
if (keyCode == UP) {
angle++;
} else if (keyCode == DOWN) {
angle--;
}
angle = constrain(angle, 0, 30);
kinect.setTilt(angle);
} else if (key == 'a') {
minDepth = constrain(minDepth+10, 0, maxDepth);
} else if (key == 's') {
minDepth = constrain(minDepth-10, 0, maxDepth);
} else if (key == 'z') {
maxDepth = constrain(maxDepth+10, minDepth, 2047);
} else if (key =='x') {
maxDepth = constrain(maxDepth-10, minDepth, 2047);
}
}
Answers
You need to describe your problem. Do you get any error messages?
Kf
Thanks kf!
Here's the error: Found path: /Users/patriciarobinson/Documents/Processing/libraries/openkinect_processing/library/v1/mac/ Loaded freenect from /Users/patriciarobinson/Documents/Processing/libraries/openkinect_processing/library/v1/mac/libfreenect.dylib upload_firmware: failed to find firmware file. upload_firmware failed: -2