void SWNUI::mode_gesture() { switch(state) { default: state = INIT; break; case INIT: button_enableInterrupt(); sleep(); delay(CHANGE_MODE_TIME); changeMode_management(); if(mode == M_GESTURE) { state = SAMPLE; button_disableInterrupt(); } break; case SAMPLE: refreshGestureArrays(); while(button_press()) { samples = adxl_sampling(); gestures(); delay(T_SAMPLE); } state = SEND; break; case SEND: gestureRecognition(); gestureSend(); state = INIT; break; } }
GestureHMM* GestureHMM::fromXML(string filename){ ofxXmlSettings XML; XML.loadFile(filename); string name = XML.getValue("name", ""); int alphabet = XML.getValue("alphabet", 0); int hiddenStates = XML.getValue("hiddenStates", 0); mat prior; mat transmat; mat obsmat; prior = matrix_from_string<mat>( XML.getValue("prior", "") ); transmat = matrix_from_string<mat>( XML.getValue("transmat", "") ); obsmat = matrix_from_string<mat>( XML.getValue("obsmat", "") ); GestureHMM * g = new GestureHMM(alphabet, hiddenStates, prior, transmat, obsmat); g->name = name; XML.pushTag("gestures"); int num_gesture = XML.getNumTags("train_gestures"); //cout << "fromXML num_gesture: " << num_gesture << endl; if(num_gesture>0) { vector<Gesture*> gestures(num_gesture); for(int i = 0; i < num_gesture; i++) { string labels_string = XML.getValue("train_gestures;labeled", "", i); vector<int> labels = intvector_from_string(labels_string); vector<ofPoint> raws = ofPointvector_from_string(XML.getValue("train_gestures:raw", "", i)); gestures[i] = new Gesture(raws, labels); } //cout << "GestureHMM::fromXML _trainset size: " << gestures.size() << endl; g->_trainset = gestures; } XML.popTag(); return g; }