track hand within a given range?
in
Contributed Library Questions
•
5 months ago
Hi!
Im editing and developing sketch with handtracking from Greg Borensteins example in the book Making things see
I want to be able to just track the hand when its within a given range. Basically I want to filter the tracking so anything outside the given range (for example a couple of meters) doesnt interfere with the handtracking.
Im trying to edit the sketch so as soon as the hand is outside the range the tracking stops and as soon as its inside the range again it continous but run into some problem. Im trying to edit the code in the bottom of this example but running out of ideas. anyone who have some suggestion?
im mainly been working on onCreateHands, onUpdateHands, onDestroyHands and onRecognizeGesture trying to stop the updating of the hand when its outside a range and to call onRecognizeGesture again when its inside. but im a bit stuck at the moment :)
heres the code:
Im editing and developing sketch with handtracking from Greg Borensteins example in the book Making things see
I want to be able to just track the hand when its within a given range. Basically I want to filter the tracking so anything outside the given range (for example a couple of meters) doesnt interfere with the handtracking.
Im trying to edit the sketch so as soon as the hand is outside the range the tracking stops and as soon as its inside the range again it continous but run into some problem. Im trying to edit the code in the bottom of this example but running out of ideas. anyone who have some suggestion?
im mainly been working on onCreateHands, onUpdateHands, onDestroyHands and onRecognizeGesture trying to stop the updating of the hand when its outside a range and to call onRecognizeGesture again when its inside. but im a bit stuck at the moment :)
heres the code:
- import SimpleOpenNI.*;
- SimpleOpenNI kinect;
- ArrayList<PVector> handPositions;
- PVector currentHand;
- PVector previousHand;
- void setup() {
- size(640, 480);
- kinect = new SimpleOpenNI(this);
- kinect.setMirror(true);
- //enable depthMap generation
- kinect.enableDepth();
- // enable hands + gesture generation
- 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);
- line(previousHand.x, previousHand.y, currentHand.x, currentHand.y);
- }
- }
- // -----------------------------------------------------------------
- // hand events
- 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");
- }
- // -----------------------------------------------------------------
- // gesture events
- void onRecognizeGesture(String strGesture,
- PVector idPosition,
- PVector endPosition)
- {
- kinect.startTrackingHands(endPosition);
- kinect.removeGesture("RaiseHand");
- }
1