81
KINECT Skeleton Tracking 2D 02

Kinect=002=skeleton tracking 2d

Embed Size (px)

DESCRIPTION

Kinect Skeleton Tracking

Citation preview

Page 1: Kinect=002=skeleton tracking 2d

KINECTSkeleton Tracking

2D

02

Page 2: Kinect=002=skeleton tracking 2d

REVIEW

Page 3: Kinect=002=skeleton tracking 2d

import SimpleOpenNI.*;

SimpleOpenNI context;

///////////////////////////////////////////////

void setup(){

context = new SimpleOpenNI (this);

context.enableDepth();

context.enableUser();

if(context.isInit() == false){

println("Maybe your Kinect is not connected");

exit();

return;

}

size(context.depthWidth(), context.depthHeight());

}

///////////////////////////////////////////////

void draw(){

context.update();

image(context.userImage(),0,0);

}

Try to

explain ?what does each lines mean

Page 4: Kinect=002=skeleton tracking 2d

import SimpleOpenNI.*;

SimpleOpenNI context;

///////////////////////////////////////////////

void setup(){

context = new SimpleOpenNI (this);

context.enableDepth();

context.enableUser();

if(context.isInit() == false){

println("Maybe your Kinect is not connected");

exit();

return;

}

size(context.depthWidth(), context.depthHeight());

}

///////////////////////////////////////////////

void draw(){

context.update();

image(context.userImage(),0,0);

}

Import library.

Create an simpleOpenNI object.

Initiate this simpleOpenNI object.

Enable Depth calculation.

Enable User(ID) calculation.

Detect Kinect’s connection

Size of the Window

Update the data

Draw User’s Coloring Image

Page 5: Kinect=002=skeleton tracking 2d

If you are

IN A HURRY

Page 6: Kinect=002=skeleton tracking 2d

Open the user example to get it.

Page 7: Kinect=002=skeleton tracking 2d

But I will

Try to Simplify the code

Page 8: Kinect=002=skeleton tracking 2d

import SimpleOpenNI.*;

SimpleOpenNI context;

color[] 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)

};

///////////////////////////////////////////////

void setup(){

context = new SimpleOpenNI (this);

context.enableDepth();

context.enableUser();

if(context.isInit() == false){

println("Maybe your Kinect is not connected");

exit();

return;

}

size(context.depthWidth(), context.depthHeight());

}

///////////////////////////////////////////////

void draw(){

context.update();

image(context.userImage(),0,0);

}

Color for idetifying the users

If you try to compare the differences between

the user example and our previous code.

Here is the first difference:

Which means each of the user identified

by Kinect will has its own skeleton color.

Page 9: Kinect=002=skeleton tracking 2d

import SimpleOpenNI.*;

SimpleOpenNI context;

color[] 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)

};

///////////////////////////////////////////////

void setup(){

context = new SimpleOpenNI (this);

context.enableDepth();

context.enableUser();

if(context.isInit() == false){

println("Maybe your Kinect is not connected");

exit();

return;

}

size(context.depthWidth(), context.depthHeight());

}

///////////////////////////////////////////////

void draw(){

context.update();

image(context.userImage(),0,0);

}

But to ME, I don’t need it.

(you can still keep it if you like).

Page 10: Kinect=002=skeleton tracking 2d

import SimpleOpenNI.*;

SimpleOpenNI context;

PVector com = new PVector();

PVector com2d = new PVector();

///////////////////////////////////////////////

void setup(){

context = new SimpleOpenNI (this);

context.enableDepth();

context.enableUser();

if(context.isInit() == false){

println("Maybe your Kinect is not connected");

exit();

return;

}

size(context.depthWidth(), context.depthHeight());

}

///////////////////////////////////////////////

void draw(){

context.update();

image(context.userImage(),0,0);

}

Center of Mass// Center of your figure

Second Difference:

Page 11: Kinect=002=skeleton tracking 2d

import SimpleOpenNI.*;

SimpleOpenNI context;

PVector com = new PVector();

PVector com2d = new PVector();

///////////////////////////////////////////////

void setup(){

context = new SimpleOpenNI (this);

context.enableDepth();

context.enableUser();

if(context.isInit() == false){

println("Maybe your Kinect is not connected");

exit();

return;

}

size(context.depthWidth(), context.depthHeight());

}

///////////////////////////////////////////////

void draw(){

context.update();

image(context.userImage(),0,0);

}

Center of Mass// Center of your figure

If we want to keep it simple for the first

time, we can still ignore them. (or talk

about it later).

Page 12: Kinect=002=skeleton tracking 2d

ARE YOU

KIDDING ME?

Page 13: Kinect=002=skeleton tracking 2d

import SimpleOpenNI.*;

SimpleOpenNI context;

///////////////////////////////////////////////

void setup(){

context = new SimpleOpenNI (this);

context.enableDepth();

context.enableUser();

if(context.isInit() == false){

println("Maybe your Kinect is not connected");

exit();

return;

}

size(context.depthWidth(), context.depthHeight());

}

///////////////////////////////////////////////

void draw(){

context.update();

image(context.userImage(),0,0);

int [] userList = context.getUsers();

for(int i =0; i<userList.length; i++){

if(context.isTrackingSkeleton(userList[i])){

stroke(255,0,0);

drawSkeleton(userList[i]);

}

}

}

Detect the users.

For every users, they will …

If Kinect have tracked someone…

Draw the skeleton

Here comes

the REAL

stuffs.

Page 14: Kinect=002=skeleton tracking 2d

But we don’t have

drawSkeleton(userList[i])

function yet!

Page 15: Kinect=002=skeleton tracking 2d

HEAD

NECK

LEFT_SHOULDERRIGHT_SHOULDER

LEFT_ELBOWRIGHT_ELBOW

LEFT_HANDRIGHT_HAND

TORSO

RIGHT_HIP LEFT_HIP

RIGHT_KNEE LEFT_KNEE

RIGHT_FOOT LEFT_FOOT

Page 16: Kinect=002=skeleton tracking 2d

void drawSkeleton(int userId)

{

// to get the 3d joint data

/*

PVector jointPos = new PVector();

context.getJointPositionSkeleton(userId,SimpleOpenNI.SKEL_NECK,jointPos);

println(jointPos);

*/

context.drawLimb(userId, SimpleOpenNI.SKEL_HEAD, SimpleOpenNI.SKEL_NECK);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_LEFT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_LEFT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_ELBOW, SimpleOpenNI.SKEL_LEFT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_RIGHT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_RIGHT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, SimpleOpenNI.SKEL_RIGHT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_LEFT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_HIP, SimpleOpenNI.SKEL_LEFT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_KNEE, SimpleOpenNI.SKEL_LEFT_FOOT);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_RIGHT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_HIP, SimpleOpenNI.SKEL_RIGHT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_KNEE, SimpleOpenNI.SKEL_RIGHT_FOOT);

}

Here you are (simply copy from example)

Let’s take a look!

Page 17: Kinect=002=skeleton tracking 2d

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_RIGHT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_RIGHT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, SimpleOpenNI.SKEL_RIGHT_HAND);

Object

Function

Feed in Data 1:

UserID

Feed in Data 2:

Draw Something

Page 18: Kinect=002=skeleton tracking 2d

