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.
GRT::HighPassFilter Class Reference
Inheritance diagram for GRT::HighPassFilter:
GRT::PreProcessing GRT::MLBase GRT::GRTBase GRT::Observer< TrainingResult > GRT::Observer< TestInstanceResult >

Public Member Functions

 HighPassFilter (double filterFactor=0.1, double gain=1, UINT numDimensions=1, double cutoffFrequency=-1, double delta=-1)
 
 HighPassFilter (const HighPassFilter &rhs)
 
virtual ~HighPassFilter ()
 
HighPassFilteroperator= (const HighPassFilter &rhs)
 
virtual bool deepCopyFrom (const PreProcessing *preProcessing)
 
virtual bool process (const VectorDouble &inputVector)
 
virtual bool reset ()
 
virtual bool saveModelToFile (string filename) const
 
virtual bool saveModelToFile (fstream &file) const
 
virtual bool loadModelFromFile (string filename)
 
virtual bool loadModelFromFile (fstream &file)
 
bool init (double filterFactor, double gain, UINT numDimensions)
 
double filter (const double x)
 
VectorDouble filter (const VectorDouble &x)
 
bool setGain (double gain)
 
bool setFilterFactor (double filterFactor)
 
bool setCutoffFrequency (double cutoffFrequency, double delta)
 
double getFilterFactor ()
 
double getGain ()
 
VectorDouble getFilteredValues ()
 
- Public Member Functions inherited from GRT::PreProcessing
 PreProcessing (void)
 
virtual ~PreProcessing (void)
 
bool copyBaseVariables (const PreProcessing *preProcessingModule)
 
virtual bool clear ()
 
string getPreProcessingType () const
 
UINT getNumInputDimensions () const
 
UINT getNumOutputDimensions () const
 
bool getInitialized () const
 
VectorDouble getProcessedData () const
 
PreProcessingcreateNewInstance () const
 
- Public Member Functions inherited from GRT::MLBase
 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 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)
 
MLBasegetMLBasePointer ()
 
const MLBasegetMLBasePointer () const
 
vector< TrainingResultgetTrainingResults () const
 
- Public Member Functions inherited from GRT::GRTBase
 GRTBase (void)
 
virtual ~GRTBase (void)
 
bool copyGRTBaseVariables (const GRTBase *GRTBase)
 
string getClassType () const
 
string getLastWarningMessage () const
 
string getLastErrorMessage () const
 
string getLastInfoMessage () const
 
GRTBasegetGRTBasePointer ()
 
const GRTBasegetGRTBasePointer () const
 
- Public Member Functions inherited from GRT::Observer< TrainingResult >
virtual void notify (const TrainingResult &data)
 
- Public Member Functions inherited from GRT::Observer< TestInstanceResult >
virtual void notify (const TestInstanceResult &data)
 

Protected Attributes

double filterFactor
 The filter factor (alpha) of the filter.
 
double gain
 The gain factor of the filter.
 
VectorDouble xx
 The previous input value(s)
 
VectorDouble yy
 The previous output value(s)
 
- Protected Attributes inherited from GRT::PreProcessing
string preProcessingType
 
bool initialized
 
VectorDouble processedData
 
- Protected Attributes inherited from GRT::MLBase
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< TrainingResulttrainingResults
 
TrainingResultsObserverManager trainingResultsObserverManager
 
TestResultsObserverManager testResultsObserverManager
 
- Protected Attributes inherited from GRT::GRTBase
string classType
 
DebugLog debugLog
 
ErrorLog errorLog
 
InfoLog infoLog
 
TrainingLog trainingLog
 
TestingLog testingLog
 
WarningLog warningLog
 

Static Protected Attributes

static RegisterPreProcessingModule< HighPassFilterregisterModule
 

Additional Inherited Members

- Public Types inherited from GRT::PreProcessing
typedef std::map< string, PreProcessing *(*)() > StringPreProcessingMap
 
- Public Types inherited from GRT::MLBase
enum  BaseTypes { BASE_TYPE_NOT_SET =0, CLASSIFIER, REGRESSIFIER, CLUSTERER }
 
- Static Public Member Functions inherited from GRT::PreProcessing
static PreProcessingcreateInstanceFromString (string const &preProcessingType)
 
- Static Public Member Functions inherited from GRT::GRTBase
static string getGRTVersion (bool returnRevision=true)
 
static string getGRTRevison ()
 
- Protected Member Functions inherited from GRT::PreProcessing
bool init ()
 
bool savePreProcessingSettingsToFile (fstream &file) const
 
bool loadPreProcessingSettingsFromFile (fstream &file)
 
- Protected Member Functions inherited from GRT::MLBase
bool saveBaseSettingsToFile (fstream &file) const
 
