Kinect=004=skeleton tracking to Max/Msp

Page 1

04

KINECT Skeleton Tracking To MAX/MSP


You should be more familiar with this than before.


OPEN your “Skeleton3D” again


Since we will send data to MAX/MSP with OSC


OSC = Open Sound Control OSC is the acronym for Open Sound Control, a network protocol developed at cnmat, UC Berkeley. Open Sound Control is a protocol for communication among computers, sound synthesizers, and other multimedia devices that is optimized for modern networking technology and has been used in many application areas.


Anyway, we need a Library: oscP5


Download through here.

And put it to your Processing/ modes/Java/ libraries Or C:\Users\archgary\Documents\Processing\lib raries (Will not repeat this part.)



import oscP5.*; import netP5.*;

Import Libraries

import SimpleOpenNI.*; import peasy.test.*; import peasy.org.apache.commons.math.*; import peasy.*; import peasy.org.apache.commons.math.geometry.*; import processing.opengl.*; SimpleOpenNI context; PeasyCam cam; int boundSize = 2400;

Create an oscP5 object. OscP5 oscP5; Create an Network Address. NetAddress myRemoteLocation; OscMessage myMessage = new OscMessage(""); Create a Message for input data. PVector PVector PVector PVector color[]

bodyCenter = new PVector(); bodyDir = new PVector(); com = new PVector(); com2d = new PVector(); userClr = new color[]{ color(255,0,0), color(0,255,0), color(0,0,255), color(255,255,0), color(255,0,255), color(0,255,255) };

Something like this. ***before setup();


void setup(){ size(1024,768,P3D); context = new SimpleOpenNI(this); if(context.isInit() == false) { println("Can't init SimpleOpenNI, maybe the camera is not connected!"); exit(); return; } // disable mirror context.setMirror(false); // enable depthMap generation context.enableDepth(); // enable skeleton generation for all joints context.enableUser(); cam = new PeasyCam(this, 0, 0, 1000, 4000);

//start oscP5, telling it to listen for incoming messages at port 5001 */ oscP5 = new OscP5(this,5001); Set up a PORT. // set the remote location to be the localhost on port 5001 myRemoteLocation = new NetAddress("127.0.0.1",5001); stroke(255,255,255); smooth();

Stay with this for internal communication with MAX/MSP.

} IF YOU WAN TO SEND TO OTHER DEVICE IN THE NETWORK HERE ARE THE SETTING YOU NEED TO MODIFY.

***setup();


//PVector joint_HEAD = new PVector(); //context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_HEAD, joint_HEAD);

// draw the skeleton with the selected joints

void drawSkeleton(int userId){

PVector joint_NECK = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_NECK, joint_NECK);

strokeWeight(3);

PVector joint_LEFT_SHOULDER = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, joint_LEFT_SHOULDER);

// to get the 3d joint data drawLimb(userId, SimpleOpenNI.SKEL_HEAD, SimpleOpenNI.SKEL_NECK);

PVector joint_LEFT_ELBOW = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_ELBOW, joint_LEFT_ELBOW);

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);

PVector joint_LEFT_HAND = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_HAND, joint_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);

PVector joint_RIGHT_SHOULDER = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, joint_RIGHT_SHOULDER);

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);

PVector joint_RIGHT_ELBOW = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, joint_RIGHT_ELBOW);

1.

PVector joint_TORSO = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_TORSO, joint_TORSO);

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);

PVector joint_LEFT_HIP = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_HIP, joint_LEFT_HIP);

// draw body direction getBodyDirection(userId,bodyCenter,bodyDir);

PVector joint_LEFT_KNEE = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_KNEE, joint_LEFT_KNEE);

bodyDir.mult(200); // 200mm length bodyDir.add(bodyCenter);

PVector joint_LEFT_FOOT = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_FOOT, joint_LEFT_FOOT);

stroke(255,200,200); line(bodyCenter.x,bodyCenter.y,bodyCenter.z, bodyDir.x ,bodyDir.y,bodyDir.z);

PVector joint_RIGHT_HIP = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_HIP, joint_RIGHT_HIP);

PVector joint_HEAD = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_HEAD, joint_HEAD); strokeWeight(50); stroke(255); point(joint_HEAD.x, joint_HEAD.y, joint_HEAD.z);

