0

im running the following code in processing but i only get a white background!!

import processing.opengl.*;
import SimpleOpenNI.*;
SimpleOpenNI kinect;
import saito.objloader.*;
OBJModel model;
void setup() { 
size(1028, 768, OPENGL);
model = new OBJModel(this, "kinect.obj", "relative", TRIANGLES);
model.translateToCenter();
// translate the model so its origin
// is at its left side
BoundingBox box = new BoundingBox(this, model); 
model.translate(box.getMin()); 
kinect = new SimpleOpenNI(this);
kinect.enableDepth();
kinect.enableUser();
kinect.setMirror(true);
}
void draw() { 
kinect.update();
background(255);
translate(width/2, height/2, 0);
rotateX(radians(180));
IntVector userList = new IntVector();
kinect.getUsers(userList);
if (userList.size() > 0) {
int userId = userList.get(0);
if ( kinect.isTrackingSkeleton(userId)) {
PVector leftHand = new PVector();
kinect.getJointPositionSkeleton(userId,
SimpleOpenNI.SKEL_LEFT_HAND, leftHand);
PVector rightHand = new PVector();
kinect.getJointPositionSkeleton(userId,
SimpleOpenNI.SKEL_RIGHT_HAND,
rightHand);
// subtract right from left hand
// to turn leftHand into a vector representing
// the difference between them
leftHand.sub(rightHand); 
// convert leftHand to a unit vector
leftHand.normalize(); 
// model is rotated so "up" is the x-axis
PVector modelOrientation = new PVector(1, 0, 0); 
// calculate angle and axis
float angle = acos(modelOrientation.dot(leftHand)); 
PVector axis = modelOrientation.cross(leftHand); 
stroke(255, 0, 0);
strokeWeight(5);
drawSkeleton(userId);
pushMatrix(); 
lights();
stroke(175);
strokeWeight(1);
fill(250);
translate(rightHand.x, rightHand.y, rightHand.z); 
// rotate angle amount around axis
rotate(angle, axis.x, axis.y, axis.z); 
model.draw(); 
popMatrix();
}
}
}
void drawSkeleton(int userId) {
drawLimb(userId, SimpleOpenNI.SKEL_HEAD, SimpleOpenNI.SKEL_NECK);
drawLimb(userId, SimpleOpenNI.SKEL_NECK,SimpleOpenNI.SKEL_LEFT_SHOULDER);
drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER,SimpleOpenNI.SKEL_LEFT_ELBOW);
drawLimb(userId, SimpleOpenNI.SKEL_LEFT_ELBOW,
SimpleOpenNI.SKEL_LEFT_HAND);
drawLimb(userId, SimpleOpenNI.SKEL_NECK,
SimpleOpenNI.SKEL_RIGHT_SHOULDER);
drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER,
SimpleOpenNI.SKEL_RIGHT_ELBOW);
drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW,
SimpleOpenNI.SKEL_RIGHT_HAND);
drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER,SimpleOpenNI.SKEL_TORSO);
drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER,SimpleOpenNI.SKEL_TORSO);
drawLimb(userId, SimpleOpenNI.SKEL_TORSO,SimpleOpenNI.SKEL_LEFT_HIP);
drawLimb(userId, SimpleOpenNI.SKEL_LEFT_HIP,SimpleOpenNI.SKEL_LEFT_KNEE);
drawLimb(userId, SimpleOpenNI.SKEL_LEFT_KNEE,SimpleOpenNI.SKEL_LEFT_FOOT);
drawLimb(userId, SimpleOpenNI.SKEL_TORSO,SimpleOpenNI.SKEL_RIGHT_HIP);
drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_HIP,SimpleOpenNI.SKEL_RIGHT_KNEE);
drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_KNEE,SimpleOpenNI.SKEL_RIGHT_FOOT);
drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_HIP,SimpleOpenNI.SKEL_LEFT_HIP);
}
void drawLimb(int userId, int jointType1, int jointType2)
{
PVector jointPos1 = new PVector();
PVector jointPos2 = new PVector();
float confidence;
// draw the joint position
confidence = kinect.getJointPositionSkeleton(userId, jointType1, jointPos1);
confidence = kinect.getJointPositionSkeleton(userId, jointType2, jointPos2);
line(jointPos1.x, jointPos1.y, jointPos1.z,jointPos2.x, jointPos2.y, jointPos2.z);
}

// user-tracking callbacks!
void onNewUser(SimpleOpenNI Kinect ,int userId)
{
  println("onNewUser - userId: " + userId);
  println("\tstart tracking skeleton");

  Kinect.startTrackingSkeleton(userId);
}

void onLostUser(SimpleOpenNI Kinect,int userId)
{
  println("onLostUser - userId: " + userId);
}

void onVisibleUser(SimpleOpenNI Kinect,int userId)
{
  //println("onVisibleUser - userId: " + userId);
}

im using processing 2.2.1 & simpleOpenNI 1.96 this code is from the book"making things see" but i changed the last few lines under // user-tracking callbacks! because i had problems running the original code (processing tells me some function do not exist),i also changed (kinect.enableUser(SimpleOpenNI.SKEL_PROFILE_ALL);)to(kinect.enableUser();) help plz :) ?

  • You're doing a lot of different things in that draw function. Instead, try to start smaller. What's the very first thing you want to see? Create an [MCVE](http://stackoverflow.com/help/mcve) with just that, and we'll go from there. Note that this should not be your whole sketch! Just an example project that only contains the code directly related to your problem. – Kevin Workman Apr 09 '15 at 02:46
  • Welcome to Stackoverflow! Remember that you're asking other people just like you to help you with your code problem, so please take a moment to edit your post and properly format your code, so people can actually read it easily. – Mike 'Pomax' Kamermans Apr 10 '15 at 03:47

0 Answers0