Don’t be afraid of Copy&Paste,Unless you know how to Change.

(Coding is not an memorizing game)

Page 19: Kinect=002=skeleton tracking 2d

The Last piece of your Skeleton puzzle.

Page 20: Kinect=002=skeleton tracking 2d

void onNewUser(SimpleOpenNI curContext, int userId)

{

println("onNewUser - userId: " + userId);

println("\tstart tracking skeleton");

context.startTrackingSkeleton(userId);

}

void onLostUser(SimpleOpenNI curContext, int userId)

{

println("onLostUser - userId: " + userId);

}

void onVisibleUser(SimpleOpenNI curContext, int userId)

{

//println("onVisibleUser - userId: " + userId);

}

Lost&Found Users(simply copy from example)

Page 21: Kinect=002=skeleton tracking 2d

import SimpleOpenNI.*;

SimpleOpenNI context;

///////////////////////////////////////////////

void setup(){

context = new SimpleOpenNI (this);

context.enableDepth();

context.enableUser();

if(context.isInit() == false){

println("Maybe your Kinect is not connected");

exit();

return;

}

size(context.depthWidth(), context.depthHeight());

}

///////////////////////////////////////////////

void draw(){

context.update();

image(context.userImage(),0,0);

int [] userList = context.getUsers();

for(int i =0; i<userList.length; i++){

if(context.isTrackingSkeleton(userList[i])){

stroke(255,0,0);

drawSkeleton(userList[i]);

}

}

}

void drawSkeleton(int userId)

{

// to get the 3d joint data

/*

PVector jointPos = new PVector();

context.getJointPositionSkeleton(userId,SimpleOpenNI.SKEL_NECK,jointPos);

println(jointPos);

*/

context.drawLimb(userId, SimpleOpenNI.SKEL_HEAD, SimpleOpenNI.SKEL_NECK);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_LEFT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_LEFT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_ELBOW, SimpleOpenNI.SKEL_LEFT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_RIGHT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_RIGHT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, SimpleOpenNI.SKEL_RIGHT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_LEFT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_HIP, SimpleOpenNI.SKEL_LEFT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_KNEE, SimpleOpenNI.SKEL_LEFT_FOOT);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_RIGHT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_HIP, SimpleOpenNI.SKEL_RIGHT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_KNEE, SimpleOpenNI.SKEL_RIGHT_FOOT);

}

// SimpleOpenNI user events///////////////////////////////////////////////////////////////////////////////////////

void onNewUser(SimpleOpenNI curContext, int userId)

{

println("onNewUser - userId: " + userId);

println("\tstart tracking skeleton");

context.startTrackingSkeleton(userId);

}

void onLostUser(SimpleOpenNI curContext, int userId)

{

println("onLostUser - userId: " + userId);

}

void onVisibleUser(SimpleOpenNI curContext, int userId)

{

//println("onVisibleUser - userId: " + userId);

}

Page 22: Kinect=002=skeleton tracking 2d

THE color: (255,0,0)

Free

As

A

Bird

Page 23: Kinect=002=skeleton tracking 2d

I want my Head!Let’s create a function!

Page 24: Kinect=002=skeleton tracking 2d

void drawHead(int userId){

PVector jointPosH = new PVector();

//Create a Vector (to capture the Head joint).

context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_HEAD, jointPosH);

//Get the Head Joint in 3D!

PVector jointPosH_Proj = new PVector();

//Create a Vector (for projecting on 2D).

context.convertRealWorldToProjective(jointPosH, jointPosH_Proj);

//Convert 3D Head Joint Vector to 2D screen (for projecting on 2D).

fill(0,255,0);

stroke(255,0,0);

ellipse(jointPosH_Proj.x, jointPosH_Proj.y, 50, 50);

// Extract the x and y position from the Projection Head Joint to draw a circle.

}

Page 25: Kinect=002=skeleton tracking 2d

Put it in the CODE

Page 26: Kinect=002=skeleton tracking 2d

import SimpleOpenNI.*;

SimpleOpenNI context;

///////////////////////////////////////////////

void setup(){

context = new SimpleOpenNI (this);

context.enableDepth();

context.enableUser();

if(context.isInit() == false){

println("Maybe your Kinect is not connected");

exit();

return;

}

size(context.depthWidth(), context.depthHeight());

}

///////////////////////////////////////////////

void draw(){

context.update();

image(context.userImage(),0,0);

int [] userList = context.getUsers();

for(int i =0; i<userList.length; i++){

if(context.isTrackingSkeleton(userList[i])){

stroke(255,0,0);

drawSkeleton(userList[i]);

drawHead(userList[i]);

}

}

}

void drawSkeleton(int userId)

{

// to get the 3d joint data

/*

PVector jointPos = new PVector();

context.getJointPositionSkeleton(userId,SimpleOpenNI.SKEL_NECK,jointPos);

println(jointPos);

*/

context.drawLimb(userId, SimpleOpenNI.SKEL_HEAD, SimpleOpenNI.SKEL_NECK);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_LEFT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_LEFT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_ELBOW, SimpleOpenNI.SKEL_LEFT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_RIGHT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_RIGHT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, SimpleOpenNI.SKEL_RIGHT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_LEFT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_HIP, SimpleOpenNI.SKEL_LEFT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_KNEE, SimpleOpenNI.SKEL_LEFT_FOOT);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_RIGHT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_HIP, SimpleOpenNI.SKEL_RIGHT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_KNEE, SimpleOpenNI.SKEL_RIGHT_FOOT);

}

// SimpleOpenNI user events///////////////////////////////////////////////////////////////////////////////////////

void onNewUser(SimpleOpenNI curContext, int userId)

{

println("onNewUser - userId: " + userId);

println("\tstart tracking skeleton");

context.startTrackingSkeleton(userId);

}

void onLostUser(SimpleOpenNI curContext, int userId)

{

println("onLostUser - userId: " + userId);

}

void onVisibleUser(SimpleOpenNI curContext, int userId)

{

//println("onVisibleUser - userId: " + userId);

}

void drawHead(int userId){

PVector jointPosH = new PVector();

//Create a Vector (to capture the Head joint).

context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_HEAD, jointPosH);

//Get the Head Joint in 3D!

PVector jointPosH_Proj = new PVector();

//Create a Vector (for projecting on 2D).

context.convertRealWorldToProjective(jointPosH, jointPosH_Proj);

//Convert 3D Head Joint Vector to 2D screen (for projecting on 2D).

fill(0,255,0);

stroke(255,0,0);

ellipse(jointPosH_Proj.x, jointPosH_Proj.y, 80, 80);

// Extract the x and y position from the Projection Head Joint to draw a circle.

}

Page 27: Kinect=002=skeleton tracking 2d

Let’s reduceSome stuffs

Page 28: Kinect=002=skeleton tracking 2d

import SimpleOpenNI.*;

SimpleOpenNI context;

///////////////////////////////////////////////

void setup(){

context = new SimpleOpenNI (this);

context.enableDepth();

context.enableUser();

if(context.isInit() == false){

println("Maybe your Kinect is not connected");

exit();

return;

}

size(context.depthWidth(), context.depthHeight());

}

///////////////////////////////////////////////