bool loadBaseSettingsFromFile (fstream &file)
 
- Protected Member Functions inherited from GRT::GRTBase
double SQR (const double &x) const
 
- Static Protected Member Functions inherited from GRT::PreProcessing
static StringPreProcessingMapgetMap ()
 

Detailed Description

Definition at line 38 of file HighPassFilter.h.

Constructor & Destructor Documentation

GRT::HighPassFilter::HighPassFilter ( double  filterFactor = 0.1,
double  gain = 1,
UINT  numDimensions = 1,
double  cutoffFrequency = -1,
double  delta = -1 
)

Constructor, sets the filter factor, gain and dimensionality of the high pass filter. If the cutoffFrequency and delta values are set then the filter will be initialized with these values rather than the filterFactor. If the cutoffFrequency and delta values are kept at their default values of -1 then the values will be ignored and the filter factor will be used instead. Otherwise the fiterFactor will control the high pass filter, with a smaller filterFactor (i.e. 0.1) resulting in a more aggresive attenuation of low frequency signals in the input signal. The filterFactor should be in the range [0.0 1.0].

Parameters
doublefilterFactor: controls the high pass filter, a smaller value will result in a more aggresive attenuation of low frequency signals in the input signal. Default value filterFactor = 0.1
doublegain: multiples the filtered values by a constant ampltidue. Default value = 1.0
UINTnumDimensions: the dimensionality of the input data to filter. Default numDimensions = 1
doublecutoffFrequency: sets the cutoffFrequency of the filter (in Hz). If the cutoffFrequency and delta values are set then the filter will be initialized with these values rather than the filterFactor. Default value cutoffFrequency = -1.0
doubledelta: the sampling rate of your sensor, delta should be set as 1.0/SR, where SR is the sampling rate of your sensor. Default value delta = -1.0

Definition at line 28 of file HighPassFilter.cpp.

GRT::HighPassFilter::HighPassFilter ( const HighPassFilter rhs)

Copy Constructor, copies the HighPassFilter from the rhs instance to this instance

Parameters
constHighPassFilter &rhs: another instance of the HighPassFilter class from which the data will be copied to this instance

Definition at line 42 of file HighPassFilter.cpp.

GRT::HighPassFilter::~HighPassFilter ( )
virtual

Default Destructor

Definition at line 57 of file HighPassFilter.cpp.

Member Function Documentation

bool GRT::HighPassFilter::deepCopyFrom ( const PreProcessing preProcessing)
virtual

Sets the PreProcessing deepCopyFrom function, overwriting the base PreProcessing function. This function is used to deep copy the values from the input pointer to this instance of the PreProcessing module. This function is called by the GestureRecognitionPipeline when the user adds a new PreProcessing module to the pipeline.

Parameters
constPreProcessing *preProcessing: a pointer to another instance of a HighPassFilter, the values of that instance will be cloned to this instance
Returns
true if the deep copy was successful, false otherwise

Reimplemented from GRT::PreProcessing.

Definition at line 72 of file HighPassFilter.cpp.

double GRT::HighPassFilter::filter ( const double  x)

Filters the input, this should only be called if the dimensionality of the filter was set to 1.

Parameters
doublex: the value to filter, this should only be called if the dimensionality of the filter was set to 1
Returns
the filtered value. Zero will be returned if the value was not filtered

Definition at line 259 of file HighPassFilter.cpp.

VectorDouble GRT::HighPassFilter::filter ( const VectorDouble &  x)

Filters the input, the dimensionality of the input vector should match that of the filter.

Parameters
constVectorDouble &x: the values to filter, the dimensionality of the input vector should match that of the filter
Returns
the filtered values. An empty vector will be returned if the values were not filtered

Definition at line 274 of file HighPassFilter.cpp.

VectorDouble GRT::HighPassFilter::getFilteredValues ( )
inline

Returns the last value(s) that were filtered.

Returns
the filtered values. An empty vector will be returned if the values were not filtered

Definition at line 214 of file HighPassFilter.h.

double GRT::HighPassFilter::getFilterFactor ( )
inline

Gets the current filter factor if the filter has been initialized.

Returns
the current filter factor if the filter has been initialized, zero otherwise

Definition at line 200 of file HighPassFilter.h.

double GRT::HighPassFilter::getGain ( )
inline

Gets the current gain value if the filter has been initialized.

Returns
the currentgain value if the filter has been initialized, zero otherwise

Definition at line 207 of file HighPassFilter.h.

bool GRT::HighPassFilter::init ( double  filterFactor,
double  gain,
UINT  numDimensions 
)

Initializes the filter, setting the filter size and dimensionality of the data it will filter. Sets all the filter values to zero.

