![]() |
GestureRecognitionToolkit
Version: 1.0 Revision: 04-03-15
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
|
Public Types | |
enum | FFTWindowFunctionOptions { RECTANGULAR_WINDOW =0, BARTLETT_WINDOW, HAMMING_WINDOW, HANNING_WINDOW } |
![]() | |
typedef std::map< string, FeatureExtraction *(*)() > | StringFeatureExtractionMap |
![]() | |
enum | BaseTypes { BASE_TYPE_NOT_SET =0, CLASSIFIER, REGRESSIFIER, CLUSTERER } |
Public Member Functions | |
FFT (UINT fftWindowSize=512, UINT hopSize=1, UINT numDimensions=1, UINT fftWindowFunction=RECTANGULAR_WINDOW, bool computeMagnitude=true, bool computePhase=true) | |
FFT (const FFT &rhs) | |
virtual | ~FFT (void) |
FFT & | operator= (const FFT &rhs) |
virtual bool | deepCopyFrom (const FeatureExtraction *featureExtraction) |
virtual bool | computeFeatures (const VectorDouble &inputVector) |
virtual bool | clear () |
virtual bool | reset () |
virtual bool | saveModelToFile (fstream &file) const |
virtual bool | loadModelFromFile (fstream &file) |
bool | init (UINT fftWindowSize, UINT hopSize, UINT numDimensions, UINT windowFunction, bool computeMagnitude, bool computePhase) |
bool | update (const double x) |
bool | update (const VectorDouble &x) |
UINT | getHopSize () |
UINT | getDataBufferSize () |
UINT | getFFTWindowSize () |
UINT | getFFTWindowFunction () |
UINT | getHopCounter () |
bool | getComputeMagnitude () |
bool | getComputePhase () |
vector< FastFourierTransform > | getFFTResults () |
vector< FastFourierTransform > & | getFFTResultsPtr () |
VectorDouble | getFrequencyBins (const unsigned int sampleRate) |
bool | setHopSize (UINT hopSize) |
bool | setFFTWindowSize (UINT fftWindowSize) |
bool | setFFTWindowFunction (UINT fftWindowFunction) |
bool | setComputeMagnitude (bool computeMagnitude) |
bool | setComputePhase (bool computePhase) |
![]() | |
FeatureExtraction () | |
virtual | ~FeatureExtraction () |
bool | copyBaseVariables (const FeatureExtraction *featureExtractionModule) |
string | getFeatureExtractionType () const |
UINT | getNumInputDimensions () const |
UINT | getNumOutputDimensions () const |
bool | getInitialized () const |
bool | getFeatureDataReady () const |
VectorDouble | getFeatureVector () const |
FeatureExtraction * | createNewInstance () const |
![]() | |
MLBase (void) | |
virtual | ~MLBase (void) |
bool | copyMLBaseVariables (const MLBase *mlBase) |
virtual bool | train (ClassificationData trainingData) |
virtual bool | train_ (ClassificationData &trainingData) |
virtual bool | train (RegressionData trainingData) |
virtual bool | train_ (RegressionData &trainingData) |
virtual bool | train (TimeSeriesClassificationData trainingData) |
virtual bool | train_ (TimeSeriesClassificationData &trainingData) |
virtual bool | train (TimeSeriesClassificationDataStream trainingData) |
virtual bool | train_ (TimeSeriesClassificationDataStream &trainingData) |
virtual bool | train (UnlabelledData trainingData) |
virtual bool | train_ (UnlabelledData &trainingData) |
virtual bool | train (MatrixDouble data) |
virtual bool | train_ (MatrixDouble &data) |
virtual bool | predict (VectorDouble inputVector) |
virtual bool | predict_ (VectorDouble &inputVector) |
virtual bool | predict (MatrixDouble inputMatrix) |
virtual bool | predict_ (MatrixDouble &inputMatrix) |
virtual bool | map (VectorDouble inputVector) |
virtual bool | map_ (VectorDouble &inputVector) |
virtual bool | print () const |
virtual bool | save (const string filename) const |
virtual bool | load (const string filename) |
virtual bool | saveModelToFile (string filename) const |
virtual bool | loadModelFromFile (string filename) |
virtual bool | getModel (ostream &stream) const |
double | scale (const double &x, const double &minSource, const double &maxSource, const double &minTarget, const double &maxTarget, const bool constrain=false) |
virtual string | getModelAsString () const |
UINT | getBaseType () const |
UINT | getNumInputFeatures () const |
UINT | getNumInputDimensions () const |
UINT | getNumOutputDimensions () const |
UINT | getMinNumEpochs () const |
UINT | getMaxNumEpochs () const |
UINT | getValidationSetSize () const |
UINT | getNumTrainingIterationsToConverge () const |
double | getMinChange () const |
double | getLearningRate () const |
double | getRootMeanSquaredTrainingError () const |
double | getTotalSquaredTrainingError () const |
bool | getUseValidationSet () const |
bool | getRandomiseTrainingOrder () const |
bool | getTrained () const |
bool | getModelTrained () const |
bool | getScalingEnabled () const |
bool | getIsBaseTypeClassifier () const |
bool | getIsBaseTypeRegressifier () const |
bool | getIsBaseTypeClusterer () const |
bool | enableScaling (bool useScaling) |
bool | setMaxNumEpochs (const UINT maxNumEpochs) |
bool | setMinNumEpochs (const UINT minNumEpochs) |
bool | setMinChange (const double minChange) |
bool | setLearningRate (double learningRate) |
bool | setUseValidationSet (const bool useValidationSet) |
bool | setValidationSetSize (const UINT validationSetSize) |
bool | setRandomiseTrainingOrder (const bool randomiseTrainingOrder) |
bool | registerTrainingResultsObserver (Observer< TrainingResult > &observer) |
bool | registerTestResultsObserver (Observer< TestInstanceResult > &observer) |
bool | removeTrainingResultsObserver (const Observer< TrainingResult > &observer) |
bool | removeTestResultsObserver (const Observer< TestInstanceResult > &observer) |
bool | removeAllTrainingObservers () |
bool | removeAllTestObservers () |
bool | notifyTrainingResultsObservers (const TrainingResult &data) |
bool | notifyTestResultsObservers (const TestInstanceResult &data) |
MLBase * | getMLBasePointer () |
const MLBase * | getMLBasePointer () const |
vector< TrainingResult > | getTrainingResults () const |
![]() | |
GRTBase (void) | |
virtual | ~GRTBase (void) |
bool | copyGRTBaseVariables (const GRTBase *GRTBase) |
string | getClassType () const |
string | getLastWarningMessage () const |
string | getLastErrorMessage () const |
string | getLastInfoMessage () const |
GRTBase * | getGRTBasePointer () |
const GRTBase * | getGRTBasePointer () const |
![]() | |
virtual void | notify (const TrainingResult &data) |
![]() | |
virtual void | notify (const TestInstanceResult &data) |
Protected Member Functions | |
bool | isPowerOfTwo (UINT x) |
A helper function to compute if the input is a power of two. | |
bool | validateFFTWindowFunction (UINT fftWindowFunction) |
![]() | |
bool | init () |
bool | saveFeatureExtractionSettingsToFile (fstream &file) const |
bool | loadFeatureExtractionSettingsFromFile (fstream &file) |
![]() | |
bool | saveBaseSettingsToFile (fstream &file) const |
bool | loadBaseSettingsFromFile (fstream &file) |
![]() | |
double | SQR (const double &x) const |
Protected Attributes | |
UINT | hopSize |
The current hopSize, this sets how often the fft should be computed. | |
UINT | dataBufferSize |
Stores how much previous input data is stored in the dataBuffer. | |
UINT | fftWindowSize |
Stores the size of the fft (and also the dataBuffer) | |
UINT | fftWindowFunction |
The current windowFunction used for the FFT. | |
UINT | hopCounter |
Keeps track of how many input samples the FFT has seen. | |
bool | computeMagnitude |
Tracks if the magnitude (and power) of the FFT need to be computed. | |
bool | computePhase |
Tracks if the phase of the FFT needs to be computed. | |
GRT::VectorDouble | tempBuffer |
A temporary buffer used to store the input data for the FFT. | |
CircularBuffer< VectorDouble > | dataBuffer |
A circular buffer used to store the previous M inputs. | |
vector< FastFourierTransform > | fft |
A buffer used to store the FFT results. | |
std::map< unsigned int, unsigned int > | windowSizeMap |
A map to relate the FFTWindowSize enumerations to actual values. | |
![]() | |
string | featureExtractionType |
bool | initialized |
bool | featureDataReady |
VectorDouble | featureVector |
![]() | |
bool | trained |
bool | useScaling |
UINT | baseType |
UINT | numInputDimensions |
UINT | numOutputDimensions |
UINT | numTrainingIterationsToConverge |
UINT | minNumEpochs |
UINT | maxNumEpochs |
UINT | validationSetSize |
double | learningRate |
double | minChange |
double | rootMeanSquaredTrainingError |
double | totalSquaredTrainingError |
bool | useValidationSet |
bool | randomiseTrainingOrder |
Random | random |
vector< TrainingResult > | trainingResults |
TrainingResultsObserverManager | trainingResultsObserverManager |
TestResultsObserverManager | testResultsObserverManager |
![]() | |
string | classType |
DebugLog | debugLog |
ErrorLog | errorLog |
InfoLog | infoLog |
TrainingLog | trainingLog |
TestingLog | testingLog |
WarningLog | warningLog |
Static Protected Attributes | |
static RegisterFeatureExtractionModule< FFT > | registerModule |
Additional Inherited Members | |
![]() | |
static FeatureExtraction * | createInstanceFromString (string const &featureExtractionType) |
![]() | |
static string | getGRTVersion (bool returnRevision=true) |
static string | getGRTRevison () |
![]() | |
static StringFeatureExtractionMap * | getMap () |
GRT::FFT::FFT | ( | UINT | fftWindowSize = 512 , |
UINT | hopSize = 1 , |
||
UINT | numDimensions = 1 , |
||
UINT | fftWindowFunction = RECTANGULAR_WINDOW , |
||
bool | computeMagnitude = true , |
||
bool | computePhase = true |
||
) |
Constructor, sets the fftWindowSize, hopSize, fftWindowFunction, if the magnitude and phase should be computed during the FFT and the number of dimensions in the input signal.
UINT | fftWindowSize: sets the size of the fft, this should be a power of two. Default fftWindowSize=512 |
UINT | hopSize: sets how often the fft should be computed. If the hopSize parameter is set to 1 then the FFT will be computed everytime the classes computeFeatures(...) or computeFFT(...) functions are called. You may not want to compute the FFT of the input signal for every sample however, if this is the case then set the hopSize parameter to N, in which case the FFT will only be computed every N samples on the previous M values, where M is equal to the fftWindowSize. Default hopSize=1 |
UINT | numDimensions: the dimensionality of the input data to the FFT. Default numDimensions = 1 |
UINT | fftWindowFunction: sets the window function of the FFT. This should be one of the FFTWindowFunctionOptions enumeration values. Default windowFunction=RECTANGULAR_WINDOW |
bool | computeMagnitude: sets if the magnitude (and power) of the spectrum should be computed on the results of the FFT. Default computeMagnitude=true |
bool | computePhase: sets if the phase of the spectrum should be computed on the results of the FFT. Default computePhase=true |
GRT::FFT::FFT | ( | const FFT & | rhs | ) |
|
virtual |
Sets the FeatureExtraction clear function, overwriting the base FeatureExtraction function. This function is called by the GestureRecognitionPipeline when the pipelines main clear() function is called. This function completely clears the FFT setup, you will need to initialize the instance again before you can use it.
Reimplemented from GRT::FeatureExtraction.
|
virtual |
Sets the FeatureExtraction computeFeatures function, overwriting the base FeatureExtraction function. This function is called by the GestureRecognitionPipeline when any new input data needs to be processed (during the prediction phase for example). This function calls the FFT's computeFFT(...) function.
const | VectorDouble &inputVector: the inputVector that should be processed. Must have the same dimensionality as the FeatureExtraction module |
Reimplemented from GRT::FeatureExtraction.
|
virtual |
Sets the FeatureExtraction deepCopyFrom function, overwriting the base FeatureExtraction function. This function is used to deep copy the values from the input pointer to this instance of the FeatureExtraction module. This function is called by the GestureRecognitionPipeline when the user adds a new FeatureExtraction module to the pipeline.
FeatureExtraction | *featureExtraction: a pointer to another instance of an FFT, the values of that instance will be cloned to this instance |
Reimplemented from GRT::FeatureExtraction.
|
inline |
|
inline |
UINT GRT::FFT::getDataBufferSize | ( | ) |
|
inline |
Returns the FFT results computed from the last FFT of the input signal.
|
inline |
Returns a pointer to the FFT results computed from the last FFT of the input signal.
UINT GRT::FFT::getFFTWindowFunction | ( | ) |
UINT GRT::FFT::getFFTWindowSize | ( | ) |
UINT GRT::FFT::getHopCounter | ( | ) |
UINT GRT::FFT::getHopSize | ( | ) |
bool GRT::FFT::init | ( | UINT | fftWindowSize, |
UINT | hopSize, | ||
UINT | numDimensions, | ||
UINT | windowFunction, | ||
bool | computeMagnitude, | ||
bool | computePhase | ||
) |
Initializes the FFT. Should be called before calling the computeFFT(...) or computeFeatures(...) methods. This function is automatically called by the constructor.
UINT | fftWindowSize: sets the size of the fft, this must be a power of two |
UINT | hopSize: sets how often the fft should be computed. If the hopSize parameter is set to 1 then the FFT will be computed everytime the classes computeFeatures(...) or computeFFT(...) functions are called. You may not want to compute the FFT of the input signal for every sample however, if this is the case then set the hopSize parameter to N, in which case the FFT will only be computed every N samples on the previous M values, where M is equal to the fftWindowSize |
UINT | numDimensions: the dimensionality of the input data to the FFT |
UINT | windowFunction: sets the window function of the FFT. This should be one of the WindowFunctionOptions enumeration values |
bool | computeMagnitude: sets if the magnitude (and power) of the spectrum should be computed on the results of the FFT |
bool | computePhase: sets if the phase of the spectrum should be computed on the results of the FFT |
|
virtual |
This loads the feature extraction settings from a file. This overrides the loadSettingsFromFile function in the FeatureExtraction base class.
fstream | &file: a reference to the file to load the settings from |
Reimplemented from GRT::FeatureExtraction.
|
virtual |
Sets the FeatureExtraction reset function, overwriting the base FeatureExtraction function. This function is called by the GestureRecognitionPipeline when the pipelines main reset() function is called. This function resets the FFT by re-initiliazing the instance.
Reimplemented from GRT::FeatureExtraction.
|
virtual |
This saves the feature extraction settings to a file. This overrides the saveSettingsToFile function in the FeatureExtraction base class.
fstream | &file: a reference to the file to save the settings to |
Reimplemented from GRT::FeatureExtraction.
bool GRT::FFT::setComputeMagnitude | ( | bool | computeMagnitude | ) |
bool GRT::FFT::setComputePhase | ( | bool | computePhase | ) |
bool GRT::FFT::setFFTWindowFunction | ( | UINT | fftWindowFunction | ) |
Sets the fftWindowFunction parameter, this should be one of the FFTWindowFunctionOptions enumeration values.
UINT | fftWindowFunction: the new fftWindowFunction parameter, must be one of the FFTWindowFunctionOptions enumeration values |
bool GRT::FFT::setFFTWindowSize | ( | UINT | fftWindowSize | ) |
Sets the fftWindowSize parameter, this sets the size of the fft, this must be a power of two. Setting this value will also re-initialize the FFT.
UINT | fftWindowSize: the new fftWindowSize parameter, this must be a power of two. |
bool GRT::FFT::setHopSize | ( | UINT | hopSize | ) |
Sets the hopSize parameter, this sets how often the fft should be computed. If the hopSize parameter is set to 1 then the FFT will be computed everytime the classes' computeFeatures(...) or computeFFT(...) functions are called. You may not want to compute the FFT of the input signal for every sample however, if this is the case then set the hopSize parameter to N, in which case the FFT will only be computed every N samples on the previous M values, where M is equal to the fftWindowSize. The hopSize must be greater than zero. Setting the hopSize will also reset the hop counter.
UINT | hopSize: the new hopSize parameter, must be greater than zero |
bool GRT::FFT::update | ( | const double | x | ) |
Computes the FFT of the previous M input samples, where M is the size of the fft window set by the constructor. The FFT of the input will only be computed if the current hop counter value matches the hopSize. This function should only be used if the dimensionality of the FFT has been set to 1.
const | double x: the new sample, this will be added to a buffer and the FFT will be computed for the data in the buffer |
bool GRT::FFT::update | ( | const VectorDouble & | x | ) |
Computes the FFT of the previous M input samples, where M is the size of the fft window set by the constructor. The FFT of the input will only be computed if the current hop counter value matches the hopSize. The dimensionality of the input vector must match the number of dimensions for the FFT.
const | VectorDouble &x: the new N-dimensional sample, this will be added to a buffer and the FFT will be computed for the data in the buffer |