/* -------------------------------------------------------------------------- * SimpleOpenNI User3d Test * -------------------------------------------------------------------------- * Processing Wrapper for the OpenNI/Kinect library * http://code.google.com/p/simple-openni * -------------------------------------------------------------------------- * prog: Max Rheiner / Interaction Design / zhdk / http://iad.zhdk.ch/ * date: 02/16/2011 (m/d/y) * ---------------------------------------------------------------------------- * this demos is at the moment only for 1 user, will be implemented later * ---------------------------------------------------------------------------- */ import SimpleOpenNI.*; SimpleOpenNI context; float zoomF =0.5f; float rotX = radians(180); // by default rotate the hole scene 180deg around the x-axis, // the data from openni comes upside down float rotY = radians(0); boolean autoCalib=true; PVector bodyCenter = new PVector(); PVector bodyDir = new PVector(); void setup() { size(1024,768,P3D); // strange, get drawing error in the cameraFrustum if i use P3D, in opengl there is no problem context = new SimpleOpenNI(this); // disable mirror context.setMirror(false); // enable depthMap generation if(context.enableDepth() == false) { println("Can't open the depthMap, maybe the camera is not connected!"); exit(); return; } // enable skeleton generation for all joints context.enableUser(SimpleOpenNI.SKEL_PROFILE_ALL); stroke(255,255,255); smooth(); perspective(radians(45), float(width)/float(height), 10,150000); } void draw() { // update the cam context.update(); background(0,0,0); // set the scene pos translate(width/2, height/2, 0); rotateX(rotX); rotateY(rotY); scale(zoomF); int[] depthMap = context.depthMap(); int steps = 3; // to speed up the drawing, draw every third point int index; PVector realWorldPoint; translate(0,0,-1000); // set the rotation center of the scene 1000 infront of the camera stroke(100); for(int y=0;y < context.depthHeight();y+=steps) { for(int x=0;x < context.depthWidth();x+=steps) { index = x + y * context.depthWidth(); if(depthMap[index] > 0) { // draw the projected point realWorldPoint = context.depthMapRealWorld()[index]; point(realWorldPoint.x,realWorldPoint.y,realWorldPoint.z); } } } // draw the skeleton if it's available int[] userList = context.getUsers(); for(int i=0;i