//--------------------------------------------------------------
bool ofxHandGenerator::setup(ofxOpenNIContext* pContext, int number_of_hands) {
	
	context = pContext;
	context->getDepthGenerator(&depth_generator);
	
	XnStatus result = XN_STATUS_OK;	
	
	// setup a gesture generator using our ofxGestureGenerator wrapper
	gesture_generator.setup(context);
	ofAddListener(gesture_generator.gestureRecognized, this, &ofxHandGenerator::gestureRecognized); 
	
	// Try to fetch hands generator before creating one
	if(pContext->getHandsGenerator(&hands_generator)) {
		// found the hands generator - for do nothing		
	} else {
		result = hands_generator.Create(context->getXnContext());
		CHECK_RC(result, "Creating hand generator");
		hands_generator.StartGenerating();
	}
	
	// pre-generate the tracked users.
	setMaxNumHands(number_of_hands);
	
	found_hands = 0;
	
	isFiltering = false;
	
	printf("Hands generator inited\n");
	
	startTrackHands();
	
	return true;
}
示例#2
0
// Stop/Start hand tracking
//--------------------------------------------------------------
void ofxHandGenerator::toggleTrackHands() {
	if (!bIsTracking) {
		startTrackHands();
	} else stopTrackHands();
}