GestureRecognitionToolkit
Version: 0.2.5
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 } |
Public Types inherited from FeatureExtraction | |
typedef std::map< std::string, FeatureExtraction *(*)() > | StringFeatureExtractionMap |
Public Types inherited from MLBase | |
enum | BaseType { BASE_TYPE_NOT_SET =0, CLASSIFIER, REGRESSIFIER, CLUSTERER, PRE_PROCSSING, POST_PROCESSING, FEATURE_EXTRACTION, CONTEXT } |
Public Member Functions | |
FFT (const UINT fftWindowSize=512, const UINT hopSize=1, const UINT numDimensions=1, const UINT fftWindowFunction=RECTANGULAR_WINDOW, const bool computeMagnitude=true, const 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 VectorFloat &inputVector) |
virtual bool | computeFeatures (const MatrixFloat &inputMatrix) |
virtual bool | clear () |
virtual bool | reset () |
virtual bool | save (std::fstream &file) const |
virtual bool | load (std::fstream &file) |
bool | init (const UINT fftWindowSize, const UINT hopSize=1, const UINT numDimensions=1, const UINT windowFunction=RECTANGULAR_WINDOW, const bool computeMagnitude=true, const bool computePhase=true, const DataType inputType=DATA_TYPE_VECTOR, const DataType outputType=DATA_TYPE_VECTOR) |
bool | update (const Float x) |
bool | update (const VectorFloat &x) |
bool | update (const MatrixFloat &x) |
UINT | getHopSize () const |
UINT | getDataBufferSize () const |
UINT | getFFTWindowSize () const |
UINT | getFFTWindowFunction () const |
UINT | getHopCounter () const |
bool | getComputeMagnitude () const |
bool | getComputePhase () const |
Vector< FastFourierTransform > | getFFTResults () const |
Vector< FastFourierTransform > & | getFFTResultsPtr () |
const Vector< FastFourierTransform > & | getFFTResultsPtr () const |
VectorFloat | getFrequencyBins (const unsigned int sampleRate) const |
bool | setHopSize (const UINT hopSize) |
bool | setFFTWindowSize (const UINT fftWindowSize) |
bool | setFFTWindowFunction (const UINT fftWindowFunction) |
bool | setComputeMagnitude (const bool computeMagnitude) |
bool | setComputePhase (const bool computePhase) |
Public Member Functions inherited from FeatureExtraction | |
FeatureExtraction (const std::string id="") | |
virtual | ~FeatureExtraction () |
bool | copyBaseVariables (const FeatureExtraction *featureExtractionModule) |
bool | getInitialized () const |
bool | getFeatureDataReady () const |
const VectorFloat & | getFeatureVector () const |
const MatrixFloat & | getFeatureMatrix () const |
FeatureExtraction * | create () const |
GRT_DEPRECATED_MSG ("createNewInstance is deprecated, use create() instead.", FeatureExtraction *createNewInstance() const ) | |
GRT_DEPRECATED_MSG ("createInstanceFromString(id) is deprecated, use create(id) instead.", static FeatureExtraction *createInstanceFromString(const std::string &id)) | |
GRT_DEPRECATED_MSG ("getFeatureExtractionType is deprecated, use getId() instead", std::string getFeatureExtractionType() const ) | |
Public Member Functions inherited from MLBase | |
MLBase (const std::string &id="", const BaseType type=BASE_TYPE_NOT_SET) | |
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 (RegressionData trainingData, RegressionData validationData) |
virtual bool | train_ (RegressionData &trainingData, RegressionData &validationData) |
virtual bool | train (TimeSeriesClassificationData trainingData) |
virtual bool | train_ (TimeSeriesClassificationData &trainingData) |
virtual bool | train (ClassificationDataStream trainingData) |
virtual bool | train_ (ClassificationDataStream &trainingData) |
virtual bool | train (UnlabelledData trainingData) |
virtual bool | train_ (UnlabelledData &trainingData) |
virtual bool | train (MatrixFloat data) |
virtual bool | train_ (MatrixFloat &data) |
virtual bool | predict (VectorFloat inputVector) |
virtual bool | predict_ (VectorFloat &inputVector) |
virtual bool | predict (MatrixFloat inputMatrix) |
virtual bool | predict_ (MatrixFloat &inputMatrix) |
virtual bool | map (VectorFloat inputVector) |
virtual bool | map_ (VectorFloat &inputVector) |
virtual bool | print () const |
virtual bool | save (const std::string &filename) const |
virtual bool | load (const std::string &filename) |
GRT_DEPRECATED_MSG ("saveModelToFile(std::string filename) is deprecated, use save(const std::string &filename) instead", virtual bool saveModelToFile(const std::string &filename) const ) | |
GRT_DEPRECATED_MSG ("saveModelToFile(std::fstream &file) is deprecated, use save(std::fstream &file) instead", virtual bool saveModelToFile(std::fstream &file) const ) | |
GRT_DEPRECATED_MSG ("loadModelFromFile(std::string filename) is deprecated, use load(const std::string &filename) instead", virtual bool loadModelFromFile(const std::string &filename)) | |
GRT_DEPRECATED_MSG ("loadModelFromFile(std::fstream &file) is deprecated, use load(std::fstream &file) instead", virtual bool loadModelFromFile(std::fstream &file)) | |
virtual bool | getModel (std::ostream &stream) const |
virtual std::string | getModelAsString () const |
DataType | getInputType () const |
DataType | getOutputType () const |
BaseType | getType () const |
UINT | getNumInputFeatures () const |
UINT | getNumInputDimensions () const |
UINT | getNumOutputDimensions () const |
UINT | getMinNumEpochs () const |
UINT | getMaxNumEpochs () const |
UINT | getBatchSize () const |
UINT | getNumRestarts () const |
UINT | getValidationSetSize () const |
UINT | getNumTrainingIterationsToConverge () const |
Float | getMinChange () const |
Float | getLearningRate () const |
Float | getRMSTrainingError () const |
GRT_DEPRECATED_MSG ("getRootMeanSquaredTrainingError() is deprecated, use getRMSTrainingError() instead", Float getRootMeanSquaredTrainingError() const ) | |
Float | getTotalSquaredTrainingError () const |
Float | getRMSValidationError () const |
Float | getValidationSetAccuracy () const |
VectorFloat | getValidationSetPrecision () const |
VectorFloat | getValidationSetRecall () const |
bool | getUseValidationSet () const |
bool | getRandomiseTrainingOrder () const |
bool | getTrained () const |
GRT_DEPRECATED_MSG ("getModelTrained() is deprecated, use getTrained() instead", bool getModelTrained() const ) | |
bool | getConverged () const |
bool | getScalingEnabled () const |
bool | getIsBaseTypeClassifier () const |
bool | getIsBaseTypeRegressifier () const |
bool | getIsBaseTypeClusterer () const |
bool | getTrainingLoggingEnabled () const |
bool | getTestingLoggingEnabled () const |
bool | enableScaling (const bool useScaling) |
bool | setMaxNumEpochs (const UINT maxNumEpochs) |
bool | setBatchSize (const UINT batchSize) |
bool | setMinNumEpochs (const UINT minNumEpochs) |
bool | setNumRestarts (const UINT numRestarts) |
bool | setMinChange (const Float minChange) |
bool | setLearningRate (const Float learningRate) |
bool | setUseValidationSet (const bool useValidationSet) |
bool | setValidationSetSize (const UINT validationSetSize) |
bool | setRandomiseTrainingOrder (const bool randomiseTrainingOrder) |
bool | setTrainingLoggingEnabled (const bool loggingEnabled) |
bool | setTestingLoggingEnabled (const bool loggingEnabled) |
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 |
Public Member Functions inherited from GRTBase | |
GRTBase (const std::string &id="") | |
virtual | ~GRTBase (void) |
bool | copyGRTBaseVariables (const GRTBase *GRTBase) |
GRT_DEPRECATED_MSG ("getClassType is deprecated, use getId() instead!", std::string getClassType() const ) | |
std::string | getId () const |
std::string | getLastWarningMessage () const |
std::string | getLastErrorMessage () const |
std::string | getLastInfoMessage () const |
bool | setInfoLoggingEnabled (const bool loggingEnabled) |
bool | setWarningLoggingEnabled (const bool loggingEnabled) |
bool | setErrorLoggingEnabled (const bool loggingEnabled) |
bool | setDebugLoggingEnabled (const bool loggingEnabled) |
GRTBase * | getGRTBasePointer () |
const GRTBase * | getGRTBasePointer () const |
Float | scale (const Float &x, const Float &minSource, const Float &maxSource, const Float &minTarget, const Float &maxTarget, const bool constrain=false) |
Float | SQR (const Float &x) const |
Public Member Functions inherited from Observer< TrainingResult > | |
virtual void | notify (const TrainingResult &data) |
Public Member Functions inherited from Observer< TestInstanceResult > | |
virtual void | notify (const TestInstanceResult &data) |
Static Public Member Functions | |
static std::string | getId () |
Static Public Member Functions inherited from FeatureExtraction | |
static FeatureExtraction * | create (const std::string &id) |
Static Public Member Functions inherited from GRTBase | |
static std::string | getGRTVersion (bool returnRevision=true) |
static std::string | getGRTRevison () |
Protected Member Functions | |
bool | isPowerOfTwo (UINT x) |
A helper function to compute if the input is a power of two. | |
bool | validateFFTWindowFunction (UINT fftWindowFunction) |
Protected Member Functions inherited from FeatureExtraction | |
bool | init () |
bool | saveFeatureExtractionSettingsToFile (std::fstream &file) const |
bool | loadFeatureExtractionSettingsFromFile (std::fstream &file) |
Protected Member Functions inherited from MLBase | |
bool | saveBaseSettingsToFile (std::fstream &file) const |
bool | loadBaseSettingsFromFile (std::fstream &file) |
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. | |
VectorFloat | tempBuffer |
A temporary buffer used to store the input data for the FFT. | |
CircularBuffer< VectorFloat > | 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. | |
Protected Attributes inherited from FeatureExtraction | |
std::string | featureExtractionType |
bool | initialized |
bool | featureDataReady |
VectorFloat | featureVector |
MatrixFloat | featureMatrix |
Protected Attributes inherited from MLBase | |
bool | trained |
bool | useScaling |
bool | converged |
DataType | inputType |
DataType | outputType |
BaseType | baseType |
UINT | numInputDimensions |
UINT | numOutputDimensions |
UINT | numTrainingIterationsToConverge |
UINT | minNumEpochs |
UINT | maxNumEpochs |
UINT | batchSize |
UINT | validationSetSize |
UINT | numRestarts |
Float | learningRate |
Float | minChange |
Float | rmsTrainingError |
Float | rmsValidationError |
Float | totalSquaredTrainingError |
Float | validationSetAccuracy |
bool | useValidationSet |
bool | randomiseTrainingOrder |
VectorFloat | validationSetPrecision |
VectorFloat | validationSetRecall |
Random | random |
Vector< TrainingResult > | trainingResults |
TrainingResultsObserverManager | trainingResultsObserverManager |
TestResultsObserverManager | testResultsObserverManager |
TrainingLog | trainingLog |
TestingLog | testingLog |
Protected Attributes inherited from GRTBase | |
std::string | classId |
Stores the name of the class (e.g., MinDist) | |
DebugLog | debugLog |
ErrorLog | errorLog |
InfoLog | infoLog |
WarningLog | warningLog |
Additional Inherited Members | |
Static Protected Member Functions inherited from FeatureExtraction | |
static StringFeatureExtractionMap * | getMap () |
FFT::FFT | ( | const UINT | fftWindowSize = 512 , |
const UINT | hopSize = 1 , |
||
const UINT | numDimensions = 1 , |
||
const UINT | fftWindowFunction = RECTANGULAR_WINDOW , |
||
const bool | computeMagnitude = true , |
||
const 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.
fftWindowSize | sets the size of the fft, this should be a power of two. Default fftWindowSize=512 |
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 |
numDimensions | the dimensionality of the input data to the FFT. Default numDimensions = 1 |
fftWindowFunction | sets the window function of the FFT. This should be one of the FFTWindowFunctionOptions enumeration values. Default windowFunction=RECTANGULAR_WINDOW |
computeMagnitude | sets if the magnitude (and power) of the spectrum should be computed on the results of the FFT. Default computeMagnitude=true |
computePhase | sets if the phase of the spectrum should be computed on the results of the FFT. Default computePhase=true |
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 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.
inputVector | the inputVector that should be processed. Must have the same dimensionality as the FeatureExtraction module |
Reimplemented from 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.
inputMatrix | the inputMatrix that should be processed. Must have the same dimensionality as the FeatureExtraction module |
Reimplemented from 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 | a pointer to another instance of an FFT, the values of that instance will be cloned to this instance |
Reimplemented from FeatureExtraction.
|
inline |
|
inline |
UINT FFT::getDataBufferSize | ( | ) | const |
|
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.
|
inline |
Returns a const pointer to the FFT results computed from the last FFT of the input signal.
UINT FFT::getFFTWindowFunction | ( | ) | const |
UINT FFT::getFFTWindowSize | ( | ) | const |
UINT FFT::getHopCounter | ( | ) | const |
UINT FFT::getHopSize | ( | ) | const |
|
static |
bool FFT::init | ( | const UINT | fftWindowSize, |
const UINT | hopSize = 1 , |
||
const UINT | numDimensions = 1 , |
||
const UINT | windowFunction = RECTANGULAR_WINDOW , |
||
const bool | computeMagnitude = true , |
||
const bool | computePhase = true , |
||
const DataType | inputType = DATA_TYPE_VECTOR , |
||
const DataType | outputType = DATA_TYPE_VECTOR |
||
) |
Initializes the FFT. Should be called before calling the computeFFT(...) or computeFeatures(...) methods. This function is automatically called by the constructor.
fftWindowSize | sets the size of the fft, this must be a power of two |
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 |
numDimensions | the dimensionality of the input data to the FFT |
windowFunction | sets the window function of the FFT. This should be one of the WindowFunctionOptions enumeration values |
computeMagnitude | sets if the magnitude (and power) of the spectrum should be computed on the results of the FFT |
computePhase | sets if the phase of the spectrum should be computed on the results of the FFT |
inputType | the input type expected, defaults to DATA_TYPE_VECTOR |
outputType | the output type that can be accessed by users of the module, defaults to DATA_TYPE_VECTOR |
|
virtual |
This loads the feature extraction settings from a file. This overrides the load function in the FeatureExtraction base class.
file | a reference to the file to load the settings from |
Reimplemented from MLBase.
|
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 MLBase.
|
virtual |
This saves the feature extraction settings to a file. This overrides the save function in the FeatureExtraction base class.
file | a reference to the file to save the settings to |
Reimplemented from MLBase.
bool FFT::setComputeMagnitude | ( | const bool | computeMagnitude | ) |
bool FFT::setComputePhase | ( | const bool | computePhase | ) |
bool FFT::setFFTWindowFunction | ( | const UINT | fftWindowFunction | ) |
Sets the fftWindowFunction parameter, this should be one of the FFTWindowFunctionOptions enumeration values.
fftWindowFunction | the new fftWindowFunction parameter, must be one of the FFTWindowFunctionOptions enumeration values |
bool FFT::setFFTWindowSize | ( | const 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.
fftWindowSize | the new fftWindowSize parameter, this must be a power of two. |
bool FFT::setHopSize | ( | const 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.
hopSize | the new hopSize parameter, must be greater than zero |
bool FFT::update | ( | const Float | 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.
x | the new sample, this will be added to a buffer and the FFT will be computed for the data in the buffer |
bool FFT::update | ( | const VectorFloat & | 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.
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 |
bool FFT::update | ( | const MatrixFloat & | 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 number of columns in the input matrix must match the number of dimensions for the FFT.
x | a [M N] matrix, this will be added to a buffer and the FFT will be computed for the data in the buffer |