PVector joint_RIGHT_KNEE = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_KNEE, joint_RIGHT_KNEE); PVector joint_RIGHT_FOOT = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_FOOT, joint_RIGHT_FOOT);

2.

THE MOST IMPORTANT PART HERE. Let’s take a closer look

PVector joint_RIGHT_HAND = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_HAND, joint_RIGHT_HAND);

myMessage.add(new float[] {joint_HEAD.x,joint_HEAD.y,joint_HEAD.z, joint_NECK.x,joint_NECK.y,joint_NECK.z, joint_LEFT_SHOULDER.x,joint_LEFT_SHOULDER.y,joint_LEFT_SHOULDER.z, joint_LEFT_ELBOW.x,joint_LEFT_ELBOW.y,joint_LEFT_ELBOW.z, joint_LEFT_HAND.x,joint_LEFT_HAND.y,joint_LEFT_HAND.z, joint_RIGHT_SHOULDER.x,joint_RIGHT_SHOULDER.y,joint_RIGHT_SHOULDER.z, joint_RIGHT_ELBOW.x,joint_RIGHT_ELBOW.y,joint_RIGHT_ELBOW.z, joint_RIGHT_HAND.x,joint_RIGHT_HAND.y,joint_RIGHT_HAND.z, joint_LEFT_HIP.x,joint_LEFT_HIP.y,joint_LEFT_HIP.z, joint_LEFT_KNEE.x,joint_LEFT_KNEE.y,joint_LEFT_KNEE.z, joint_LEFT_FOOT.x,joint_LEFT_FOOT.y,joint_LEFT_FOOT.z, joint_RIGHT_HIP.x,joint_RIGHT_HIP.y,joint_RIGHT_HIP.z, joint_RIGHT_KNEE.x,joint_RIGHT_KNEE.y,joint_RIGHT_KNEE.z, joint_RIGHT_FOOT.x,joint_RIGHT_FOOT.y,joint_RIGHT_FOOT.z, }); strokeWeight(1);

}

***drawSkeleton


//PVector joint_HEAD = new PVector(); //context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_HEAD, joint_HEAD); PVector joint_NECK = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_NECK, joint_NECK);

If have this info already, so please hide them.

PVector joint_LEFT_SHOULDER = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, joint_LEFT_SHOULDER); PVector joint_LEFT_ELBOW = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_ELBOW, joint_LEFT_ELBOW); PVector joint_LEFT_HAND = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_HAND, joint_LEFT_HAND);

You can see, just extracting the Joints

PVector joint_RIGHT_SHOULDER = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, joint_RIGHT_SHOULDER); PVector joint_RIGHT_ELBOW = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, joint_RIGHT_ELBOW);

1.

PVector joint_RIGHT_HAND = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_HAND, joint_RIGHT_HAND); PVector joint_TORSO = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_TORSO, joint_TORSO); PVector joint_LEFT_HIP = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_HIP, joint_LEFT_HIP); PVector joint_LEFT_KNEE = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_KNEE, joint_LEFT_KNEE); PVector joint_LEFT_FOOT = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_FOOT, joint_LEFT_FOOT); PVector joint_RIGHT_HIP = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_HIP, joint_RIGHT_HIP); PVector joint_RIGHT_KNEE = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_KNEE, joint_RIGHT_KNEE);

PVector joint_RIGHT_FOOT = new PVector(); context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_FOOT, joint_RIGHT_FOOT);

***drawSkeleton


2.

myMessage.add(new float[] {joint_HEAD.x,joint_HEAD.y,joint_HEAD.z, joint_NECK.x,joint_NECK.y,joint_NECK.z, joint_LEFT_SHOULDER.x,joint_LEFT_SHOULDER.y,joint_LEFT_SHOULDER.z, joint_LEFT_ELBOW.x,joint_LEFT_ELBOW.y,joint_LEFT_ELBOW.z, joint_LEFT_HAND.x,joint_LEFT_HAND.y,joint_LEFT_HAND.z, joint_RIGHT_SHOULDER.x,joint_RIGHT_SHOULDER.y,joint_RIGHT_SHOULDER.z, joint_RIGHT_ELBOW.x,joint_RIGHT_ELBOW.y,joint_RIGHT_ELBOW.z, joint_RIGHT_HAND.x,joint_RIGHT_HAND.y,joint_RIGHT_HAND.z, joint_LEFT_HIP.x,joint_LEFT_HIP.y,joint_LEFT_HIP.z, joint_LEFT_KNEE.x,joint_LEFT_KNEE.y,joint_LEFT_KNEE.z, joint_LEFT_FOOT.x,joint_LEFT_FOOT.y,joint_LEFT_FOOT.z, joint_RIGHT_HIP.x,joint_RIGHT_HIP.y,joint_RIGHT_HIP.z, joint_RIGHT_KNEE.x,joint_RIGHT_KNEE.y,joint_RIGHT_KNEE.z, joint_RIGHT_FOOT.x,joint_RIGHT_FOOT.y,joint_RIGHT_FOOT.z, });

