Hand tracking with SimpleOpenNI and Kinect
in
Contributed Library Questions
•
11 months ago
I am trying to write a program, which display a blob tracking the right hand or the head. Is it possible to do that and if yes, where can i find the commands for the right hand or the head detection.
The program must be something similiar to this
import SimpleOpenNI.*;
SimpleOpenNI kinect;
ArrayList<PVector> handPositions;
PVector currentHand;
PVector previousHand;
int x;
int y;
void setup(){
size (640,480);
kinect = new SimpleOpenNI(this);
kinect.setMirror(true);
kinect.enableDepth();
kinect.enableGesture();
kinect.enableHands();
kinect.addGesture("RaiseHand");
handPositions = new ArrayList();
stroke(255,0,0);
strokeWeight(2);
}
void draw(){
kinect.update();
image(kinect.depthImage(),0,0);
for(int i=1;i< handPositions.size(); i++)
{
currentHand = handPositions.get(i);
previousHand = handPositions.get(i-1);
//fill(255,0,0);
//ellipse(previousHand.x,previousHand.y,15,15);
x = int(currentHand.x);
y = int(currentHand.y);
//ellipse(x,y,15,15);
}
println("x="+x);
println("y="+y);
fill(255,0,0);
ellipse(x,y,15,15);
}
void onCreateHands(int handId, PVector position, float time){
kinect.convertRealWorldToProjective(position,position);
handPositions.add(position);
}
void onUpdateHands(int handId, PVector position, float time){
kinect.convertRealWorldToProjective(position, position);
handPositions.add(position);
}
void onDestroyHands(int handId, float time) {
handPositions.clear();
kinect.addGesture("RaiseHand");
}
void onRecognizeGesture(String strGesture, PVector idPosition, PVector endPosition) {
kinect.startTrackingHands(endPosition);
kinect.removeGesture("RaiseHand");
}
1