void draw(){

context.update();

background(0);

//image(context.userImage(),0,0);

int [] userList = context.getUsers();

for(int i =0; i<userList.length; i++){

if(context.isTrackingSkeleton(userList[i])){

stroke(255,0,0);

drawSkeleton(userList[i]);

drawHead(userList[i]);

}

}

}

void drawSkeleton(int userId)

{

// to get the 3d joint data

/*

PVector jointPos = new PVector();

context.getJointPositionSkeleton(userId,SimpleOpenNI.SKEL_NECK,jointPos);

println(jointPos);

*/

context.drawLimb(userId, SimpleOpenNI.SKEL_HEAD, SimpleOpenNI.SKEL_NECK);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_LEFT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_LEFT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_ELBOW, SimpleOpenNI.SKEL_LEFT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_RIGHT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_RIGHT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, SimpleOpenNI.SKEL_RIGHT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_LEFT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_HIP, SimpleOpenNI.SKEL_LEFT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_KNEE, SimpleOpenNI.SKEL_LEFT_FOOT);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_RIGHT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_HIP, SimpleOpenNI.SKEL_RIGHT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_KNEE, SimpleOpenNI.SKEL_RIGHT_FOOT);

}

// SimpleOpenNI user events///////////////////////////////////////////////////////////////////////////////////////

void onNewUser(SimpleOpenNI curContext, int userId)

{

println("onNewUser - userId: " + userId);

println("\tstart tracking skeleton");

context.startTrackingSkeleton(userId);

}

void onLostUser(SimpleOpenNI curContext, int userId)

{

println("onLostUser - userId: " + userId);

}

void onVisibleUser(SimpleOpenNI curContext, int userId)

{

//println("onVisibleUser - userId: " + userId);

}

void drawHead(int userId){

PVector jointPosH = new PVector();

//Create a Vector (to capture the Head joint).

context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_HEAD, jointPosH);

//Get the Head Joint in 3D!

PVector jointPosH_Proj = new PVector();

//Create a Vector (for projecting on 2D).

context.convertRealWorldToProjective(jointPosH, jointPosH_Proj);

//Convert 3D Head Joint Vector to 2D screen (for projecting on 2D).

fill(0,255,0);

stroke(255,0,0);

ellipse(jointPosH_Proj.x, jointPosH_Proj.y, 80, 80);

// Extract the x and y position from the Projection Head Joint to draw a circle.

}

Page 29: Kinect=002=skeleton tracking 2d

In this Virtual WorldNO One is FAT!

Page 30: Kinect=002=skeleton tracking 2d

Change the ColorYou Like

Page 31: Kinect=002=skeleton tracking 2d

import SimpleOpenNI.*;

SimpleOpenNI context;

///////////////////////////////////////////////

void setup(){

context = new SimpleOpenNI (this);

context.enableDepth();

context.enableUser();

if(context.isInit() == false){

println("Maybe your Kinect is not connected");

exit();

return;

}

size(context.depthWidth(), context.depthHeight());

}

///////////////////////////////////////////////

void draw(){

background(0);

context.update();

//image(context.userImage(),0,0);

int [] userList = context.getUsers();

for(int i =0; i<userList.length; i++){

if(context.isTrackingSkeleton(userList[i])){

strokeWeight(2);

stroke(0,255,255);

drawSkeleton(userList[i]);

drawHead(userList[i]);

}

}

}

void drawSkeleton(int userId)

{

// to get the 3d joint data

/*

PVector jointPos = new PVector();

context.getJointPositionSkeleton(userId,SimpleOpenNI.SKEL_NECK,jointPos);

println(jointPos);

*/

context.drawLimb(userId, SimpleOpenNI.SKEL_HEAD, SimpleOpenNI.SKEL_NECK);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_LEFT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_LEFT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_ELBOW, SimpleOpenNI.SKEL_LEFT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_RIGHT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_RIGHT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, SimpleOpenNI.SKEL_RIGHT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_LEFT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_HIP, SimpleOpenNI.SKEL_LEFT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_KNEE, SimpleOpenNI.SKEL_LEFT_FOOT);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_RIGHT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_HIP, SimpleOpenNI.SKEL_RIGHT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_KNEE, SimpleOpenNI.SKEL_RIGHT_FOOT);

}

// SimpleOpenNI user events///////////////////////////////////////////////////////////////////////////////////////

void onNewUser(SimpleOpenNI curContext, int userId)

{

println("onNewUser - userId: " + userId);

println("\tstart tracking skeleton");

context.startTrackingSkeleton(userId);

}

void onLostUser(SimpleOpenNI curContext, int userId)

{

println("onLostUser - userId: " + userId);

}

void onVisibleUser(SimpleOpenNI curContext, int userId)

{

//println("onVisibleUser - userId: " + userId);

}

void drawHead(int userId){

PVector jointPosH = new PVector();

//Create a Vector (to capture the Head joint).

context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_HEAD, jointPosH);

//Get the Head Joint in 3D!

PVector jointPosH_Proj = new PVector();

//Create a Vector (for projecting on 2D).

context.convertRealWorldToProjective(jointPosH, jointPosH_Proj);

//Convert 3D Head Joint Vector to 2D screen (for projecting on 2D).

fill(0,255,255);

stroke(0,255,255.80);

ellipse(jointPosH_Proj.x, jointPosH_Proj.y, 50, 50);

// Extract the x and y position from the Projection Head Joint to draw a circle.

}

Page 32: Kinect=002=skeleton tracking 2d

Nude Descending a Staircase No. 2|| Marcel Duchamp'

Duchamp Effect

Page 33: Kinect=002=skeleton tracking 2d

import SimpleOpenNI.*;

SimpleOpenNI context;

///////////////////////////////////////////////

void setup(){

context = new SimpleOpenNI (this);

context.enableDepth();

context.enableUser();

if(context.isInit() == false){

println("Maybe your Kinect is not connected");

exit();

return;

}

size(context.depthWidth(), context.depthHeight());

background(0);

}

///////////////////////////////////////////////

void draw(){

context.update();

//image(context.userImage(),0,0);

int [] userList = context.getUsers();

for(int i =0; i<userList.length; i++){

if(context.isTrackingSkeleton(userList[i])){

strokeWeight(2);

stroke(0,255,255,80);

drawSkeleton(userList[i]);

drawHead(userList[i]);

}

}

}

void drawSkeleton(int userId)

{

// to get the 3d joint data

/*

PVector jointPos = new PVector();

context.getJointPositionSkeleton(userId,SimpleOpenNI.SKEL_NECK,jointPos);

println(jointPos);

*/

context.drawLimb(userId, SimpleOpenNI.SKEL_HEAD, SimpleOpenNI.SKEL_NECK);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_LEFT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_LEFT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_ELBOW, SimpleOpenNI.SKEL_LEFT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_RIGHT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_RIGHT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, SimpleOpenNI.SKEL_RIGHT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_LEFT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_HIP, SimpleOpenNI.SKEL_LEFT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_KNEE, SimpleOpenNI.SKEL_LEFT_FOOT);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_RIGHT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_HIP, SimpleOpenNI.SKEL_RIGHT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_KNEE, SimpleOpenNI.SKEL_RIGHT_FOOT);

}

// SimpleOpenNI user events///////////////////////////////////////////////////////////////////////////////////////

