Public Types | |
enum | GVFState { STATE_CLEAR = 0, STATE_LEARNING, STATE_FOLLOWING, STATE_BYPASS } |
Public Member Functions | |
GVF () | |
~GVF () | |
void | startGesture () |
void | addObservation (vector< float > data) |
void | addGestureTemplate (GVFGesture &gestureTemplate) |
void | replaceGestureTemplate (GVFGesture &gestureTemplate, int index) |
void | removeGestureTemplate (int index) |
void | removeAllGestureTemplates () |
GVFGesture & | getGestureTemplate (int index) |
vector< GVFGesture > & | getAllGestureTemplates () |
int | getNumberOfGestureTemplates () |
vector< int > | getGestureClasses () |
GVFState | setState (GVFState _state, vector< int > indexes=vector< int >()) |
GVFState | getState () |
GVFOutcomes & | update (vector< float > &observation) |
void | setActiveGestures (vector< int > activeGestureIds) |
void | restart () |
void | clear () |
void | translate (bool translateFlag) |
void | segmentation (bool segmentationFlag) |
void | setTolerance (float tolerance) |
float | getTolerance () |
void | setNumberOfParticles (int numberOfParticles) |
int | getNumberOfParticles () |
void | setPredictionSteps (int predictionSteps) |
int | getPredictionSteps () |
void | setResamplingThreshold (int resamplingThreshold) |
int | getResamplingThreshold () |
void | setDynamicsVariance (float dynVariance, int dim=-1) |
void | setDynamicsVariance (vector< float > dynVariance) |
vector< float > | getDynamicsVariance () |
void | setScalingsVariance (float scaleVariance, int dim=-1) |
void | setScalingsVariance (vector< float > scaleVariance) |
vector< float > | getScalingsVariance () |
void | setRotationsVariance (float rotationsVariance, int dim=-1) |
void | setRotationsVariance (vector< float > rotationsVariance) |
vector< float > | getRotationsVariance () |
const vector< vector< float > > & | getParticlesPositions () |
void | setSpreadDynamics (float min, float max, int dim=-1) |
void | setSpreadScalings (float min, float max, int dim=-1) |
void | setSpreadRotations (float min, float max, int dim=-1) |
void | saveTemplates (string filename) |
void | loadTemplates (string filename) |
Protected Attributes | |
GVFConfig | config |
GVFParameters | parameters |
GVFOutcomes | outcomes |
GVFState | state |
GVFGesture | theGesture |
vector< float > | dimWeights |
vector< float > | maxRange |
vector< float > | minRange |
int | dynamicsDim |
int | scalingsDim |
int | rotationsDim |
float | globalNormalizationFactor |
int | mostProbableIndex |
int | learningGesture |
vector< int > | classes |
vector< float > | alignment |
vector< vector< float > > | dynamics |
vector< vector< float > > | scalings |
vector< vector< float > > | rotations |
vector< float > | weights |
vector< float > | prior |
vector< float > | posterior |
vector< float > | likelihood |
vector< float > | estimatedGesture |
vector< float > | estimatedAlignment |
vector< vector< float > > | estimatedDynamics |
vector< vector< float > > | estimatedScalings |
vector< vector< float > > | estimatedRotations |
vector< float > | estimatedProbabilities |
vector< float > | estimatedLikelihoods |
vector< float > | absoluteLikelihoods |
vector< float > | currentVelAcc |
vector< vector< float > > | kalmanDynMatrix |
vector< vector< float > > | kalmanMapMatrix |
bool | tolerancesetmanually |
vector< GVFGesture > | gestureTemplates |
vector< vector< float > > | offsets |
vector< int > | activeGestures |
std::random_device | rd |
std::mt19937 | normgen |
std::normal_distribution< float > * | rndnorm |
std::default_random_engine | unifgen |
std::uniform_real_distribution< float > * | rndunif |
vector< float > | gestureProbabilities |
vector< vector< float > > | particles |
enum GVF::GVFState |
GVF possible states
Enumerator | |
---|---|
STATE_CLEAR |
STATE_CLEAR: clear the GVF and be in standby |
STATE_LEARNING |
STATE_LEARNING: recording mode, input gestures are added to the templates |
STATE_FOLLOWING |
STATE_FOLLOWING: tracking mode, input gestures are classifed and their variations tracked (need the GVF to be trained) |
STATE_BYPASS |
STATE_BYPASS: by pass GVF but does not erase templates or training |
GVF::GVF | ( | ) |
GVF default constructor
use default configuration and parameters, can be changed using accessors
GVF::~GVF | ( | ) |
void GVF::addGestureTemplate | ( | GVFGesture & | gestureTemplate | ) |
Add gesture template to the vocabulary
a gesture template is a GVFGesture object
the | gesture template to be recorded |
void GVF::addObservation | ( | vector< float > | data | ) |
Add an observation to a gesture template
vector | of features |
void GVF::clear | ( | ) |
Clear GVF
delete templates
vector< GVFGesture > & GVF::getAllGestureTemplates | ( | ) |
Get every recorded gesture template
vector< float > GVF::getDynamicsVariance | ( | ) |
Get dynamics variances
vector< int > GVF::getGestureClasses | ( | ) |
Get gesture classes
GVFGesture & GVF::getGestureTemplate | ( | int | index | ) |
Get a specific gesture template a gesture template by another
index | of the template to be returned |
int GVF::getNumberOfGestureTemplates | ( | ) |
Get number of gesture templates in the vocabulary
int GVF::getNumberOfParticles | ( | ) |
Get the current number of particles
const vector< vector< float > > & GVF::getParticlesPositions | ( | ) |
Get particle values
int GVF::getPredictionSteps | ( | ) |
Get the current number of prediction steps
int GVF::getResamplingThreshold | ( | ) |
Get the current resampling threshold
vector< float > GVF::getRotationsVariance | ( | ) |
Get rotation variances
vector< float > GVF::getScalingsVariance | ( | ) |
Get scalings variances
float GVF::getTolerance | ( | ) |
Get the obervation tolerance value
see setTolerance(float tolerance)
void GVF::loadTemplates | ( | string | filename | ) |
Import template data in a filename
needs to respect a given format provided by saveTemplates()
file | name as a string |
void GVF::removeAllGestureTemplates | ( | ) |
Remove every recorded gesture template
void GVF::removeGestureTemplate | ( | int | index | ) |
Remove a specific template
the | gesture index (as integer) to be removed |
void GVF::replaceGestureTemplate | ( | GVFGesture & | gestureTemplate, |
int | index | ||
) |
Replace a specific gesture template by another
the | gesture template to be used |
the | gesture index (as integer) to be replaced |
void GVF::restart | ( | ) |
Restart GVF
re-sample particles at the origin (i.e. initial prior)
void GVF::saveTemplates | ( | string | filename | ) |
Export template data in a filename
filename | file name as a string |
void GVF::segmentation | ( | bool | segmentationFlag | ) |
Segment gestures within a continuous gesture stream
if segmentation is true, the method will segment a continuous gesture into a sequence of gestures. In other words no need to call the method startGesture(), it is done automatically
boolean | to activate or deactivate segmentation |
void GVF::setActiveGestures | ( | vector< int > | activeGestureIds | ) |
Define a subset of gesture templates on which to perform the recognition and variation tracking
By default every recorded gesture template is considered
set | of gesture template index to consider |
void GVF::setDynamicsVariance | ( | float | dynVariance, |
int | dim = -1 |
||
) |
Change variance of alignment adaptation
if alignment variance is high the method will adapt faster to high variations Change variance of adaptation in dynamics
if dynamics adaptation variance is high the method will adapt faster to fast changes in dynamics. Dynamics is 2-dimensional: the first dimension is the speed The second dimension is the acceleration.
Typically the variance is the average amount the speed or acceleration can change from one sample to another. As an example, if the relative estimated speed can change from 1.1 to 1.2 from one sample to another, the variance should allow a change of 0.1 in speed. So the variance should be set to 0.1*0.1 = 0.01
dynVariance | dynamics variance value |
dim | optional dimension of the dynamics for which the change of variance is applied (default value is 1) |
void GVF::setDynamicsVariance | ( | vector< float > | dynVariance | ) |
Change variance of adaptation in dynamics
See setDynamicsVariance(float dynVariance, int dim) for more details
dynVariance | vector of dynamics variances, each vector index is the variance to be applied to each dynamics dimension (consequently the vector should be 2-dimensional). |
void GVF::setNumberOfParticles | ( | int | numberOfParticles | ) |
Set number of particles used in estimation
default valye is 1000, note that the computational cost directly depends on the number of particles
new | number of particles |
void GVF::setPredictionSteps | ( | int | predictionSteps | ) |
Number of prediciton steps
it is possible to leave GVF to perform few steps of prediction ahead which can be useful to estimate more fastly the variations. Default value is 1 which means no prediction ahead
the | number of prediction steps |
void GVF::setResamplingThreshold | ( | int | resamplingThreshold | ) |
Set resampling threshold
resampling threshold is the minimum number of active particles before resampling all the particles by the estimated posterior distribution. in other words, it re-targets particles around the best current estimates
the | minimum number of particles (default is (number of particles)/2) |
void GVF::setRotationsVariance | ( | float | rotationsVariance, |
int | dim = -1 |
||
) |
Change variance of adaptation in orientation
if rotation adaptation variance is high the method will adapt faster to fast changes in relative orientation. If the gesture is 2-dimensional, there is one variance value since the rotation can be defined by only one angle of rotation. If the gesture is 3-dimensional, there are 3 variance values since the rotation in 3-d is defined by 3 rotation angles. For any other dimension, the rotation is not defined.
The variance is the average amount the orientation can change from one sample to another. As an example, if the relative orientation in rad changes from 0.1 to 0.2 from one observation to another, the variance should allow a change of 0.1 in rotation angle. So the variance should be set to 0.1*0.1 = 0.01
rotationsVariance | rotation variance value |
dim | optional dimension of the rotation for which the change of variance is applied |
void GVF::setRotationsVariance | ( | vector< float > | rotationsVariance | ) |
Change variance of adaptation in orientation
See setRotationsVariance(float rotationsVariance, int dim) for more details
vector | of rotation variances, each vector index is the variance to be applied to each rotation angle (1 or 3) |
vector | of variances (should be 1 if the the template gestures are 2-dim or 3 if they are 3-dim) |
void GVF::setScalingsVariance | ( | float | scaleVariance, |
int | dim = -1 |
||
) |
Change variance of adaptation in scalings
if scalings adaptation variance is high the method will adapt faster to fast changes in relative sizes. There is one scaling variance for each dimension of the input gesture. If the gesture is 2-dimensional, the scalings variances will also be 2-dimensional.
Typically the variance is the average amount the size can change from one sample to another. As an example, if the relative estimated size changes from 1.1 to 1.15 from one sample to another, the variance should allow a change of 0.05 in size. So the variance should be set to 0.05*0.05 = 0.0025
scalings | variance value |
dimension | of the scalings for which the change of variance is applied |
void GVF::setScalingsVariance | ( | vector< float > | scaleVariance | ) |
Change variance of adaptation in dynamics
See setScalingsVariance(float scaleVariance, int dim) for more details
vector | of scalings variances, each vector index is the variance to be applied to each scaling dimension. |
vector | of variances (should be the size of the template gestures dimension) |
void GVF::setSpreadDynamics | ( | float | min, |
float | max, | ||
int | dim = -1 |
||
) |
Set the interval on which the dynamics values should be spread at the beginning (before adaptation)
this interval can be used to concentrate the potential dynamics value on a narrow interval, typically around 1 (the default value), for instance between -0.05 and 0.05, or to allow at the very beginning, high changes in dynamics by spreading, for instance between 0.0 and 2.0
min | lower value of the inital values for dynamics |
max | higher value of the inital values for dynamics |
dim | the dimension on which the change of initial interval should be applied (optional) |
void GVF::setSpreadRotations | ( | float | min, |
float | max, | ||
int | dim = -1 |
||
) |
Set the interval on which the angle of rotation values should be spread at the beginning (before adaptation)
this interval can be used to concentrate the potential angle values on a narrow interval, typically around 0.0 (the default value), for instance between -0.05 and 0.05, or to allow at the very beginning, high changes in orientation by spreading, for instance, between -0.5 and 0.5
min | lower value of the inital values for angle of rotation |
max | higher value of the inital values for angle of rotation |
dim | the dimension on which the change of initial interval should be applied (optional) |
void GVF::setSpreadScalings | ( | float | min, |
float | max, | ||
int | dim = -1 |
||
) |
Set the interval on which the scalings values should be spread at the beginning (before adaptation)
this interval can be used to concentrate the potential scalings value on a narrow interval, typically around 1.0 (the default value), for instance between 0.95 and 1.05, or to allow at the very beginning high changes in dynamics by spreading, for instance, between 0.0 and 2.0
min | lower value of the inital values for scalings |
max | higher value of the inital values for scalings |
dim | the dimension on which the change of initial interval should be applied (optional) |
void GVF::setTolerance | ( | float | tolerance | ) |
Get gesture probabilities
tolerance depends on the range of the data typially tolerance = (data range)/3.0;
tolerance | value |
void GVF::startGesture | ( | ) |
Start a gesture either to be recorded or followed
void GVF::translate | ( | bool | translateFlag | ) |
Translate data according to the first point
substract each gesture feature by the first point of the gesture
boolean | to activate or deactivate translation |
GVFOutcomes & GVF::update | ( | vector< float > & | observation | ) |
Compute the estimated gesture and its potential variations
infers the probability that the current observation belongs to one of the recorded gesture template and track the variations of this gesture according to each template
observation | vector of the observation data at current time |
|
protected |
Similar to constructor GVF() - for openFrameworks Similar to constructor GVF(GVFConfig _config) - for openFrameworks Similar to constructor GVF(GVFConfig _config, GVFParameters _parameters) - for openFrameworks