//-------------------------------------------------------------- void ofApp::update(){ openNIDevice.update(); // reset all depthThresholds to 0,0,0 for(int i = 0; i < openNIDevice.getMaxNumHands(); i++){ ofxOpenNIDepthThreshold & depthThreshold = openNIDevice.getDepthThreshold(i); ofPoint leftBottomNearWorld = ofPoint(0,0,0); ofPoint rightTopFarWorld = ofPoint(0,0,0); ofxOpenNIROI roi = ofxOpenNIROI(leftBottomNearWorld, rightTopFarWorld); depthThreshold.setROI(roi); } // iterate through users for (int i = 0; i < openNIDevice.getNumTrackedHands(); i++){ // get a reference to this user ofxOpenNIHand & hand = openNIDevice.getTrackedHand(i); // get hand position ofPoint & handWorldPosition = hand.getWorldPosition(); // remember to use world position for setting ROIs!!! // set depthThresholds based on handPosition ofxOpenNIDepthThreshold & depthThreshold = openNIDevice.getDepthThreshold(i); // we just use hand index for the depth threshold index ofPoint leftBottomNearWorld = handWorldPosition - 100; // ofPoint has operator overloading so it'll subtract/add 50 to x, y, z ofPoint rightTopFarWorld = handWorldPosition + 100; ofxOpenNIROI roi = ofxOpenNIROI(leftBottomNearWorld, rightTopFarWorld); depthThreshold.setROI(roi); } }
//-------------------------------------------------------------- void testApp::update(){ openNIDevice.update(); // reset all depthThresholds to 0,0,0 for(int i = 0; i < openNIDevice.getMaxNumHands(); i++){ ofxOpenNIDepthThreshold & depthThreshold = openNIDevice.getDepthThreshold(i); ofPoint leftBottomNearWorld = ofPoint(0,0,0); ofPoint rightTopFarWorld = ofPoint(0,0,0); ofxOpenNIROI roi = ofxOpenNIROI(leftBottomNearWorld, rightTopFarWorld); depthThreshold.setROI(roi); } // iterate through users for (int i = 0; i < openNIDevice.getNumTrackedHands(); i++){ // get a reference to this user ofxOpenNIHand & hand = openNIDevice.getTrackedHand(i); // get hand position ofPoint & handWorldPosition = hand.getWorldPosition(); // remember to use world position for setting ROIs!!! ofxOscMessage m; m.setAddress("/mouse"+ofToString(i)+"/position"); m.addIntArg(hand.getPosition().x); m.addIntArg(hand.getPosition().y); sender.sendMessage(m); // set depthThresholds based on handPosition ofxOpenNIDepthThreshold & depthThreshold = openNIDevice.getDepthThreshold(i); // we just use hand index for the depth threshold index ofPoint leftBottomNearWorld = handWorldPosition - 100; // ofPoint has operator overloading so it'll subtract/add 50 to x, y, z ofPoint rightTopFarWorld = handWorldPosition + 100; ofxOpenNIROI roi = ofxOpenNIROI(leftBottomNearWorld, rightTopFarWorld); depthThreshold.setROI(roi); } for (int i = openNIDevice.getNumTrackedHands(); i < 4; i++){ // get a reference to this user ofxOscMessage m; m.setAddress("/mouse"+ofToString(i)+"/position"); m.addIntArg(-10); m.addIntArg(-10); sender.sendMessage(m); } //---osc }