![]() |
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 Member Functions | |
TimeSeriesClassificationDataStream (const UINT numDimensions=0, const string datasetName="NOT_SET", const string infoText="") | |
TimeSeriesClassificationDataStream (const TimeSeriesClassificationDataStream &rhs) | |
virtual | ~TimeSeriesClassificationDataStream () |
TimeSeriesClassificationDataStream & | operator= (const TimeSeriesClassificationDataStream &rhs) |
ClassificationSample & | operator[] (const UINT i) |
void | clear () |
bool | setNumDimensions (const UINT numDimensions) |
bool | setDatasetName (const string datasetName) |
bool | setInfoText (const string infoText) |
bool | setClassNameForCorrespondingClassLabel (const string className, const UINT classLabel) |
bool | addSample (const UINT classLabel, const VectorDouble &trainingSample) |
bool | removeLastSample () |
UINT | eraseAllSamplesWithClassLabel (const UINT classLabel) |
bool | relabelAllSamplesWithClassLabel (const UINT oldClassLabel, const UINT newClassLabel) |
bool | setExternalRanges (const vector< MinMax > &externalRanges, const bool useExternalRanges=false) |
bool | enableExternalRangeScaling (const bool useExternalRanges) |
bool | scale (const double minTarget, const double maxTarget) |
bool | scale (const vector< MinMax > &ranges, const double minTarget, const double maxTarget) |
bool | resetPlaybackIndex (const UINT playbackIndex) |
ClassificationSample | getNextSample () |
TimeSeriesClassificationData | getAllTrainingExamplesWithClassLabel (const UINT classLabel) const |
bool | save (const string &filename) |
bool | load (const string &filename) |
bool | saveDatasetToFile (const string &filename) |
bool | saveDatasetToCSVFile (const string &filename) |
bool | loadDatasetFromFile (const string &filename) |
bool | loadDatasetFromCSVFile (const string &filename, const UINT classLabelColumnIndex=0) |
bool | printStats () const |
string | getDatasetName () const |
string | getInfoText () const |
UINT | getNumDimensions () const |
UINT | getNumSamples () const |
UINT | getNumClasses () const |
UINT | getMinimumClassLabel () const |
UINT | getMaximumClassLabel () const |
UINT | getClassLabelIndexValue (const UINT classLabel) const |
string | getClassNameForCorrespondingClassLabel (const UINT classLabel) |
vector< MinMax > | getRanges () const |
vector< ClassTracker > | getClassTracker () const |
vector< TimeSeriesPositionTracker > | getTimeSeriesPositionTracker () const |
vector< ClassificationSample > | getClassificationSamples () const |
TimeSeriesClassificationDataStream | getSubset (const UINT startIndex, const UINT endIndex) const |
TimeSeriesClassificationData | getTimeSeriesClassificationData (const bool includeNullGestures=false) const |
ClassificationData | getClassificationData (const bool includeNullGestures=false) const |
MatrixDouble | getTimeSeriesData (const TimeSeriesPositionTracker &trackerInfo) const |
MatrixDouble | getDataAsMatrixDouble () const |
vector< UINT > | getClassLabels () const |
Protected Attributes | |
string | datasetName |
The name of the dataset. | |
string | infoText |
Some infoText about the dataset. | |
UINT | numDimensions |
The number of dimensions in the dataset. | |
UINT | totalNumSamples |
UINT | lastClassID |
UINT | playbackIndex |
bool | trackingClass |
bool | useExternalRanges |
A flag to show if the dataset should be scaled using the externalRanges values. | |
vector< MinMax > | externalRanges |
A vector containing a set of externalRanges set by the user. | |
vector< ClassTracker > | classTracker |
vector< ClassificationSample > | data |
vector< TimeSeriesPositionTracker > | timeSeriesPositionTracker |
DebugLog | debugLog |
Default debugging log. | |
ErrorLog | errorLog |
Default error log. | |
WarningLog | warningLog |
Default warning log. | |
Definition at line 41 of file TimeSeriesClassificationDataStream.h.
GRT::TimeSeriesClassificationDataStream::TimeSeriesClassificationDataStream | ( | const UINT | numDimensions = 0 , |
const string | datasetName = "NOT_SET" , |
||
const string | infoText = "" |
||
) |
Constructor, sets the name of the dataset and the number of dimensions of the training data. The name of the dataset should not contain any spaces.
UINT | numDimensions: the number of dimensions of the training data, should be an unsigned integer greater than 0 |
string | datasetName: the name of the dataset, should not contain any spaces |
string | infoText: some info about the data in this dataset, this can contain spaces |
Definition at line 26 of file TimeSeriesClassificationDataStream.cpp.
GRT::TimeSeriesClassificationDataStream::TimeSeriesClassificationDataStream | ( | const TimeSeriesClassificationDataStream & | rhs | ) |
Copy Constructor, copies the TimeSeriesClassificationDataStream from the rhs instance to this instance
const | TimeSeriesClassificationDataStream &rhs: another instance of the TimeSeriesClassificationDataStream class from which the data will be copied to this instance |
Definition at line 44 of file TimeSeriesClassificationDataStream.cpp.
|
virtual |
Default Destructor
Definition at line 48 of file TimeSeriesClassificationDataStream.cpp.
bool GRT::TimeSeriesClassificationDataStream::addSample | ( | const UINT | classLabel, |
const VectorDouble & | trainingSample | ||
) |
Adds a new labelled sample to the dataset. The dimensionality of the sample should match the number of dimensions in the TimeSeriesClassificationDataStream. The class label can be zero (this should represent a null class).
const | UINT classLabel: the class label of the corresponding sample |
const | VectorDouble &sample: the new sample you want to add to the dataset. The dimensionality of this sample should match the number of dimensions in the TimeSeriesClassificationDataStream |
Definition at line 127 of file TimeSeriesClassificationDataStream.cpp.
void GRT::TimeSeriesClassificationDataStream::clear | ( | ) |
Clears any previous training data and counters
Definition at line 72 of file TimeSeriesClassificationDataStream.cpp.
bool GRT::TimeSeriesClassificationDataStream::enableExternalRangeScaling | ( | const bool | useExternalRanges | ) |
Sets if the dataset should be scaled using an external range (if useExternalRanges == true) or the ranges of the dataset (if false). The external ranges need to be set FIRST before calling this function, otherwise it will return false.
bool | useExternalRanges: sets if these ranges should be used to scale the dataset |
Definition at line 312 of file TimeSeriesClassificationDataStream.cpp.
UINT GRT::TimeSeriesClassificationDataStream::eraseAllSamplesWithClassLabel | ( | const UINT | classLabel | ) |
Deletes from the dataset all the samples with a specific class label.
const | UINT classLabel: the class label of the samples you wish to delete from the dataset |
Definition at line 201 of file TimeSeriesClassificationDataStream.cpp.
TimeSeriesClassificationData GRT::TimeSeriesClassificationDataStream::getAllTrainingExamplesWithClassLabel | ( | const UINT | classLabel | ) | const |
Gets all the timeseries that have a specific class label.
const | UINT classLabel: the class label of the timeseries you want to find |
Definition at line 352 of file TimeSeriesClassificationDataStream.cpp.
ClassificationData GRT::TimeSeriesClassificationDataStream::getClassificationData | ( | const bool | includeNullGestures = false | ) | const |
This function segments the continuous time series data into individual samples and then adds these samples into a new ClassificationData dataset. This new dataset is then returned. By default, the new dataset will not contain any samples with the class label of GRT_DEFAULT_NULL_CLASS_LABEL (as this is assumed to be a NULL gesture) unless you set the includeNullGestures parameter to true.
Definition at line 828 of file TimeSeriesClassificationDataStream.cpp.
|
inline |
Gets the classification data as a vector of ClassificationSample.
Definition at line 380 of file TimeSeriesClassificationDataStream.h.
UINT GRT::TimeSeriesClassificationDataStream::getClassLabelIndexValue | ( | const UINT | classLabel | ) | const |
Gets the index of the class label from the class tracker.
Definition at line 391 of file TimeSeriesClassificationDataStream.cpp.
vector< UINT > GRT::TimeSeriesClassificationDataStream::getClassLabels | ( | ) | const |
Gets the class labels in the current dataset.
Definition at line 882 of file TimeSeriesClassificationDataStream.cpp.
string GRT::TimeSeriesClassificationDataStream::getClassNameForCorrespondingClassLabel | ( | const UINT | classLabel | ) |
Gets the name of the class with a given class label. If the class label does not exist then the string "CLASS_LABEL_NOT_FOUND" will be returned.
Definition at line 401 of file TimeSeriesClassificationDataStream.cpp.
|
inline |
Gets the class tracker for each class in the dataset.
Definition at line 366 of file TimeSeriesClassificationDataStream.h.
MatrixDouble GRT::TimeSeriesClassificationDataStream::getDataAsMatrixDouble | ( | ) | const |
Gets all the data as a MatrixDouble. This returns just the data, not the labels. This will be an M by N MatrixDouble, where M is the number of samples and N is the number of dimensions.
Definition at line 870 of file TimeSeriesClassificationDataStream.cpp.
|
inline |
Gets the name of the dataset.
Definition at line 296 of file TimeSeriesClassificationDataStream.h.
|
inline |
Gets the infotext for the dataset
Definition at line 303 of file TimeSeriesClassificationDataStream.h.
UINT GRT::TimeSeriesClassificationDataStream::getMaximumClassLabel | ( | ) | const |
Gets the maximum class label in the dataset. If there are no values in the dataset then the value 0 will be returned.
Definition at line 379 of file TimeSeriesClassificationDataStream.cpp.
UINT GRT::TimeSeriesClassificationDataStream::getMinimumClassLabel | ( | ) | const |
Gets the minimum class label in the dataset. If there are no values in the dataset then the value 99999 will be returned.
Definition at line 366 of file TimeSeriesClassificationDataStream.cpp.
ClassificationSample GRT::TimeSeriesClassificationDataStream::getNextSample | ( | ) |
Gets the next sample, this will also increment the playback index. If the playback index reaches the last data sample then it will be reset to 0.
Definition at line 345 of file TimeSeriesClassificationDataStream.cpp.
|
inline |
Gets the number of classes.
Definition at line 324 of file TimeSeriesClassificationDataStream.h.
|
inline |
Gets the number of dimensions of the labelled classification data.
Definition at line 310 of file TimeSeriesClassificationDataStream.h.
|
inline |
Gets the number of samples in the classification data across all the classes.
Definition at line 317 of file TimeSeriesClassificationDataStream.h.
vector< MinMax > GRT::TimeSeriesClassificationDataStream::getRanges | ( | ) | const |
Gets the ranges of the classification data.
Definition at line 411 of file TimeSeriesClassificationDataStream.cpp.
TimeSeriesClassificationDataStream GRT::TimeSeriesClassificationDataStream::getSubset | ( | const UINT | startIndex, |
const UINT | endIndex | ||
) | const |
Gets a new TimeSeriesClassificationDataStream dataset drawn from the startIndex and endIndex values. The startIndex and endIndex values must be valid (i.e. if the current dataset has 1000 samples then you can not have a startIndex or endIndex value that is greater or equal to 1000).
UINT | startIndex: the index of the first value from the current dataset that you want to start the new subset from |
UINT | endIndex: the index of the last value from the current dataset that you want to end the new dataset at (inclusive) |
Definition at line 782 of file TimeSeriesClassificationDataStream.cpp.
TimeSeriesClassificationData GRT::TimeSeriesClassificationDataStream::getTimeSeriesClassificationData | ( | const bool | includeNullGestures = false | ) | const |
This function segments the continuous time series data into individual time series and then adds these time series into a new TimeSeriesClassificationData dataset. This new dataset is then returned. By default, the new dataset will not contain any time series with the class label of GRT_DEFAULT_NULL_CLASS_LABEL (as this is assumed to be a NULL gesture) unless you set the includeNullGestures parameter to true.
Definition at line 809 of file TimeSeriesClassificationDataStream.cpp.
MatrixDouble GRT::TimeSeriesClassificationDataStream::getTimeSeriesData | ( | const TimeSeriesPositionTracker & | trackerInfo | ) | const |
This function segments a specific time series from the main data set and returns this as a MatrixDouble. You should use one of the TimeSeriesPositionTracker elements from the timeSeriesPositionTracker vector to indicate to the function which time series you want to retrieve. You can get the TimeSeriesPositionTracker elements using the getTimeSeriesPositionTracker() function.
The MatrixDouble will be empty if the trackerInfo indexs (the startIndex and the endIndex) are not valid.
Definition at line 849 of file TimeSeriesClassificationDataStream.cpp.
|
inline |
Gets the timeseries position tracker, a vector of TimeSeriesPositionTracker which indicate the start and end position of each time series in the dataset.
Definition at line 373 of file TimeSeriesClassificationDataStream.h.
bool GRT::TimeSeriesClassificationDataStream::load | ( | const string & | filename | ) |
Load the data from a file. If the file format ends in '.csv' then the function will try and load the data from a csv format. If this fails then it will try and load the data as a custom GRT file.
const | string &filename: the name of the file the data will be loaded from |
Definition at line 443 of file TimeSeriesClassificationDataStream.cpp.
bool GRT::TimeSeriesClassificationDataStream::loadDatasetFromCSVFile | ( | const string & | filename, |
const UINT | classLabelColumnIndex = 0 |
||
) |
Loads the labelled timeseries classification data from a CSV file. This assumes the data is formatted with each row representing a sample. The class label should be the first column followed by the sample data as the following N columns, where N is the number of dimensions in the data. If the class label is not the first column, you should set the 2nd argument (UINT classLabelColumnIndex) to the column index that contains the class label.
const | string filename: the name of the file the data will be loaded from |
const | UINT classLabelColumnIndex: the index of the column containing the class label. Default value = 0 |
Definition at line 694 of file TimeSeriesClassificationDataStream.cpp.
bool GRT::TimeSeriesClassificationDataStream::loadDatasetFromFile | ( | const string & | filename | ) |
Loads the data from a custom file format.
string | filename: the name of the file the data will be loaded from |
Definition at line 508 of file TimeSeriesClassificationDataStream.cpp.
TimeSeriesClassificationDataStream & GRT::TimeSeriesClassificationDataStream::operator= | ( | const TimeSeriesClassificationDataStream & | rhs | ) |
Sets the equals operator, copies the data from the rhs instance to this instance
const | TimeSeriesClassificationDataStream &rhs: another instance of the TimeSeriesClassificationDataStream class from which the data will be copied to this instance |
Definition at line 50 of file TimeSeriesClassificationDataStream.cpp.
|
inline |
Array Subscript Operator, returns the ClassificationSample at index i. It is up to the user to ensure that i is within the range of [0 totalNumSamples-1]
const | UINT &i: the index of the training sample you want to access. Must be within the range of [0 totalNumSamples-1] |
Definition at line 81 of file TimeSeriesClassificationDataStream.h.
bool GRT::TimeSeriesClassificationDataStream::printStats | ( | ) | const |
Prints the dataset info (such as its name and infoText) and the stats (such as the number of examples, number of dimensions, number of classes, etc.) to the std out.
Definition at line 749 of file TimeSeriesClassificationDataStream.cpp.
bool GRT::TimeSeriesClassificationDataStream::relabelAllSamplesWithClassLabel | ( | const UINT | oldClassLabel, |
const UINT | newClassLabel | ||
) |
Relabels all the samples with the class label A with the new class label B.
const | UINT oldClassLabel: the class label of the samples you want to relabel |
const | UINT newClassLabel: the class label the samples will be relabelled with |
Definition at line 250 of file TimeSeriesClassificationDataStream.cpp.
bool GRT::TimeSeriesClassificationDataStream::removeLastSample | ( | ) |
Removes the last training sample added to the dataset.
Definition at line 169 of file TimeSeriesClassificationDataStream.cpp.
bool GRT::TimeSeriesClassificationDataStream::resetPlaybackIndex | ( | const UINT | playbackIndex | ) |
Sets the playback index to a specific index. The index should be within the range [0 totalNumSamples-1].
const | UINT playbackIndex: the value you want to set the playback index to |
Definition at line 337 of file TimeSeriesClassificationDataStream.cpp.
bool GRT::TimeSeriesClassificationDataStream::save | ( | const string & | filename | ) |
Saves the data to a file. If the file format ends in '.csv' then the data will be saved as comma-seperated-values, otherwise it will be saved to a custom GRT file (which contains the csv data with an additional header).
const | string &filename: the name of the file the data will be saved to |
Definition at line 432 of file TimeSeriesClassificationDataStream.cpp.
bool GRT::TimeSeriesClassificationDataStream::saveDatasetToCSVFile | ( | const string & | filename | ) |
Saves the data to a CSV file. This will save the timeseries counter as the first column, the class label as the second column, and the sample data as the following N columns, where N is the number of dimensions in the data. Each row will represent a sample.
const | string &filename: the name of the file the data will be saved to |
Definition at line 671 of file TimeSeriesClassificationDataStream.cpp.
bool GRT::TimeSeriesClassificationDataStream::saveDatasetToFile | ( | const string & | filename | ) |
Saves the labelled timeseries classification data to a custom file format.
string | filename: the name of the file the data will be saved to |
Definition at line 454 of file TimeSeriesClassificationDataStream.cpp.
bool GRT::TimeSeriesClassificationDataStream::scale | ( | const double | minTarget, |
const double | maxTarget | ||
) |
Scales the dataset to the new target range. This function uses the minimum and maximum values of the current dataset as the source range.
const | double minTarget: the minimum value of the target range |
const | double maxTarget: the maximum value of the target range |
Definition at line 320 of file TimeSeriesClassificationDataStream.cpp.
bool GRT::TimeSeriesClassificationDataStream::scale | ( | const vector< MinMax > & | ranges, |
const double | minTarget, | ||
const double | maxTarget | ||
) |
Scales the dataset to the new target range, using the vector of ranges as the min and max source ranges.
const | vector<MinMax> &ranges: the minimum and maximum values for the source range |
const | double minTarget: the minimum value of the target range |
const | double maxTarget: the maximum value of the target range |
Definition at line 325 of file TimeSeriesClassificationDataStream.cpp.
bool GRT::TimeSeriesClassificationDataStream::setClassNameForCorrespondingClassLabel | ( | const string | className, |
const UINT | classLabel | ||
) |
Sets the name of the class with the given class label. There should not be any spaces in the className. Will return true if the name is set, or false if the class label does not exist.
Definition at line 114 of file TimeSeriesClassificationDataStream.cpp.
bool GRT::TimeSeriesClassificationDataStream::setDatasetName | ( | const string | datasetName | ) |
Sets the name of the dataset. There should not be any spaces in the name. Will return true if the name is set, or false otherwise.
Definition at line 97 of file TimeSeriesClassificationDataStream.cpp.
bool GRT::TimeSeriesClassificationDataStream::setExternalRanges | ( | const vector< MinMax > & | externalRanges, |
const bool | useExternalRanges = false |
||
) |
Sets the external ranges of the dataset, also sets if the dataset should be scaled using these values. The dimensionality of the externalRanges vector should match the number of dimensions of this dataset.
const | vector< MinMax > &externalRanges: an N dimensional vector containing the min and max values of the expected ranges of the dataset. |
const | bool useExternalRanges: sets if these ranges should be used to scale the dataset, default value is false. |
Definition at line 302 of file TimeSeriesClassificationDataStream.cpp.
bool GRT::TimeSeriesClassificationDataStream::setInfoText | ( | const string | infoText | ) |
Sets the info string. This can be any string with information about how the training data was recorded for example.
const | string infoText: the infoText |
Definition at line 109 of file TimeSeriesClassificationDataStream.cpp.
bool GRT::TimeSeriesClassificationDataStream::setNumDimensions | ( | const UINT | numDimensions | ) |
Sets the number of dimensions in the training data. This should be an unsigned integer greater than zero. This will clear any previous training data and counters. This function needs to be called before any new samples can be added to the dataset, unless the numDimensions variable was set in the constructor or some data was already loaded from a file
const | UINT numDimensions: the number of dimensions of the training data. Must be an unsigned integer greater than zero |
Definition at line 81 of file TimeSeriesClassificationDataStream.cpp.