GestureRecognitionToolkit  Version: 0.2.0
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
ThresholdCrossingDetector Class Reference

Public Types

enum  SearchStates { SEARCHING_FOR_FIRST_THRESHOLD_CROSSING =0, SEARCHING_FOR_SECOND_THRESHOLD_CROSSING, NO_SEARCH_GATE_TIME_OUT }
 
enum  ThresholdCrossingModes {
  UPPER_THRESHOLD_CROSSING =0, LOWER_THRESHOLD_CROSSING, UPPER_OR_LOWER_THRESHOLD_CROSSING, UPPER_THEN_LOWER_THRESHOLD_CROSSING,
  LOWER_THEN_UPPER_THRESHOLD_CROSSING
}
 
enum  AnalysisModes { RAW_DATA_ANALYSIS_MODE =0, MOVING_OFFSET_ANALYSIS_MODE, DERIVATIVE_ANALYSIS_MODE }
 
enum  DetectionTimeoutMode { TIMEOUT_COUNTER =0, HYSTERESIS_THRESHOLD }
 

Public Member Functions

 ThresholdCrossingDetector (UINT analysisMode=RAW_DATA_ANALYSIS_MODE, UINT thresholdCrossingMode=UPPER_THRESHOLD_CROSSING, UINT detectionTimeoutMode=TIMEOUT_COUNTER, Float lowerThreshold=-1, Float upperThreshold=1, Float hysteresisThreshold=0, UINT searchWindowSize=20, UINT searchTimeoutDuration=1000, UINT offsetFilterSize=10)
 
 ~ThresholdCrossingDetector ()
 
 ThresholdCrossingDetector (const ThresholdCrossingDetector &rhs)
 
ThresholdCrossingDetectoroperator= (const ThresholdCrossingDetector &rhs)
 
bool update (const Float x)
 
bool reset ()
 
bool triggerSearchTimeout ()
 
bool getThresholdCrossingDetected () const
 
bool getEnableSearch () const
 
UINT getAnalysisMode () const
 
UINT getThresholdCrossingMode () const
 
UINT getSearchWindowSize () const
 
UINT getOffsetFilterSize () const
 
UINT getSearchWindowIndex () const
 
UINT getSearchTimeoutCounter ()
 
UINT getSearchTimeoutDuration () const
 
Float getAnalysisValue () const
 
Float getUpperThreshold () const
 
Float getLowerThreshold () const
 
Float getHysteresisThreshold () const
 
bool setEnableSearch (const bool enableSearch)
 
bool setAnalysisMode (const UINT analysisMode)
 
bool setThresholdCrossingMode (const UINT thresholdCrossingMode)
 
bool setSearchWindowSize (const UINT searchWindowSize)
 
bool setOffsetFilterSize (const UINT offsetFilterSize)
 
bool setSearchTimeoutDuration (const UINT searchTimeoutDuration)
 
bool setDetectionTimeoutMode (const UINT detectionTimeoutMode)
 
bool setLowerThreshold (const Float lowerThreshold)
 
bool setUpperThreshold (const Float upperThreshold)
 
bool setHysteresisThreshold (const Float hysteresisThreshold)
 

Protected Attributes

Float analysisValue
 
Float lowerThreshold
 
Float upperThreshold
 
Float hysteresisThreshold
 
bool enableSearch
 
bool thresholdCrossingDetected
 
unsigned int analysisMode
 
unsigned int thresholdCrossingMode
 
unsigned int detectionTimeoutMode
 
unsigned int searchTimeoutDuration
 
unsigned int searchWindowSize
 
unsigned int searchWindowIndex
 
unsigned int offsetFilterSize
 
unsigned int currentSearchState
 
Timer searchTimeoutCounter
 
MovingAverageFilter movingAverageFilter
 
Derivative derivative
 

Detailed Description

Definition at line 38 of file ThresholdCrossingDetector.h.

Constructor & Destructor Documentation

GRT_BEGIN_NAMESPACE ThresholdCrossingDetector::ThresholdCrossingDetector ( UINT  analysisMode = RAW_DATA_ANALYSIS_MODE,
UINT  thresholdCrossingMode = UPPER_THRESHOLD_CROSSING,
UINT  detectionTimeoutMode = TIMEOUT_COUNTER,
Float  lowerThreshold = -1,
Float  upperThreshold = 1,
Float  hysteresisThreshold = 0,
UINT  searchWindowSize = 20,
UINT  searchTimeoutDuration = 1000,
UINT  offsetFilterSize = 10 
)

Default Constructor.

Parameters
analysisModesets the algorithm used to detect threshold crossings, this should be one of the AnalysisMode enums
thresholdCrossingModesets the threshold crossing mode, this should be one of the ThresholdCrossingModes enums
lowerThresholdsets the lower threshold level
upperThresholdsets the upper threshold level
searchWindowSizesets the size of the search window used to detect UPPER_THEN_LOWER_THRESHOLD_CROSSING or LOWER_THEN_UPPER_THRESHOLD_CROSSING
searchTimeoutDurationsets the duration (in samples) that the threshold detector will ignore any new threshold crossings after detecting a valid threshold crossing
offsetFilterSizesets the size of the moving average filter used to offset the input value (if the analysisMode is set to MOVING_OFFSET_ANALYSIS_MODE)

