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.
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 
21 #define GRT_DLL_EXPORTS
23 
24 namespace GRT{
25 
27  recordingMode = NOT_RECORDING;
28  prepTime = 0;
29  recordTime = 0;
30 }
31 
33  this->recordingMode = rhs.recordingMode;
34  this->prepTime = rhs.prepTime;
35  this->recordTime = rhs.recordTime;
36  this->trainingTimer = rhs.trainingTimer;
37 }
38 
40 
41 }
42 
44  if( this != &rhs ){
45  this->recordingMode = rhs.recordingMode;
46  this->prepTime = rhs.prepTime;
47  this->recordTime = rhs.recordTime;
48  this->trainingTimer = rhs.trainingTimer;
49  }
50  return *this;
51 }
52 
53 bool TrainingDataRecordingTimer::startRecording(unsigned long prepTime,unsigned long recordTime){
54  this->prepTime = prepTime;
55  this->recordTime = recordTime;
56 
57  //If the prepTime is less than 1 then go straight ahead and start recording
58  if( prepTime < 1 ){
59  recordingMode = RECORDING;
60 
61  //If recordTime is less than 1 then record forever (until the user tells us to stop)
62  if( recordTime < 1 ) trainingTimer.start();
63  else trainingTimer.start( recordTime );
64  }else{
65  recordingMode = PREP_COUNTDOWN;
66  trainingTimer.start( prepTime );
67  }
68 
69  return true;
70 }
71 
72 bool TrainingDataRecordingTimer::stopRecording(){
73  recordingMode = NOT_RECORDING;
74  trainingTimer.stop();
75  return true;
76 }
77 
78 bool TrainingDataRecordingTimer::update(){
79 
80  switch( recordingMode ){
81  case NOT_RECORDING:
82  //Do nothing
83  return true;
84  break;
85  case PREP_COUNTDOWN:
86  //Check to see if the prep countdown phase is over, if so then move to the recording mode
87  if( trainingTimer.getTimerReached() ){
88  recordingMode = RECORDING;
89  //If recordTime is less than 1 then record forever (until the user tells us to stop)
90  if( recordTime < 1 ) trainingTimer.start();
91  else trainingTimer.start( recordTime );
92  }
93  break;
94  case RECORDING:
95  if( trainingTimer.getTimerReached() ){
96  recordingMode = NOT_RECORDING;
97  }
98  break;
99  default:
100  return false;
101  break;
102  }
103  return true;
104 }
105 
106 bool TrainingDataRecordingTimer::getInPrepMode(){
107  update();
108  return recordingMode==PREP_COUNTDOWN ? true : false;
109 }
110 
111 bool TrainingDataRecordingTimer::getInRecordingMode(){
112  update();
113  return recordingMode==RECORDING ? true : false;
114 }
115 
116 bool TrainingDataRecordingTimer::getRecordingStopped(){
117  update();
118  return recordingMode==NOT_RECORDING ? true : false;
119 }
120 
121 double TrainingDataRecordingTimer::getSeconds(){
122  update();
123  return trainingTimer.getSeconds();
124 }
125 
126 }; //End of namespace GRT
TrainingDataRecordingTimer & operator=(const TrainingDataRecordingTimer &rhs)
The TrainingDataRecordingTimer is a tool to help record your training data.