void onNewUser(SimpleOpenNI curContext, int userId)

{

println("onNewUser - userId: " + userId);

println("\tstart tracking skeleton");

context.startTrackingSkeleton(userId);

}

void onLostUser(SimpleOpenNI curContext, int userId)

{

println("onLostUser - userId: " + userId);

}

void onVisibleUser(SimpleOpenNI curContext, int userId)

{

//println("onVisibleUser - userId: " + userId);

}

void drawHead(int userId){

PVector jointPosH = new PVector();

//Create a Vector (to capture the Head joint).

context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_HEAD, jointPosH);

//Get the Head Joint in 3D!

PVector jointPosH_Proj = new PVector();

//Create a Vector (for projecting on 2D).

context.convertRealWorldToProjective(jointPosH, jointPosH_Proj);

//Convert 3D Head Joint Vector to 2D screen (for projecting on 2D).

fill(0,255,255,80);

stroke(0,255,255.80);

ellipse(jointPosH_Proj.x, jointPosH_Proj.y, 50, 50);

// Extract the x and y position from the Projection Head Joint to draw a circle.

}

Page 34: Kinect=002=skeleton tracking 2d
Page 35: Kinect=002=skeleton tracking 2d

[ If-else ]Again

Page 36: Kinect=002=skeleton tracking 2d

import SimpleOpenNI.*;

SimpleOpenNI context;

///////////////////////////////////////////////

void setup(){

context = new SimpleOpenNI (this);

context.enableDepth();

context.enableUser();

if(context.isInit() == false){

println("Maybe your Kinect is not connected");

exit();

return;

}

size(context.depthWidth(), context.depthHeight());

}

///////////////////////////////////////////////

void draw(){

background(0);

context.update();

//image(context.userImage(),0,0);

int [] userList = context.getUsers();

for(int i =0; i<userList.length; i++){

if(context.isTrackingSkeleton(userList[i])){

strokeWeight(2);

stroke(0,255,255,80);

drawSkeleton(userList[i]);

drawHead(userList[i]);

PVector myHead = new PVector();

context.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_HEAD, myHead);

PVector myHead_Proj = new PVector();

context.convertRealWorldToProjective(myHead, myHead_Proj);

if(myHead_Proj.x> width/2){

background(255,0,255);

}

else{

background(255,255,0);

}

}

}

}

void drawSkeleton(int userId)

{

// to get the 3d joint data

/*

PVector jointPos = new PVector();

context.getJointPositionSkeleton(userId,SimpleOpenNI.SKEL_NECK,jointPos);

println(jointPos);

*/

context.drawLimb(userId, SimpleOpenNI.SKEL_HEAD, SimpleOpenNI.SKEL_NECK);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_LEFT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_LEFT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_ELBOW, SimpleOpenNI.SKEL_LEFT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_RIGHT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_RIGHT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, SimpleOpenNI.SKEL_RIGHT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_LEFT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_HIP, SimpleOpenNI.SKEL_LEFT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_KNEE, SimpleOpenNI.SKEL_LEFT_FOOT);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_RIGHT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_HIP, SimpleOpenNI.SKEL_RIGHT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_KNEE, SimpleOpenNI.SKEL_RIGHT_FOOT);

}

// SimpleOpenNI user events///////////////////////////////////////////////////////////////////////////////////////

void onNewUser(SimpleOpenNI curContext, int userId)

{

println("onNewUser - userId: " + userId);

println("\tstart tracking skeleton");

context.startTrackingSkeleton(userId);

}

void onLostUser(SimpleOpenNI curContext, int userId)

{

println("onLostUser - userId: " + userId);

}

void onVisibleUser(SimpleOpenNI curContext, int userId)

{

//println("onVisibleUser - userId: " + userId);

}

void drawHead(int userId){

PVector jointPosH = new PVector();

//Create a Vector (to capture the Head joint).

context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_HEAD, jointPosH);

//Get the Head Joint in 3D!

PVector jointPosH_Proj = new PVector();

//Create a Vector (for projecting on 2D).

context.convertRealWorldToProjective(jointPosH, jointPosH_Proj);

//Convert 3D Head Joint Vector to 2D screen (for projecting on 2D).

fill(0,255,255,80);

stroke(0,255,255,80);

ellipse(jointPosH_Proj.x, jointPosH_Proj.y, 50, 50);

// Extract the x and y position from the Projection Head Joint to draw a circle.

}

Page 37: Kinect=002=skeleton tracking 2d

if(myHead_Proj.x > width/2)else

Page 38: Kinect=002=skeleton tracking 2d

But, Dude,

Where is my BODY?

(you should know)

Page 39: Kinect=002=skeleton tracking 2d

import SimpleOpenNI.*;

SimpleOpenNI context;

///////////////////////////////////////////////

void setup(){

context = new SimpleOpenNI (this);

context.enableDepth();

context.enableUser();

if(context.isInit() == false){

println("Maybe your Kinect is not connected");

exit();

return;

}

size(context.depthWidth(), context.depthHeight());

}

///////////////////////////////////////////////

void draw(){

background(0);

context.update();

//image(context.userImage(),0,0);

int [] userList = context.getUsers();

for(int i =0; i<userList.length; i++){

if(context.isTrackingSkeleton(userList[i])){

PVector myHead = new PVector();

context.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_HEAD, myHead);

PVector myHead_Proj = new PVector();

context.convertRealWorldToProjective(myHead, myHead_Proj);

if(myHead_Proj.x> width/2){

background(255,0,255);

}

else{

background(255,255,0);

}

strokeWeight(2);

stroke(0,255,255);

drawSkeleton(userList[i]);

drawHead(userList[i]);

}

}

}

void drawSkeleton(int userId)

{

// to get the 3d joint data

/*

PVector jointPos = new PVector();

context.getJointPositionSkeleton(userId,SimpleOpenNI.SKEL_NECK,jointPos);

println(jointPos);

*/

context.drawLimb(userId, SimpleOpenNI.SKEL_HEAD, SimpleOpenNI.SKEL_NECK);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_LEFT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_LEFT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_ELBOW, SimpleOpenNI.SKEL_LEFT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_RIGHT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_RIGHT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, SimpleOpenNI.SKEL_RIGHT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_LEFT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_HIP, SimpleOpenNI.SKEL_LEFT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_KNEE, SimpleOpenNI.SKEL_LEFT_FOOT);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_RIGHT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_HIP, SimpleOpenNI.SKEL_RIGHT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_KNEE, SimpleOpenNI.SKEL_RIGHT_FOOT);

}

// SimpleOpenNI user events///////////////////////////////////////////////////////////////////////////////////////

void onNewUser(SimpleOpenNI curContext, int userId)

{

println("onNewUser - userId: " + userId);

println("\tstart tracking skeleton");

context.startTrackingSkeleton(userId);

}

void onLostUser(SimpleOpenNI curContext, int userId)

{

println("onLostUser - userId: " + userId);

}

void onVisibleUser(SimpleOpenNI curContext, int userId)

{

//println("onVisibleUser - userId: " + userId);

}

void drawHead(int userId){

PVector jointPosH = new PVector();

//Create a Vector (to capture the Head joint).

context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_HEAD, jointPosH);

//Get the Head Joint in 3D!

PVector jointPosH_Proj = new PVector();

