コード例 #1
0
 /**
  * Performs hmm train for all training data set.<br>
  * First quantizes the feature vector against codebook, and then train baum-welch
  *
  * @return
  */
 public boolean trainHMM() {
   boolean operationSuccess = false;
   codebook = new Codebook();
   database.setMode(DBMode.TRAINDATA);
   Model[][] regModels = database.readAllDataofCurrentMode();
   String[] gestName = database.getRegisteredModelNames();
   int quantizedSeq[][];
   HiddenMarkov mkv = new HiddenMarkov(NUM_STATES, NUM_SYMBOLS);
   // for each gesture
   for (int i = 0; i < regModels.length; i++) {
     operationSuccess = false;
     // for each train sample of current gesture
     quantizedSeq = new int[regModels[i].length][];
     for (int j = 0; j < regModels[i].length; j++) {
       GestureFeature[] gf = getFeature((RawFeature) regModels[i][j]);
       Points[] pts = getPointsFromFeatureVector(gf);
       quantizedSeq[j] = codebook.quantize(pts);
     }
     mkv.setTrainSeq(quantizedSeq);
     mkv.train();
     mkv.save(gestName[i]);
     operationSuccess = true;
   }
   return operationSuccess;
 }
コード例 #2
0
 public boolean saveCaptured(RawFeature rf, String gestName) {
   boolean operationSuccess = false;
   database.setMode(DBMode.TRAINDATA);
   database.saveModel(rf, gestName);
   operationSuccess = true;
   return operationSuccess;
 }
コード例 #3
0
 /**
  * Generates codebook by clustering all features in training set raw data
  *
  * @return
  */
 public boolean generateCodeBook() {
   boolean operationSuccess = false;
   database.setMode(DBMode.TRAINDATA);
   Model[][] regModels = database.readAllDataofCurrentMode();
   int totalFrames = 0;
   allFeaturesList.clear();
   // extract single list of all features
   for (int i = 0; i < regModels.length; i++) {
     for (int j = 0; j < regModels[i].length; j++) {
       GestureFeature[] gf = getFeature((RawFeature) regModels[i][j]);
       for (int k = 0; k < gf.length; k++) {
         allFeaturesList.add(gf[k]);
         totalFrames++;
       }
     }
   } //
   // single array from list
   GestureFeature[] allFeaturesArr = new GestureFeature[totalFrames];
   allFeaturesArr = allFeaturesList.toArray(new GestureFeature[0]);
   // clustering is done automatically after callng constructor
   Codebook cbk = new Codebook(getPointsFromFeatureVector(allFeaturesArr));
   cbk.saveToFile();
   operationSuccess = true;
   return operationSuccess;
 }
コード例 #4
0
 public String[] readTrainData1D() {
   database.setMode(DBMode.TRAINDATA);
   return (database.getRegisteredModelNames());
 }
コード例 #5
0
 public String[] readRegGestureModels() {
   database.setMode(DBMode.HMM_MODEL);
   return (database.getRegisteredModelNames());
 }