Put all the extracted coordination in the “Message”

***drawSkeleton


void draw(){ context.update(); background(0,0,0); pushMatrix(); translate(0, 0, boundSize/2); stroke(255, 0, 255); noFill(); box(boundSize); popMatrix();

// draw the kinect cam context.drawCamFrustum();

oscP5.send(myMessage, myRemoteLocation); //send the message out. myMessage.clear(); //clean the message once it send out. popMatrix();

pushMatrix(); translate(0, boundSize/4, boundSize/2); rotateX(PI/2); stroke(255, 0, 255); noFill(); rectMode(CENTER); rect(0,0,boundSize,boundSize); popMatrix(); ///////////////////////////////flip pushMatrix(); scale(-1,1,1); scale(0.5); rotateZ(radians(180)); rotateY(radians(360)); int[] userList = context.getUsers();

}

for(int i=0;i<userList.length;i++) { if(context.isTrackingSkeleton(userList[i])){ drawSkeleton(userList[i]); } // draw the center of mass if(context.getCoM(userList[i],com)) { stroke(100,255,0); strokeWeight(1); beginShape(LINES); vertex(com.x - 15,com.y,com.z); vertex(com.x + 15,com.y,com.z); vertex(com.x,com.y - 15,com.z); vertex(com.x,com.y + 15,com.z); vertex(com.x,com.y,com.z - 15); vertex(com.x,com.y,com.z + 15); endShape(); //fill(0,255,100); //text(Integer.toString(userList[i]),com.x,com.y,com.z); } }

***draw();


Run it! But how we know it works?


Open a new Patcher


Add a new Object

More like Grasshopper as a visual coding


Click on the Object


Type in “udpreceiver 5001” Number match to the Port you send out.


Make another selection with “message�


And make the connection like this. (simply drag and pull)


Now back to Processing, And Run it.


Processing Code.

Processing Canvas

MAX/MSP


X Now they are talking.


Examples sending messages relating to the real-time 3D projection. (Might have minor changes)


In projection:

Point : Intersection of Lines. Line: Intersection of Planes.


EXAMPLEs: 2Points Also need to separate the Skeleton Message and Geometry Message


void setup(){ size(1024,768,P3D); context = new SimpleOpenNI(this); if(context.isInit() == false) { println("Can't init SimpleOpenNI, maybe the camera is not connected!"); exit(); return; } // disable mirror context.setMirror(false); // enable depthMap generation context.enableDepth(); // enable skeleton generation for all joints context.enableUser(); cam = new PeasyCam(this, 0, 0, 1000, 4000);

//start oscP5, telling it to listen for incoming messages at port 5001 */ oscP5 = new OscP5(this,5002); // set the remote location to be the localhost on port 5001 myRemoteLocation = new NetAddress("127.0.0.1",5002); stroke(255,255,255); smooth();

} First, I would like to set the skeleton message to “5002�

***setup();


import oscP5.*; import netP5.*;

Then, Mostly we are doing duplication.

import SimpleOpenNI.*; import peasy.test.*; import peasy.org.apache.commons.math.*; import peasy.*; import peasy.org.apache.commons.math.geometry.*; import processing.opengl.*; SimpleOpenNI context;

PeasyCam cam; int boundSize = 2400;

OscP5 oscP5; OscP5 oscP5_P; NetAddress myRemoteLocation; NetAddress myRemoteLocation_P; OscMessage myMessage = new OscMessage(""); OscMessage myMessage_P = new OscMessage(""); PVector PVector PVector PVector color[]

bodyCenter = new PVector(); bodyDir = new PVector(); com = new PVector(); com2d = new PVector(); userClr = new color[]{ color(255,0,0), color(0,255,0), color(0,0,255), color(255,255,0), color(255,0,255), color(0,255,255) };

Something like this. ***before setup();


void setup(){ size(1024,768,P3D); context = new SimpleOpenNI(this); if(context.isInit() == false) { println("Can't init SimpleOpenNI, maybe the camera is not connected!"); exit(); return; } // disable mirror context.setMirror(false); // enable depthMap generation context.enableDepth(); // enable skeleton generation for all joints context.enableUser(); cam = new PeasyCam(this, 0, 0, 1000, 4000);

//start oscP5, telling it to listen for incoming messages at port 5001 */ oscP5 = new OscP5(this,5002); oscP5_P = new OscP5(this,5001); // set the remote location to be the localhost on port 5001 myRemoteLocation = new NetAddress("127.0.0.1",5002); myRemoteLocation_P = new NetAddress("127.0.0.1",5001); stroke(255,255,255); smooth();

} Remember to change the Address & Port to the one you will send.

***setup();


No need to worry about the message for skeleton which we have it already.


In this case, We are sending the coordination of our 2 hands.


// draw the center of mass if(context.getCoM(userList[i],com)) { stroke(100,255,0); strokeWeight(1); beginShape(LINES); vertex(com.x - 15,com.y,com.z); vertex(com.x + 15,com.y,com.z);

void draw(){ context.update(); background(0,0,0); pushMatrix(); translate(0, 0, boundSize/2); stroke(255, 0, 255); noFill(); box(boundSize); popMatrix();

vertex(com.x,com.y - 15,com.z); vertex(com.x,com.y + 15,com.z);

pushMatrix(); translate(0, boundSize/4, boundSize/2); rotateX(PI/2); stroke(255, 0, 255); noFill(); rectMode(CENTER); rect(0,0,boundSize,boundSize); popMatrix(); ///////////////////////////////flip pushMatrix(); scale(-1,1,1); scale(0.5); rotateZ(radians(180)); rotateY(radians(360)); int[] userList = context.getUsers();

vertex(com.x,com.y,com.z - 15); vertex(com.x,com.y,com.z + 15); endShape(); //fill(0,255,100); //text(Integer.toString(userList[i]),com.x,com.y,com.z); } } // draw the kinect cam context.drawCamFrustum();

for(int i=0;i<userList.length;i++) { if(context.isTrackingSkeleton(userList[i])){ drawSkeleton(userList[i]);

Extract the Hands.

PVector BRh = new PVector(); context.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_RIGHT_HAND, BRh); PVector BLh = new PVector(); context.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_LEFT_HAND, BLh); stroke(0,255,0); strokeWeight(10); point(BLh.x,BLh.y,BLh.z); point(BRh.x,BRh.y,BRh.z);

Draw the Hands Draw line between hands

oscP5.send(myMessage, myRemoteLocation); //send the message out. myMessage.clear(); //clean the message once it send out.

oscP5.send(myMessage_P, myRemoteLocation_P); myMessage_P.clear();

strokeWeight(4); line(BLh.x,BLh.y,BLh.z,BRh.x,BRh.y,BRh.z);

myMessage_p.add(new float[] {BLh.x,BLh.y,BLh.z,BRh.x,BRh.y,BRh.z}); }

Put it in the myMessage_P

popMatrix();

Send the data out!

} ***draw();


Copy another set of it. Change the Port Number.

2 Hands Coordination

Skeleton Coordination



Could Work with Multiple Players.


EXAMPLEs: 3Points

(2hands + head)

Once we set the message stream, It’s only the matter of WHAT we want to send.


void draw(){ context.update(); background(0,0,0); pushMatrix(); translate(0, 0, boundSize/2); stroke(255, 0, 255); noFill(); box(boundSize); popMatrix(); pushMatrix(); translate(0, boundSize/4, boundSize/2); rotateX(PI/2); stroke(255, 0, 255); noFill(); rectMode(CENTER); rect(0,0,boundSize,boundSize); popMatrix();

// draw the center of mass if(context.getCoM(userList[i],com)) { stroke(100,255,0); strokeWeight(1); beginShape(LINES); vertex(com.x - 15,com.y,com.z); vertex(com.x + 15,com.y,com.z); vertex(com.x,com.y - 15,com.z); vertex(com.x,com.y + 15,com.z); vertex(com.x,com.y,com.z - 15); vertex(com.x,com.y,com.z + 15); endShape();

///////////////////////////////flip pushMatrix(); scale(-1,1,1); scale(0.5); rotateZ(radians(180)); rotateY(radians(360)); int[] userList = context.getUsers();

for(int i=0;i<userList.length;i++) { if(context.isTrackingSkeleton(userList[i])){ drawSkeleton(userList[i]);

PVector BHead = new PVector(); context.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_HEAD, BHead); PVector BRh = new PVector(); context.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_RIGHT_HAND, BRh); PVector BLh = new PVector(); context.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_LEFT_HAND, BLh); stroke(0,255,0); strokeWeight(10);