Definition at line 26 of file ThresholdCrossingDetector.cpp.

ThresholdCrossingDetector::~ThresholdCrossingDetector ( )

Default Destructor.

Definition at line 66 of file ThresholdCrossingDetector.cpp.

ThresholdCrossingDetector::ThresholdCrossingDetector ( const ThresholdCrossingDetector rhs)

Copy Constructor. Copies the data from the rhs instance to this instance.

Parameters
constThresholdCrossingDetector &rhs: the right hand instance from which the data will be copied to this instance

Definition at line 47 of file ThresholdCrossingDetector.cpp.

Member Function Documentation

UINT ThresholdCrossingDetector::getAnalysisMode ( ) const
Returns
returns the current analysis mode, this will be one of the AnalysisModes enums

Definition at line 283 of file ThresholdCrossingDetector.cpp.

Float ThresholdCrossingDetector::getAnalysisValue ( ) const
Returns
gets the most recent analysis value used to compute the threshold crossing

Definition at line 311 of file ThresholdCrossingDetector.cpp.

bool ThresholdCrossingDetector::getEnableSearch ( ) const
Returns
returns true if the search is enabled, false otherwise

Definition at line 279 of file ThresholdCrossingDetector.cpp.

Float ThresholdCrossingDetector::getHysteresisThreshold ( ) const
Returns
gets the hysteresis threshold value

Definition at line 323 of file ThresholdCrossingDetector.cpp.

Float ThresholdCrossingDetector::getLowerThreshold ( ) const
Returns
gets the lower threshold value

Definition at line 319 of file ThresholdCrossingDetector.cpp.

UINT ThresholdCrossingDetector::getOffsetFilterSize ( ) const
Returns
returns the size of the moving average filter used to offset the input value, this is only used if the analysisMode is MOVING_OFFSET_ANALYSIS_MODE

Definition at line 295 of file ThresholdCrossingDetector.cpp.

UINT ThresholdCrossingDetector::getSearchTimeoutCounter ( )
Returns
gets the current search timeout counter value

Definition at line 303 of file ThresholdCrossingDetector.cpp.

UINT ThresholdCrossingDetector::getSearchTimeoutDuration ( ) const
Returns
gets the search timeout duration

Definition at line 307 of file ThresholdCrossingDetector.cpp.

UINT ThresholdCrossingDetector::getSearchWindowIndex ( ) const
Returns
gets the current index in the search window when the algorithm is looking for the second threshold crossing for UPPER_THEN_LOWER_THRESHOLD_CROSSING or LOWER_THEN_UPPER_THRESHOLD_CROSSING

Definition at line 299 of file ThresholdCrossingDetector.cpp.

UINT ThresholdCrossingDetector::getSearchWindowSize ( ) const
Returns
returns the search window size, this is only used if the thresholdCrossingMode is UPPER_THEN_LOWER_THRESHOLD_CROSSING or LOWER_THEN_UPPER_THRESHOLD_CROSSING

Definition at line 291 of file ThresholdCrossingDetector.cpp.

bool ThresholdCrossingDetector::getThresholdCrossingDetected ( ) const

This function returns true if a threshold crossing was detected during the last update.

Returns
returns true if a threshold crossing was detected, false otherwise

Definition at line 275 of file ThresholdCrossingDetector.cpp.

UINT ThresholdCrossingDetector::getThresholdCrossingMode ( ) const
Returns
returns the current threshold crossing mode being used, this will be one of the ThresholdCrossingModes enums

Definition at line 287 of file ThresholdCrossingDetector.cpp.

Float ThresholdCrossingDetector::getUpperThreshold ( ) const
Returns
gets the upper threshold value

Definition at line 315 of file ThresholdCrossingDetector.cpp.

ThresholdCrossingDetector & ThresholdCrossingDetector::operator= ( const ThresholdCrossingDetector rhs)

Equals Operator. Copies the data from the rhs instance to this instance.

Parameters
rhsthe right hand instance from which the data will be copied to this instance
Returns
returns a reference to this instance

Definition at line 70 of file ThresholdCrossingDetector.cpp.

bool ThresholdCrossingDetector::reset ( )

This function resets the threshold crossing detector.

Returns
returns true if the threshold crossing detector was reset, false otherwise

Definition at line 249 of file ThresholdCrossingDetector.cpp.

bool ThresholdCrossingDetector::setAnalysisMode ( const UINT  analysisMode)

Sets the anlysis mode used to detect threshold crossings. This should be one of the AnalysisModes enums.

Parameters
constUINT analysisMode: the new analysisMode
Returns
returns true if the parameter was updated, false otherwise

Definition at line 332 of file ThresholdCrossingDetector.cpp.

bool ThresholdCrossingDetector::setDetectionTimeoutMode ( const UINT  detectionTimeoutMode)

Sets the detectionTimeoutMode, this controls how the detection algorithm triggers detection timeouts after a threshold crossing has been detected. If the detectionTimeoutMode is TIMEOUT_COUNTER then the detection algorithm will wait for until the searchTimeoutDuration before searching for the next threshold crossing. Alternatively, if the detectionTimeoutMode is HYSTERESIS_THRESHOLD then the detection algorithm will wait for the analysis signal to pass the hysteresisThreshold (regardless of the time this takes) before searching for a new threshold crossing.

Parameters
constUINT searchTimeoutDuration: the new searchTimeoutDuration
Returns
returns true if the parameter was updated, false otherwise

Definition at line 342 of file ThresholdCrossingDetector.cpp.

bool ThresholdCrossingDetector::setEnableSearch ( const bool  enableSearch)

Sets if the algorithm can perform the threshold crossing search. If enableSearch is set to false, then the algorithm will never search for a threshold crossing.

Parameters
constbool enableSearch: the new enableSearch mode
Returns
returns true if the parameter was updated, false otherwise

Definition at line 327 of file ThresholdCrossingDetector.cpp.

bool ThresholdCrossingDetector::setHysteresisThreshold ( const Float  hysteresisThreshold)

Sets the hysteresisThreshold value, this threshold is used to debounce triggers if the detectionTimeoutMode is set to HYSTERESIS_THRESHOLD.

Parameters
hysteresisThresholdthe new hysteresisThreshold
Returns
returns true if the parameter was updated, false otherwise

Definition at line 372 of file ThresholdCrossingDetector.cpp.

bool ThresholdCrossingDetector::setLowerThreshold ( const Float  lowerThreshold)

Sets the lowerThreshold value, this lower threshold that must be crossed to trigger a LOWER_THRESHOLD_CROSSING.

Parameters
lowerThresholdthe new lowerThreshold
Returns
returns true if the parameter was updated, false otherwise

Definition at line 362 of file ThresholdCrossingDetector.cpp.

bool ThresholdCrossingDetector::setOffsetFilterSize ( const UINT  offsetFilterSize)

Sets the size of the moving average filter used to offset the input data. This is only used if the analysisMode is MOVING_OFFSET_ANALYSIS_MODE.

Parameters
constUINT offsetFilterSize: the new offsetFilterSize
Returns
returns true if the parameter was updated, false otherwise

Definition at line 352 of file ThresholdCrossingDetector.cpp.

bool ThresholdCrossingDetector::setSearchTimeoutDuration ( const UINT  searchTimeoutDuration)

Sets the searchTimeoutDuration, this is the time (in milliseconds) that will be ignored after a threshold crossing has been detected.

Parameters
constUINT searchTimeoutDuration: the new searchTimeoutDuration in milliseconds
Returns
returns true if the parameter was updated, false otherwise

Definition at line 357 of file ThresholdCrossingDetector.cpp.

bool ThresholdCrossingDetector::setSearchWindowSize ( const UINT  searchWindowSize)

Sets the searchWindowSize. This is the number of samples the algorithm will search for a second threshold crossing after the first threshold crossing has been found (in the UPPER_THEN_LOWER_THRESHOLD_CROSSING or LOWER_THEN_UPPER_THRESHOLD_CROSSING modes).

Parameters
constUINT searchWindowSize: the new searchWindowSize
Returns
returns true if the parameter was updated, false otherwise

Definition at line 347 of file ThresholdCrossingDetector.cpp.

bool ThresholdCrossingDetector::setThresholdCrossingMode ( const UINT  thresholdCrossingMode)

Sets the threshold crossing mode used to detect threshold crossings. This should be one of the ThresholdCrossingModes enums.

Parameters
constUINT thresholdCrossingMode: the new thresholdCrossingMode
Returns
returns true if the parameter was updated, false otherwise

Definition at line 337 of file ThresholdCrossingDetector.cpp.

bool ThresholdCrossingDetector::setUpperThreshold ( const Float  upperThreshold)

Sets the upperThreshold value, this upper threshold that must be crossed to trigger a UPPER_THRESHOLD_CROSSING.

Parameters
upperThresholdthe new upperThreshold
Returns
returns true if the parameter was updated, false otherwise

Definition at line 367 of file ThresholdCrossingDetector.cpp.

bool ThresholdCrossingDetector::triggerSearchTimeout ( )

This function triggers a search timeout (i.e. the algorithm will stop searching for the next N samples, where N = searchTimeoutDuration).

Returns
returns true if the search timeout was triggered, false otherwise

Definition at line 269 of file ThresholdCrossingDetector.cpp.

bool ThresholdCrossingDetector::update ( const Float  x)

This is the main update interface, you should call this every time you get a new sample from your sensor.

Parameters
xthe new value that will be pushed through the threshold crossing algorithm
Returns
returns true if a threshold crossing was detected, false otherwise

Definition at line 92 of file ThresholdCrossingDetector.cpp.


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