//Create a Vector (for projecting on 2D).

context.convertRealWorldToProjective(jointPosH, jointPosH_Proj);

//Convert 3D Head Joint Vector to 2D screen (for projecting on 2D).

fill(0,255,255);

stroke(0,255,255);ellipse(jointPosH_Proj.x, jointPosH_Proj.y, 50, 50);

// Extract the x and y position from the Projection Head Joint to draw a circle.

}

Page 40: Kinect=002=skeleton tracking 2d

if(myHead_Proj.x > width/2)else

Here you go

Page 41: Kinect=002=skeleton tracking 2d

[ If-else ]Change

Head to Hand

Page 42: Kinect=002=skeleton tracking 2d

import SimpleOpenNI.*;

SimpleOpenNI context;

///////////////////////////////////////////////

void setup(){

context = new SimpleOpenNI (this);

context.enableDepth();

context.enableUser();

if(context.isInit() == false){

println("Maybe your Kinect is not connected");

exit();

return;

}

size(context.depthWidth(), context.depthHeight());

}

///////////////////////////////////////////////

void draw(){background(0);

context.update();

//image(context.userImage(),0,0);

int [] userList = context.getUsers();

for(int i =0; i<userList.length; i++){

if(context.isTrackingSkeleton(userList[i])){

PVector myRHand = new PVector();

context.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_RIGHT_HAND, myRHand);

PVector myRHand_Proj = new PVector();

context.convertRealWorldToProjective(myRHand, myRHand_Proj);

if(myRHand_Proj.x> width/2){

background(255,0,255);

}

else{

background(255,255,0);

}

strokeWeight(2);

stroke(0,255,255);

drawSkeleton(userList[i]);

drawHead(userList[i]);

stroke(0,255,255);

strokeWeight(2);

fill(0,255,0);

ellipse(myRHand_Proj.x,myRHand_Proj.y,50,50);

stroke(0,255,255);

strokeWeight(2);

fill(255,0,255);

ellipse(myRHand_Proj.x,myRHand_Proj.y,25,25);

}

}

}

void drawSkeleton(int userId)

{

// to get the 3d joint data

/*

PVector jointPos = new PVector();

context.getJointPositionSkeleton(userId,SimpleOpenNI.SKEL_NECK,jointPos);

println(jointPos);

*/

context.drawLimb(userId, SimpleOpenNI.SKEL_HEAD, SimpleOpenNI.SKEL_NECK);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_LEFT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_LEFT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_ELBOW, SimpleOpenNI.SKEL_LEFT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_RIGHT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_RIGHT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, SimpleOpenNI.SKEL_RIGHT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_LEFT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_HIP, SimpleOpenNI.SKEL_LEFT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_KNEE, SimpleOpenNI.SKEL_LEFT_FOOT);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_RIGHT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_HIP, SimpleOpenNI.SKEL_RIGHT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_KNEE, SimpleOpenNI.SKEL_RIGHT_FOOT);

}

// SimpleOpenNI user events///////////////////////////////////////////////////////////////////////////////////////

void onNewUser(SimpleOpenNI curContext, int userId)

{

println("onNewUser - userId: " + userId);

println("\tstart tracking skeleton");

context.startTrackingSkeleton(userId);

}

void onLostUser(SimpleOpenNI curContext, int userId)

{

println("onLostUser - userId: " + userId);

}

void onVisibleUser(SimpleOpenNI curContext, int userId)

{

//println("onVisibleUser - userId: " + userId);

}

void drawHead(int userId){

PVector jointPosH = new PVector();

//Create a Vector (to capture the Head joint).

context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_HEAD, jointPosH);

//Get the Head Joint in 3D!

PVector jointPosH_Proj = new PVector();

//Create a Vector (for projecting on 2D).

context.convertRealWorldToProjective(jointPosH, jointPosH_Proj);

//Convert 3D Head Joint Vector to 2D screen (for projecting on 2D).

fill(0,255,255);

stroke(0,255,255);ellipse(jointPosH_Proj.x, jointPosH_Proj.y, 50, 50);

// Extract the x and y position from the Projection Head Joint to draw a circle.

}

Page 43: Kinect=002=skeleton tracking 2d

if(myHead_Proj.x > width/2)else

Page 44: Kinect=002=skeleton tracking 2d

GIVE ME

2 HANDS[ no If-else ]

Page 45: Kinect=002=skeleton tracking 2d

import SimpleOpenNI.*;

SimpleOpenNI context;

///////////////////////////////////////////////

void setup(){

context = new SimpleOpenNI (this);

context.enableDepth();

context.enableUser();

if(context.isInit() == false){

println("Maybe your Kinect is not connected");

exit();

return;

}

size(context.depthWidth(), context.depthHeight());

}

///////////////////////////////////////////////

void draw(){background(0);

context.update();

//image(context.userImage(),0,0);

int [] userList = context.getUsers();

for(int i =0; i<userList.length; i++){

if(context.isTrackingSkeleton(userList[i])){

PVector myRHand = new PVector();

context.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_RIGHT_HAND, myRHand);

PVector myRHand_Proj = new PVector();

context.convertRealWorldToProjective(myRHand, myRHand_Proj);

PVector myLHand = new PVector();

context.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_LEFT_HAND, myLHand);

PVector myLHand_Proj = new PVector();

context.convertRealWorldToProjective(myLHand, myLHand_Proj);

strokeWeight(2);

stroke(0,255,255);

drawSkeleton(userList[i]);

drawHead(userList[i]);

stroke(0,255,255);

strokeWeight(2);

fill(0,255,0);

ellipse(myRHand_Proj.x,myRHand_Proj.y,50,50);

ellipse(myLHand_Proj.x,myRHand_Proj.y,50,50);

stroke(0,255,255);

strokeWeight(2);

fill(255,0,255);

ellipse(myRHand_Proj.x,myRHand_Proj.y,25,25);

ellipse(myLHand_Proj.x,myRHand_Proj.y,25,25);

}

}

}

void drawSkeleton(int userId)

{

// to get the 3d joint data

/*

PVector jointPos = new PVector();

context.getJointPositionSkeleton(userId,SimpleOpenNI.SKEL_NECK,jointPos);

println(jointPos);

*/

context.drawLimb(userId, SimpleOpenNI.SKEL_HEAD, SimpleOpenNI.SKEL_NECK);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_LEFT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_LEFT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_ELBOW, SimpleOpenNI.SKEL_LEFT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_RIGHT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_RIGHT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, SimpleOpenNI.SKEL_RIGHT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_LEFT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_HIP, SimpleOpenNI.SKEL_LEFT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_KNEE, SimpleOpenNI.SKEL_LEFT_FOOT);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_RIGHT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_HIP, SimpleOpenNI.SKEL_RIGHT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_KNEE, SimpleOpenNI.SKEL_RIGHT_FOOT);

}

// SimpleOpenNI user events///////////////////////////////////////////////////////////////////////////////////////

void onNewUser(SimpleOpenNI curContext, int userId)

{

println("onNewUser - userId: " + userId);

println("\tstart tracking skeleton");

context.startTrackingSkeleton(userId);

}

void onLostUser(SimpleOpenNI curContext, int userId)

{

println("onLostUser - userId: " + userId);

}