point(BHead.x,BHead.y+1000,BHead.z);

//fill(0,255,100); //text(Integer.toString(userList[i]),com.x,com.y,com.z); } } // draw the kinect cam context.drawCamFrustum();

oscP5.send(myMessage, myRemoteLocation); myMessage.clear(); oscP5.send(myMessage_P, myRemoteLocation_P); myMessage_P.clear();

point(BRh.x,BRh.y,BRh.z); point(BRh.x,BRh.y,BRh.z); line(BHead.x,BHead.y+1000,BHead.z,BLh.x,BLh.y,BLh.z); line(BLh.x,BLh.y,BLh.z,BRh.x,BRh.y,BRh.z); line(BRh.x,BRh.y,BRh.z,BHead.x,BHead.y+1000,BHead.z);

popMatrix();

}

strokeWeight(4); line(BLh.x,BLh.y,BLh.z,BRh.x,BRh.y,BRh.z); myMessage_p.add(new float[] {BLh.x,BLh.y,BLh.z, BRh.x,BRh.y,BRh.z, BHead.x,BHead.y+1000,BHead.z}); }

***draw();


1.

2. 3.


EXAMPLEs: Plan

(4points around your HEAD)


myMessage_p.add(new float[] { BH_LT.x,BH_LT.y,BH_LT.z, BH_LD.x,BH_LD.y,BH_LD.z, BH_RD.x,BH_RD.y,BH_RD.z, BH_RT.x,BH_RT.y,BH_RT.z, });

void draw(){ context.update(); background(0,0,0); pushMatrix(); translate(0, 0, boundSize/2); stroke(255, 0, 255); noFill(); box(boundSize); popMatrix(); pushMatrix(); scale(-1,1,1); scale(0.5); rotateZ(radians(180)); rotateY(radians(360)); rotateX(PI/2); stroke(255, 0, 255); noFill(); rectMode(CENTER); rect(0,0,boundSize,boundSize); popMatrix();

} // draw the center of mass if(context.getCoM(userList[i],com)) { stroke(100,255,0); strokeWeight(1); beginShape(LINES); vertex(com.x - 15,com.y,com.z); vertex(com.x + 15,com.y,com.z);

pushMatrix(); scale(0.5); int[] userList = context.getUsers();

vertex(com.x,com.y - 15,com.z); vertex(com.x,com.y + 15,com.z);

for(int i=0;i<userList.length;i++) { if(context.isTrackingSkeleton(userList[i])){ drawSkeleton(userList[i]);

vertex(com.x,com.y,com.z - 15); vertex(com.x,com.y,com.z + 15); endShape(); //fill(0,255,100); //text(Integer.toString(userList[i]),com.x,com.y,com.z);

PVector BHead = new PVector(); context.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_HEAD, BHead); Reference Point PVector Zero = new PVector(0,0,0); float distance = PVector.dist(BHead,Zero);

PVector BH_LT = new PVector(BHead.x-distance/2, BHead.y-distance/2,BHead.z); PVector BH_LD = new PVector(BHead.x-distance/2, BHead.y+distance/2,BHead.z); PVector BH_RT = new PVector(BHead.x+distance/2, BHead.y-distance/2,BHead.z); PVector BH_RD = new PVector(BHead.x+distance/2, AddBHead.y+distance/2,BHead.z); the distance to the Head stroke(0,255,0); strokeWeight(10); point(BH_LT.x,BH_LT.y,BH_LT.z); point(BH_LD.x,BH_LD.y,BH_LD.z); point(BH_RT.x,BH_RT.y,BH_RT.z); point(BH_RD.x,BH_RD.y,BH_RD.z);

} // draw the kinect cam context.drawCamFrustum(); oscP5.send(myMessage, myRemoteLocation); myMessage.clear();

