From 7aeb7f8bc4da17644bc26f122fdd4906c0894217 Mon Sep 17 00:00:00 2001 From: bcaramiaux Date: Fri, 26 Feb 2016 14:01:07 -0500 Subject: [PATCH] fix issues with segmentation, work well on 2d gestures --- GVFlib/GVF.cpp | 44 ++++++++++++++++++++++++++++++++------------ GVFlib/GVF.h | 2 ++ 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/GVFlib/GVF.cpp b/GVFlib/GVF.cpp index 1d40776..36ef7d5 100755 --- a/GVFlib/GVF.cpp +++ b/GVFlib/GVF.cpp @@ -50,7 +50,7 @@ GVF::GVF() parameters.scalingsSpreadingCenter = 1.0; parameters.scalingsSpreadingRange = 0.3; parameters.rotationsSpreadingCenter = 0.0; - parameters.rotationsSpreadingRange = 0.0; + parameters.rotationsSpreadingRange = 0.5; tolerancesetmanually = false; learningGesture = -1; @@ -652,30 +652,50 @@ void GVF::updatePrior(int n) { //-------------------------------------------------------------- void GVF::updateLikelihood(vector obs, int n) { - vector vobs(config.inputDimensions); - setVec(vobs, obs); - - if (config.translate) for (int j=0; j < config.inputDimensions; j++) vobs[j] = vobs[j] - offsets[n][j]; + // if (config.normalization) for (int kk=0; kk 1.0) { if (config.segmentation) { - alignment[n] = fabs(1.0-alignment[n]); // re-spread at the beginning +// alignment[n] = fabs(1.0-alignment[n]); // re-spread at the beginning + alignment[n] = fabs((*rndunif)(unifgen) * 0.5); // classes[n] = n % getNumberOfGestureTemplates(); + offsets[n] = obs; + // dynamics + dynamics[n][0] = ((*rndunif)(unifgen) - 0.5) * parameters.dynamicsSpreadingRange + parameters.dynamicsSpreadingCenter; // spread speed + if (dynamics[n].size()>1) + dynamics[n][1] = ((*rndunif)(unifgen) - 0.5) * parameters.dynamicsSpreadingRange; + // scalings + for(int l = 0; l < scalings[n].size(); l++) + scalings[n][l] = ((*rndunif)(unifgen) - 0.5) * parameters.scalingsSpreadingRange + parameters.scalingsSpreadingCenter; // spread scalings + // rotations + if (rotationsDim!=0) + for(int l = 0; l < rotations[n].size(); l++) + rotations[n][l] = ((*rndunif)(unifgen) - 0.5) * parameters.rotationsSpreadingRange + parameters.rotationsSpreadingCenter; // spread rotations + // prior + prior[n] = 1/(float)parameters.numberParticles; } else{ alignment[n] = fabs(2.0-alignment[n]); // re-spread at the end } } + vector vobs(config.inputDimensions); + setVec(vobs, obs); + + if (config.translate) + for (int j=0; j < config.inputDimensions; j++) + vobs[j] = vobs[j] - offsets[n][j]; + + // take vref from template at the given alignment int gestureIndex = classes[n]; float cursor = alignment[n]; @@ -1096,10 +1116,10 @@ float GVF::getTolerance(){ } ////-------------------------------------------------------------- -//void GVF::setDistribution(float _distribution){ -// //nu = _distribution; -// parameters.distribution = _distribution; -//} +void GVF::setDistribution(float _distribution){ + //nu = _distribution; + parameters.distribution = _distribution; +} // ////-------------------------------------------------------------- //float GVF::getDistribution(){ diff --git a/GVFlib/GVF.h b/GVFlib/GVF.h index 275ca15..647fe7c 100755 --- a/GVFlib/GVF.h +++ b/GVFlib/GVF.h @@ -210,6 +210,8 @@ class GVF */ float getTolerance(); + void setDistribution(float _distribution); + /** * Set number of particles used in estimation * @details default valye is 1000, note that the computational