void onVisibleUser(SimpleOpenNI curContext, int userId)

{

//println("onVisibleUser - userId: " + userId);

}

void drawHead(int userId){

PVector jointPosH = new PVector();

//Create a Vector (to capture the Head joint).

context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_HEAD, jointPosH);

//Get the Head Joint in 3D!

PVector jointPosH_Proj = new PVector();

//Create a Vector (for projecting on 2D).

context.convertRealWorldToProjective(jointPosH, jointPosH_Proj);

//Convert 3D Head Joint Vector to 2D screen (for projecting on 2D).

fill(0,255,255);

stroke(0,255,255);ellipse(jointPosH_Proj.x, jointPosH_Proj.y, 50, 50);

// Extract the x and y position from the Projection Head Joint to draw a circle.

}

Page 46: Kinect=002=skeleton tracking 2d

We got hands!

Page 47: Kinect=002=skeleton tracking 2d

Please save this file.

Page 48: Kinect=002=skeleton tracking 2d

Make V-buttons

Page 49: Kinect=002=skeleton tracking 2d

I will only keep the

“void draw()” part for

now, since there will

not be too many

changes in the rest.

Page 50: Kinect=002=skeleton tracking 2d

void draw(){background(0);

context.update();

//Right button

noStroke();

fill(255,0,255,80);

ellipse(3*width/4,height/2,100,100);

stroke(255,0,255,80);

noFill();

ellipse(3*width/4,height/2,120,120);

//Left button

noStroke();

fill(255,255,0,80);

ellipse(width/4,height/2,100,100);

stroke(255,255,0,80);

noFill();

ellipse(width/4,height/2,120,120);

int [] userList = context.getUsers();

for(int i =0; i<userList.length; i++){

if(context.isTrackingSkeleton(userList[i])){

PVector myRHand = new PVector();

context.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_RIGHT_HAND, myRHand);

PVector myRHand_Proj = new PVector();

context.convertRealWorldToProjective(myRHand, myRHand_Proj);

PVector myLHand = new PVector();

context.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_LEFT_HAND, myLHand);

PVector myLHand_Proj = new PVector();

context.convertRealWorldToProjective(myLHand, myLHand_Proj);

strokeWeight(2);

stroke(0,255,255);

drawSkeleton(userList[i]);

drawHead(userList[i]);

stroke(0,255,255);

strokeWeight(2);

fill(0,255,0);

ellipse(myRHand_Proj.x,myRHand_Proj.y,50,50);

ellipse(myLHand_Proj.x,myRHand_Proj.y,50,50);

stroke(0,255,255);

strokeWeight(2);

fill(255,0,255);

ellipse(myRHand_Proj.x,myRHand_Proj.y,25,25);

ellipse(myLHand_Proj.x,myRHand_Proj.y,25,25);

}

}

}

We need

pre-set

buttons

Page 51: Kinect=002=skeleton tracking 2d

Keep them transparent, as a default mode

Page 52: Kinect=002=skeleton tracking 2d

If you move your

hand to “?AREA”,

it will trigger the

buttons.

Page 53: Kinect=002=skeleton tracking 2d

void draw(){background(0);

context.update();

//Right button

noStroke();

fill(255,0,255,80);

ellipse(3*width/4,height/2,100,100);

stroke(255,0,255,80);

noFill();

ellipse(3*width/4,height/2,120,120);

//Left button

noStroke();

fill(255,255,0,80);

ellipse(width/4,height/2,100,100);

stroke(255,255,0,80);

noFill();

ellipse(width/4,height/2,120,120);

int [] userList = context.getUsers();

for(int i =0; i<userList.length; i++){

if(context.isTrackingSkeleton(userList[i])){

PVector myRHand = new PVector();

context.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_RIGHT_HAND, myRHand);

PVector myRHand_Proj = new PVector();

context.convertRealWorldToProjective(myRHand, myRHand_Proj);

PVector myLHand = new PVector();

context.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_LEFT_HAND, myLHand);

PVector myLHand_Proj = new PVector();

context.convertRealWorldToProjective(myLHand, myLHand_Proj);

strokeWeight(2);

stroke(0,255,255);

drawSkeleton(userList[i]);

drawHead(userList[i]);

stroke(0,255,255);

strokeWeight(2);

fill(0,255,0);

ellipse(myRHand_Proj.x,myRHand_Proj.y,50,50);

ellipse(myLHand_Proj.x,myRHand_Proj.y,50,50);

stroke(0,255,255);

strokeWeight(2);

fill(255,0,255);

ellipse(myRHand_Proj.x,myRHand_Proj.y,25,25);

ellipse(myLHand_Proj.x,myRHand_Proj.y,25,25);

//R_Trigger

if(myRHand_Proj.x<3*width/4+25 && myRHand_Proj.x>3*width/4-

25 && myRHand_Proj.y<height/2+25 && myRHand_Proj.y>height/2-

25){

noStroke();

fill(255,0,255);

ellipse(3*width/4,height/2,100,100);

stroke(255,0,255);

noFill();

ellipse(3*width/4,height/2,120,120);

}

//L_Trigger

if(myLHand_Proj.x<width/4+25 && myLHand_Proj.x>width/4-25 &&

myLHand_Proj.y<height/2+25 && myLHand_Proj.y>height/2-25){

noStroke();

fill(255,255,0);

ellipse(width/4,height/2,100,100);

stroke(255,255,0);

noFill();

ellipse(width/4,height/2,120,120);

}

}

}

}

Let’s

make it

clear.

Page 54: Kinect=002=skeleton tracking 2d

//R_Trigger

if(myRHand_Proj.x<3*width/4+25 && myRHand_Proj.x>3*width/4-25 && myRHand_Proj.y<height/2+25 && myRHand_Proj.y>height/2-25){

noStroke();

fill(255,0,255);

ellipse(3*width/4,height/2,100,100);

stroke(255,0,255);

noFill();

ellipse(3*width/4,height/2,120,120);

}

//L_Trigger

if(myLHand_Proj.x<width/4+25 && myLHand_Proj.x>width/4-25 && myLHand_Proj.y<height/2+25 && myLHand_Proj.y>height/2-25){

noStroke();

fill(255,255,0);

ellipse(width/4,height/2,100,100);

stroke(255,255,0);

noFill();

ellipse(width/4,height/2,120,120);

}

Try to explain, please.

Page 55: Kinect=002=skeleton tracking 2d

(width/4, height/2)

25

25

Page 56: Kinect=002=skeleton tracking 2d

if(myHead_Proj.x > width/2)else

Page 57: Kinect=002=skeleton tracking 2d

THINK:

if I want not only

Left hand for Left button

Right hand for Right button

Page 58: Kinect=002=skeleton tracking 2d

//R_Trigger

if(myRHand_Proj.x<3*width/4+25 && myRHand_Proj.x>3*width/4-25 && myRHand_Proj.y<height/2+25 && myRHand_Proj.y>height/2-25

|| myLHand_Proj.x<3*width/4+25 && myLHand_Proj.x>3*width/4-25 && myLHand_Proj.y<height/2+25 && myLHand_Proj.y>height/2-25)

){

noStroke();

fill(255,0,255);

ellipse(3*width/4,height/2,100,100);

stroke(255,0,255);

noFill();

ellipse(3*width/4,height/2,120,120);

}