coordination as 4 Points

oscP5.send(myMessage_P, myRemoteLocation_P); myMessage_P.clear();

Draw 4 Points popMatrix(); }

strokeWeight(2); line(BH_LT.x,BH_LT.y,BH_LT.z,BH_LD.x,BH_LD.y,BH_LD.z); line(BH_LD.x,BH_LD.y,BH_LD.z,BH_RD.x,BH_RD.y,BH_RD.z); line(BH_RD.x,BH_RD.y,BH_RD.z,BH_RT.x,BH_RT.y,BH_RT.z); line(BH_RT.x,BH_RT.y,BH_RT.z,BH_LT.x,BH_LT.y,BH_LT.z); line(BH_LT.x,BH_LT.y,BH_LT.z,0,500,0); line(BH_LD.x,BH_LD.y,BH_LD.z,0,500,0); line(BH_RD.x,BH_RD.y,BH_RD.z,0,500,0); line(BH_RT.x,BH_RT.y,BH_RT.z,0,500,0);

}

Distance between Head & Ref.

Draw 4 Lines

Draw 4 Fake Projection Lines

***draw();


For sure the RECEIVING processing is still going on.



The closer you approach the camera, the smaller field you get.


EXAMPLEs: VH

(1 hand: Vertical, 1hand: Horizontal)


myMessage_P.add(new float[] { BLh.x-5000,BLh.y,BLh.z-5000, BLh.x+5000,BLh.y,BLh.z+5000, BRh.x,BRh.y-5000,BRh.z,BRh.x,BRh.y+5000,BRh.z }); }

void draw(){ context.update(); background(0,0,0); pushMatrix(); translate(0, 0, boundSize/2); stroke(255, 0, 255); noFill(); box(boundSize); popMatrix();

// draw the center of mass if(context.getCoM(userList[i],com)) { stroke(100,255,0); strokeWeight(1); beginShape(LINES); vertex(com.x - 15,com.y,com.z); vertex(com.x + 15,com.y,com.z);

pushMatrix(); translate(0, boundSize/4, boundSize/2); rotateX(PI/2); stroke(255, 0, 255); noFill(); rectMode(CENTER); rect(0,0,boundSize,boundSize); popMatrix(); ///////////////////////////////flip pushMatrix(); scale(-1,1,1); scale(0.5); rotateZ(radians(180)); rotateY(radians(360));

vertex(com.x,com.y - 15,com.z); vertex(com.x,com.y + 15,com.z); vertex(com.x,com.y,com.z - 15); vertex(com.x,com.y,com.z + 15); endShape();

int[] userList = context.getUsers();

for(int i=0;i<userList.length;i++) { if(context.isTrackingSkeleton(userList[i])){ drawSkeleton(userList[i]);

//fill(0,255,100); //text(Integer.toString(userList[i]),com.x,com.y,com.z); } }

2 Hands

PVector BRh = new PVector(); context.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_RIGHT_HAND, BRh); PVector BLh = new PVector(); context.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_LEFT_HAND, BLh); stroke(0,255,0); strokeWeight(10); //mainpoint; point(BLh.x-5000,BLh.y,BLh.z-5000); point(BLh.x+5000,BLh.y,BLh.z+5000); point(BRh.x,BRh.y-5000,BRh.z); point(BRh.x,BRh.y+5000,BRh.z);

// draw the kinect cam context.drawCamFrustum(); oscP5.send(myMessage, myRemoteLocation); myMessage.clear();

oscP5.send(myMessage_P, myRemoteLocation_P); myMessage_P.clear();

Add long distances, and make 45 rotation for the projection.

popMatrix(); }

stroke(0,255,0); strokeWeight(4); line(BLh.x-5000,BLh.y,BLh.z-5000,BLh.x+5000,BLh.y,BLh.z+5000); line(BRh.x,BRh.y-5000,BRh.z,BRh.x,BRh.y+5000,BRh.z);

Display them.

***draw();


I’ve been KILLED


Vertical

Vertical

Horizontal

Horizontal


Let’s see HOW We can cooperate with

Projections


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.