GestureRecognitionToolkit  Version: 0.1.0
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
TrainingDataRecordingTimer.cpp
1 /*
2 GRT MIT License
3 Copyright (c) <2012> <Nicholas Gillian, Media Lab, MIT>
4 
5 Permission is hereby granted, free of charge, to any person obtaining a copy of this software
6 and associated documentation files (the "Software"), to deal in the Software without restriction,
7 including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
9 subject to the following conditions:
10 
11 The above copyright notice and this permission notice shall be included in all copies or substantial
12 portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15 LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
18 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 */
20 
22 
23 namespace GRT{
24 
26  recordingMode = NOT_RECORDING;
27  prepTime = 0;
28  recordTime = 0;
29 }
30 
32  this->recordingMode = rhs.recordingMode;
33  this->prepTime = rhs.prepTime;
34  this->recordTime = rhs.recordTime;
35  this->trainingTimer = rhs.trainingTimer;
36 }
37 
39 
40 }
41 
43  if( this != &rhs ){
44  this->recordingMode = rhs.recordingMode;
45  this->prepTime = rhs.prepTime;
46  this->recordTime = rhs.recordTime;
47  this->trainingTimer = rhs.trainingTimer;
48  }
49  return *this;
50 }
51 
52 bool TrainingDataRecordingTimer::startRecording(unsigned long prepTime,unsigned long recordTime){
53  this->prepTime = prepTime;
54  this->recordTime = recordTime;
55 
56  //If the prepTime is less than 1 then go straight ahead and start recording
57  if( prepTime < 1 ){
58  recordingMode = RECORDING;
59 
60  //If recordTime is less than 1 then record forever (until the user tells us to stop)
61  if( recordTime < 1 ) trainingTimer.start();
62  else trainingTimer.start( recordTime );
63  }else{
64  recordingMode = PREP_COUNTDOWN;
65  trainingTimer.start( prepTime );
66  }
67 
68  return true;
69 }
70 
71 bool TrainingDataRecordingTimer::stopRecording(){
72  recordingMode = NOT_RECORDING;
73  trainingTimer.stop();
74  return true;
75 }
76 
77 bool TrainingDataRecordingTimer::update(){
78 
79  switch( recordingMode ){
80  case NOT_RECORDING:
81  //Do nothing
82  return true;
83  break;
84  case PREP_COUNTDOWN:
85  //Check to see if the prep countdown phase is over, if so then move to the recording mode
86  if( trainingTimer.getTimerReached() ){
87  recordingMode = RECORDING;
88  //If recordTime is less than 1 then record forever (until the user tells us to stop)
89  if( recordTime < 1 ) trainingTimer.start();
90  else trainingTimer.start( recordTime );
91  }
92  break;
93  case RECORDING:
94  if( trainingTimer.getTimerReached() ){
95  recordingMode = NOT_RECORDING;
96  }
97  break;
98  default:
99  return false;
100  break;
101  }
102  return true;
103 }
104 
105 bool TrainingDataRecordingTimer::getInPrepMode(){
106  update();
107  return recordingMode==PREP_COUNTDOWN ? true : false;
108 }
109 
110 bool TrainingDataRecordingTimer::getInRecordingMode(){
111  update();
112  return recordingMode==RECORDING ? true : false;
113 }
114 
115 bool TrainingDataRecordingTimer::getRecordingStopped(){
116  update();
117  return recordingMode==NOT_RECORDING ? true : false;
118 }
119 
120 double TrainingDataRecordingTimer::getSeconds(){
121  update();
122  return trainingTimer.getSeconds();
123 }
124 
125 }; //End of namespace GRT
TrainingDataRecordingTimer & operator=(const TrainingDataRecordingTimer &rhs)
Float getSeconds()
Definition: Timer.h:153
Definition: DebugLog.cpp:23
bool getTimerReached()
Definition: Timer.h:183
bool start()
Definition: Timer.h:64
The TrainingDataRecordingTimer is a tool to help record your training data.
bool stop()
Definition: Timer.h:105