//L_Trigger

if(myLHand_Proj.x<width/4+25 && myLHand_Proj.x>width/4-25 && myLHand_Proj.y<height/2+25 && myLHand_Proj.y>height/2-25

|| myRHand_Proj.x<width/4+25 && myRHand_Proj.x>width/4-25 && myRHand_Proj.y<height/2+25 && myRHand_Proj.y>height/2-25

){

noStroke();

fill(255,255,0);

ellipse(width/4,height/2,100,100);

stroke(255,255,0);

noFill();

ellipse(width/4,height/2,120,120);

}

Put “OR” in the code

Page 59: Kinect=002=skeleton tracking 2d

You are the dancing queen

Page 60: Kinect=002=skeleton tracking 2d

Please save another file.

Page 61: Kinect=002=skeleton tracking 2d

Let’s make

Some Noise!!!

Page 62: Kinect=002=skeleton tracking 2d

Try to combine

an example from

“minim” library

Page 63: Kinect=002=skeleton tracking 2d

Minim has been

embedded in

Processing.

Yours might look

different than this one,

but sure you can still

find this

“TriggerASample”

file.

Page 64: Kinect=002=skeleton tracking 2d

import ddf.minim.*;

Minim minim;

AudioSample kick;

AudioSample snare;

void setup()

{

size(512, 200, P3D);

minim = new Minim(this);

// load BD.wav from the data folder

kick = minim.loadSample( "BD.mp3", // filename

512 // buffer size

);

// if a file doesn't exist, loadSample will return null

if ( kick == null ) println("Didn't get kick!");

// load SD.wav from the data folder

snare = minim.loadSample("SD.wav", 512);

if ( snare == null ) println("Didn't get snare!");

}

void draw()

{

background(0);

stroke(255);

// use the mix buffer to draw the waveforms.

for (int i = 0; i < kick.bufferSize() - 1; i++)

{

float x1 = map(i, 0, kick.bufferSize(), 0, width);

float x2 = map(i+1, 0, kick.bufferSize(), 0, width);

line(x1, 50 - kick.mix.get(i)*50, x2, 50 -

kick.mix.get(i+1)*50);

line(x1, 150 - snare.mix.get(i)*50, x2, 150 -

snare.mix.get(i+1)*50);

}

}

void keyPressed()

{

if ( key == 's' ) snare.trigger();

if ( key == 'k' ) kick.trigger();

}

I simplify the code.

The color parts are what we need.

You can run the example, and press the S or K key on your keyboard.

Page 65: Kinect=002=skeleton tracking 2d

I hope you should know

How to do it!

Page 66: Kinect=002=skeleton tracking 2d

import SimpleOpenNI.*;

SimpleOpenNI context;

import ddf.minim.*;

Minim minim;

AudioSample kick;

AudioSample snare;

void setup(){context = new SimpleOpenNI (this);

context.enableDepth();

context.enableUser();

minim = new Minim(this);

kick = minim.loadSample( "BD.mp3", 512 );

// if a file doesn't exist, loadSample will return null

if ( kick == null ) println("Didn't get kick!");

// load SD.wav from the data folder

snare = minim.loadSample("SD.wav", 512);

if ( snare == null ) println("Didn't get snare!");

if(context.isInit() == false){

println("Maybe your Kinect is not connected");

exit();

return;

}

size(context.depthWidth(), context.depthHeight());

}

For

*import libraries,

*declare

*void setup()

Page 67: Kinect=002=skeleton tracking 2d

//R_Trigger

if(myRHand_Proj.x<3*width/4+25 && myRHand_Proj.x>3*width/4-25 && myRHand_Proj.y<height/2+25 && myRHand_Proj.y>height/2-25

|| myLHand_Proj.x<3*width/4+25 && myLHand_Proj.x>3*width/4-25 && myLHand_Proj.y<height/2+25 && myLHand_Proj.y>height/2-25)

snare.trigger();

){

noStroke();

fill(255,0,255);

ellipse(3*width/4,height/2,100,100);

stroke(255,0,255);

noFill();

ellipse(3*width/4,height/2,120,120);

}

//L_Trigger

if(myLHand_Proj.x<width/4+25 && myLHand_Proj.x>width/4-25 && myLHand_Proj.y<height/2+25 && myLHand_Proj.y>height/2-25

|| myRHand_Proj.x<width/4+25 && myRHand_Proj.x>width/4-25 && myRHand_Proj.y<height/2+25 && myRHand_Proj.y>height/2-25

){

kick.trigger();

noStroke();

fill(255,255,0);

ellipse(width/4,height/2,100,100);

stroke(255,255,0);

noFill();

ellipse(width/4,height/2,120,120);

}

All you need to do is put the trigger in the button

For

*void draw()

I didn’t put the whole code, it’s too much in one slide.

Page 68: Kinect=002=skeleton tracking 2d

I suppose you have saved your file all the time

(I save it as “skeleton_Button_Sound”)

Page 69: Kinect=002=skeleton tracking 2d

Last thing here you have to do:

Get the sound!!!

Page 70: Kinect=002=skeleton tracking 2d

C:\Users\archgary\Desktop\processing-2.0.3-windows64\processing-

2.0.3\modes\java\libraries\minim\examples\TriggerASample

This is the path

***Everyone might have different path, but just try to find your minim library folder, and

inside the example, there should be the one.

Page 71: Kinect=002=skeleton tracking 2d

Copy this “data” folder and put it in

your “SAVED” file folder

Page 72: Kinect=002=skeleton tracking 2d

Ts…Don…

Now you are the drummer

Page 73: Kinect=002=skeleton tracking 2d

Let’s play a bit pattern

Page 74: Kinect=002=skeleton tracking 2d

Open the file

With 2 hands

Page 75: Kinect=002=skeleton tracking 2d

First, get the girds

Page 76: Kinect=002=skeleton tracking 2d

import SimpleOpenNI.*;

SimpleOpenNI context;

ArrayList grid;

import ddf.minim.*;

Minim minim;

AudioSample kick;

AudioSample snare;

void setup(){

context = new SimpleOpenNI (this);

context.enableDepth();

context.enableUser();

grid = new ArrayList();

if(context.isInit() == false){

println("Maybe your Kinect is not connected");

exit();

return;

}

size(context.depthWidth(), context.depthHeight());

for(int i =0; i<= width; i+=48){

for(int j=0; j<= height; j+=48){

PVector loc = new PVector(i,j,0);

grid.add(loc);

}

}

}

Making

ArrayList for grid

Page 77: Kinect=002=skeleton tracking 2d

