Commit 2989fd0e authored by mzed's avatar mzed

some general cleanup

parent b591064d
......@@ -8,20 +8,12 @@
#include "rapidGVF.h"
#include "../trainingData.h"
rapidGVF::rapidGVF()
{
// Initialised with default configuration
this->gvf = new GVF();
this->currentGesture = GVFGesture();
}
rapidGVF::rapidGVF() {}
rapidGVF::~rapidGVF()
{
delete this->gvf;
this->currentGesture = NULL;
}
rapidGVF::~rapidGVF() {}
bool rapidGVF::train(const rapidmix::trainingData &newTrainingData) {
bool rapidGVF::train(const rapidmix::trainingData &newTrainingData)
{
if (newTrainingData.trainingSet.size() < 1) {
// no recorded phrase
......@@ -33,15 +25,14 @@ bool rapidGVF::train(const rapidmix::trainingData &newTrainingData) {
return false;
}
if(gvf->getState() != GVF::STATE_LEARNING)
if(gvf.getState() != GVF::STATE_LEARNING)
{
gvf->setState(GVF::STATE_LEARNING);
gvf.setState(GVF::STATE_LEARNING);
}
//Go through every phrase
for (int h = 0; h < newTrainingData.trainingSet.size(); ++h) { //I changed this because the default set is gone. -MZ
this->gvf->startGesture();
for (int h = 0; h < newTrainingData.trainingSet.size(); ++h) {
gvf.startGesture();
for (int i = 0; i < newTrainingData.trainingSet[h].elements.size(); ++i) {
std::vector<double> vd = newTrainingData.trainingSet[h].elements[i].input;
......@@ -50,53 +41,59 @@ bool rapidGVF::train(const rapidmix::trainingData &newTrainingData) {
std::vector<float> vf(vd.begin(), vd.end());
this->currentGesture.addObservation(vf);
}
this->gvf->addGestureTemplate(this->currentGesture);
gvf.addGestureTemplate(this->currentGesture);
}
return true;
}
std::vector<double> rapidGVF::run(const std::vector<double> &inputVector){
std::vector<double> rapidGVF::run(const std::vector<double> &inputVector)
{
if (inputVector.size() == 0) {
return std::vector<double>();
}
gvf->restart();
gvf.restart();
if(gvf->getState() != GVF::STATE_FOLLOWING)
if (gvf.getState() != GVF::STATE_FOLLOWING)
{
gvf->setState(GVF::STATE_FOLLOWING);
gvf.setState(GVF::STATE_FOLLOWING);
}
// Using template <class InputIterator> vector to change for vec<double> to vec<float>
std::vector<float> vf(inputVector.begin(),inputVector.end());
this->currentGesture.addObservation(vf);
this->outcomes = this->gvf->update(this->currentGesture.getLastObservation());
outcomes = gvf.update(this->currentGesture.getLastObservation());
std::vector<double> output;
output.push_back(this->outcomes.likeliestGesture);
output.insert(output.end(), this->outcomes.likelihoods.begin(), this->outcomes.likelihoods.end());
output.insert(output.end(), this->outcomes.alignments.begin(), this->outcomes.alignments.end());
output.push_back(outcomes.likeliestGesture);
output.insert(output.end(), outcomes.likelihoods.begin(), outcomes.likelihoods.end());
output.insert(output.end(), outcomes.alignments.begin(), outcomes.alignments.end());
return output;
}
const std::vector<float> rapidGVF::getLikelihoods() {
const std::vector<float> rapidGVF::getLikelihoods()
{
return outcomes.likelihoods;
};
const std::vector<float> rapidGVF::getAlignments() {
const std::vector<float> rapidGVF::getAlignments()
{
return outcomes.alignments;
};
const std::vector<std::vector<float> > * rapidGVF::getDynamics() {
const std::vector<std::vector<float> > * rapidGVF::getDynamics()
{
return &outcomes.dynamics;
};
const std::vector<std::vector<float> > * rapidGVF::getScalings() {
const std::vector<std::vector<float> > * rapidGVF::getScalings()
{
return &outcomes.scalings;
};
const std::vector<std::vector<float> > * rapidGVF::getRotations() {
const std::vector<std::vector<float> > * rapidGVF::getRotations()
{
return &outcomes.rotations;
};
......@@ -34,8 +34,8 @@ public:
const std::vector<std::vector<float> > * getScalings();
const std::vector<std::vector<float> > * getRotations();
protected:
GVF * gvf;
private:
GVF gvf;
GVFGesture currentGesture;
GVFOutcomes outcomes;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment