Skip to content

Commit

Permalink
Versione interattiva.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea committed Nov 27, 2008
1 parent c7fb616 commit 1d328f7
Show file tree
Hide file tree
Showing 16 changed files with 10,961 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ hmm/SConstruct

# Ignore backups
*~
tempGesture.txt

# Ignore Scons stuff
config.log
Expand Down
68 changes: 68 additions & 0 deletions wiiuse/GestureModel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include "GestureModel.h"

GestureModel::GestureModel()
{ int n_stati = 5, n_simboli = 14 ,span = 1;
this->gestureHMM = new HMM(n_stati, n_simboli, span);
this->quant = new Quantizer2();
this->quantizerTrained = false;
}

GestureModel::GestureModel(int n_stati, int span)
{ int n_simboli = 14;
this->gestureHMM = new HMM(n_stati, n_simboli, span);
this->quant = new Quantizer2();
this->quantizerTrained = false;
}

GestureModel::~GestureModel()
{
delete this->gestureHMM;
delete this->quant;
}

void GestureModel::setHMM(HMM* newHMM){
delete this->gestureHMM;
this->gestureHMM = newHMM;
}

HMM* GestureModel::getHMM(){
return this->gestureHMM;
}

void GestureModel::setQuantizer(Quantizer2* newQuant){
delete this->quant;
this->quant = newQuant;
}

Quantizer2* GestureModel::getQuantizer(){
return this->quant;
}

void GestureModel::trainQuantizer( std::vector<Gesture> dataset ){
quant->train(dataset);
this->quantizerTrained = true;
}

bool GestureModel::isQuantizerTrained(){
return this->quantizerTrained;
}

void GestureModel::trainHMM(std::vector<Gesture > trainSet){
std::vector<std::vector<int> > discreteTrainSet;
for(int i=0; i<trainSet.size(); i++){
discreteTrainSet.push_back( quant->getDiscreteSequence(trainSet.at(i)) );
}
gestureHMM->trainMS( discreteTrainSet );
}

std::vector<double > GestureModel::evaluateGestures(std::vector<Gesture >& testSet){
std::vector<double > results;
for( int i=0; i<testSet.size(); i++ ){
//std::vector<int> discVector = quant->getDiscreteSequence(testSet.at(i));

results.push_back(gestureHMM->getP( quant->getDiscreteSequence(testSet.at(i)) ));
}

return results;
}

Loading

0 comments on commit 1d328f7

Please sign in to comment.