void draw(){background(0);

context.update();

int [] userList = context.getUsers();

for(int i =0; i<userList.length; i++){

if(context.isTrackingSkeleton(userList[i])){

PVector myRHand = new PVector();

context.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_RIGHT_HAND, myRHand);

PVector myRHand_Proj = new PVector();

context.convertRealWorldToProjective(myRHand, myRHand_Proj);

PVector myLHand = new PVector();

context.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_LEFT_HAND, myLHand);

PVector myLHand_Proj = new PVector();

context.convertRealWorldToProjective(myLHand, myLHand_Proj);

for(int j=0; j<grid.size();j++){

PVector nLoc = (PVector)grid.get(j);

strokeWeight(1);

stroke(0,255,0);

noFill();

noFill();

ellipse(nLoc.x,nLoc.y,48,48);

}

strokeWeight(2);

stroke(0,255,255);

drawSkeleton(userList[i]);

drawHead(userList[i]);

stroke(0,255,255);

strokeWeight(2);

fill(0,255,0);

ellipse(myRHand_Proj.x,myRHand_Proj.y,50,50);

ellipse(myLHand_Proj.x,myRHand_Proj.y,50,50);

stroke(0,255,255);

strokeWeight(2);

fill(255,0,255);

ellipse(myRHand_Proj.x,myRHand_Proj.y,25,25);

ellipse(myLHand_Proj.x,myRHand_Proj.y,25,25);

}

void drawSkeleton(int userId)

{

// to get the 3d joint data

/*

PVector jointPos = new PVector();

context.getJointPositionSkeleton(userId,SimpleOpenNI.SKEL_NECK,jointPos);

println(jointPos);

*/

context.drawLimb(userId, SimpleOpenNI.SKEL_HEAD, SimpleOpenNI.SKEL_NECK);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_LEFT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_LEFT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_ELBOW, SimpleOpenNI.SKEL_LEFT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_RIGHT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_RIGHT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, SimpleOpenNI.SKEL_RIGHT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_LEFT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_HIP, SimpleOpenNI.SKEL_LEFT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_KNEE, SimpleOpenNI.SKEL_LEFT_FOOT);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_RIGHT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_HIP, SimpleOpenNI.SKEL_RIGHT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_KNEE, SimpleOpenNI.SKEL_RIGHT_FOOT);

}

// SimpleOpenNI user events///////////////////////////////////////////////////////////////////////////////////////

void onNewUser(SimpleOpenNI curContext, int userId)

{

println("onNewUser - userId: " + userId);

println("\tstart tracking skeleton");

context.startTrackingSkeleton(userId);

}

void onLostUser(SimpleOpenNI curContext, int userId)

{

println("onLostUser - userId: " + userId);

}

void onVisibleUser(SimpleOpenNI curContext, int userId)

{

//println("onVisibleUser - userId: " + userId);

}

void drawHead(int userId){

PVector jointPosH = new PVector();

//Create a Vector (to capture the Head joint).

context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_HEAD, jointPosH);

//Get the Head Joint in 3D!

PVector jointPosH_Proj = new PVector();

//Create a Vector (for projecting on 2D).

context.convertRealWorldToProjective(jointPosH, jointPosH_Proj);

//Convert 3D Head Joint Vector to 2D screen (for projecting on 2D).

fill(0,255,255);

stroke(0,255,255);

ellipse(jointPosH_Proj.x, jointPosH_Proj.y, 80, 80);

// Extract the x and y position from the Projection Head Joint to draw a circle.

}

Get the grid point

Draw them

All the skeleton events.

Page 78: Kinect=002=skeleton tracking 2d
Page 79: Kinect=002=skeleton tracking 2d

void draw(){background(0);

context.update();

int [] userList = context.getUsers();

for(int i =0; i<userList.length; i++){

if(context.isTrackingSkeleton(userList[i])){

PVector myRHand = new PVector();

context.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_RIGHT_HAND, myRHand);

PVector myRHand_Proj = new PVector();

context.convertRealWorldToProjective(myRHand, myRHand_Proj);

PVector myLHand = new PVector();

context.getJointPositionSkeleton(userList[i], SimpleOpenNI.SKEL_LEFT_HAND, myLHand);

PVector myLHand_Proj = new PVector();

context.convertRealWorldToProjective(myLHand, myLHand_Proj);

for(int j=0; j<grid.size();j++){

PVector nLoc = (PVector)grid.get(j);

strokeWeight(1);

stroke(0,255,0);

noFill();

PVector att = new PVector(myRHand_Proj.x,myRHand_Proj.y,0);

float distance = PVector.dist(nLoc,att);

float d = (map(distance,100,600,2,48));

float c = (map(distance,100,600,0,255));

fill(0,c,0);

ellipse(nLoc.x,nLoc.y,d,d);

fill(myRHand_Proj.x,myRHand_Proj.y,c);

ellipse(nLoc.x,nLoc.y,d-d/5,d-d/5);

}

strokeWeight(2);

stroke(0,255,255);

drawSkeleton(userList[i]);

drawHead(userList[i]);

stroke(0,255,255);

strokeWeight(2);

fill(0,255,0);

ellipse(myRHand_Proj.x,myRHand_Proj.y,50,50);

ellipse(myLHand_Proj.x,myRHand_Proj.y,50,50);

stroke(0,255,255);

strokeWeight(2);

fill(255,0,255);

ellipse(myRHand_Proj.x,myRHand_Proj.y,25,25);

ellipse(myLHand_Proj.x,myRHand_Proj.y,25,25);

}

void drawSkeleton(int userId)

{

// to get the 3d joint data

/*

PVector jointPos = new PVector();

context.getJointPositionSkeleton(userId,SimpleOpenNI.SKEL_NECK,jointPos);

println(jointPos);

*/

context.drawLimb(userId, SimpleOpenNI.SKEL_HEAD, SimpleOpenNI.SKEL_NECK);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_LEFT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_LEFT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_ELBOW, SimpleOpenNI.SKEL_LEFT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_RIGHT_SHOULDER);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_RIGHT_ELBOW);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, SimpleOpenNI.SKEL_RIGHT_HAND);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_TORSO);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_LEFT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_HIP, SimpleOpenNI.SKEL_LEFT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_KNEE, SimpleOpenNI.SKEL_LEFT_FOOT);

context.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_RIGHT_HIP);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_HIP, SimpleOpenNI.SKEL_RIGHT_KNEE);

context.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_KNEE, SimpleOpenNI.SKEL_RIGHT_FOOT);

}

// SimpleOpenNI user events///////////////////////////////////////////////////////////////////////////////////////

void onNewUser(SimpleOpenNI curContext, int userId)

{

println("onNewUser - userId: " + userId);

println("\tstart tracking skeleton");

context.startTrackingSkeleton(userId);

}

void onLostUser(SimpleOpenNI curContext, int userId)

{

println("onLostUser - userId: " + userId);

}

void onVisibleUser(SimpleOpenNI curContext, int userId)

{

//println("onVisibleUser - userId: " + userId);

}

void drawHead(int userId){

PVector jointPosH = new PVector();

//Create a Vector (to capture the Head joint).

context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_HEAD, jointPosH);

//Get the Head Joint in 3D!

PVector jointPosH_Proj = new PVector();

//Create a Vector (for projecting on 2D).

context.convertRealWorldToProjective(jointPosH, jointPosH_Proj);

//Convert 3D Head Joint Vector to 2D screen (for projecting on 2D).

fill(0,255,255);

stroke(0,255,255);

ellipse(jointPosH_Proj.x, jointPosH_Proj.y, 80, 80);

// Extract the x and y position from the Projection Head Joint to draw a circle.

}

Calculate distances

Mapping radius

Draw the patterns

Make Right hand as a attraction point

Mapping colors

Page 80: Kinect=002=skeleton tracking 2d
Page 81: Kinect=002=skeleton tracking 2d

Make Your Own

Patterns