Parameters
doublefilterFactor: controls the high pass filter, a smaller value will result in a more aggresive attenuation of low frequency signals in the input signal
doublegain: multiples the filtered values by a constant ampltidue
UINTnumDimensions: the dimensionality of the input data to filter
Returns
true if the filter was initiliazed, false otherwise

Definition at line 225 of file HighPassFilter.cpp.

bool GRT::HighPassFilter::loadModelFromFile ( string  filename)
virtual

This loads the HighPassFilter settings from a file. This overrides the loadModelFromFile function in the PreProcessing base class.

Parameters
stringfilename: the name of the file to load the settings from
Returns
returns true if the settings were loaded successfully, false otherwise

Reimplemented from GRT::PreProcessing.

Definition at line 156 of file HighPassFilter.cpp.

bool GRT::HighPassFilter::loadModelFromFile ( fstream &  file)
virtual

This loads the HighPassFilter settings from a file. This overrides the loadModelFromFile function in the PreProcessing base class.

Parameters
fstream&file: a reference to the file to load the settings from
Returns
returns true if the model was loaded successfully, false otherwise

Reimplemented from GRT::PreProcessing.

Definition at line 172 of file HighPassFilter.cpp.

HighPassFilter & GRT::HighPassFilter::operator= ( const HighPassFilter rhs)

Sets the equals operator, copies the data from the rhs instance to this instance

Parameters
constHighPassFilter &rhs: another instance of the HighPassFilter class from which the data will be copied to this instance
Returns
a reference to this instance of HighPassFilter

Definition at line 61 of file HighPassFilter.cpp.

bool GRT::HighPassFilter::process ( const VectorDouble &  inputVector)
virtual

Sets the PreProcessing process function, overwriting the base PreProcessing 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 HighPassFilter's filter function.

Parameters
constVectorDouble &inputVector: the inputVector that should be processed. Must have the same dimensionality as the PreProcessing module
Returns
true if the data was processed, false otherwise

Reimplemented from GRT::PreProcessing.

Definition at line 95 of file HighPassFilter.cpp.

bool GRT::HighPassFilter::reset ( )
virtual

Sets the PreProcessing reset function, overwriting the base PreProcessing function. This function is called by the GestureRecognitionPipeline when the pipelines main reset() function is called. This function resets the filter values by re-initiliazing the filter.

Returns
true if the filter was reset, false otherwise

Reimplemented from GRT::PreProcessing.

Definition at line 114 of file HighPassFilter.cpp.

bool GRT::HighPassFilter::saveModelToFile ( string  filename) const
virtual

This saves the current settings of the HighPassFilter to a file. This overrides the saveModelToFile function in the PreProcessing base class.

Parameters
stringfilename: the name of the file to save the settings to
Returns
returns true if the model was saved successfully, false otherwise

Reimplemented from GRT::PreProcessing.

Definition at line 119 of file HighPassFilter.cpp.

bool GRT::HighPassFilter::saveModelToFile ( fstream &  file) const
virtual

This saves the current settings of the HighPassFilter to a file. This overrides the saveModelToFile function in the PreProcessing base class.

Parameters
fstream&file: a reference to the file the settings will be saved to
Returns
returns true if the settings were saved successfully, false otherwise

Reimplemented from GRT::PreProcessing.

Definition at line 139 of file HighPassFilter.cpp.

bool GRT::HighPassFilter::setCutoffFrequency ( double  cutoffFrequency,
double  delta 
)

Sets the cutoff frequency of the filter, this updates the filterFactor. The cutoffFrequency should in Hz. This will also reset the filter.

Parameters
doublecutoffFrequency: the cutoff frequency of the filter in Hz
doubledelta: the sampling rate of your sensor, delta should be set as 1.0/SR, where SR is the sampling rate of your sensor
Returns
true if the filterFactor value was set, false otherwise

Definition at line 317 of file HighPassFilter.cpp.

bool GRT::HighPassFilter::setFilterFactor ( double  filterFactor)

Sets the filter factor, this controls the high pass filter, a smaller value will result in a more aggresive attenuation of low frequency signals in the input signal. This should be a value in the range [0.0 1.0]. This will also reset the filter.

Parameters
doublefilterFactor: the new filterFactor value
Returns
true if the filterFactor value was set, false otherwise

Definition at line 308 of file HighPassFilter.cpp.

bool GRT::HighPassFilter::setGain ( double  gain)

Sets the gain of the high pass filter. This will also reset the filter.

Parameters
doublegain: the new gain value, this multiples the filtered values by a constant ampltidue
Returns
true if the gain value was set, false otherwise

Definition at line 299 of file HighPassFilter.cpp.


The documentation for this class was generated from the following files: