#include <GloveGesture.h>
Inheritance diagram for gadget::GloveGesture:


Public Methods | |
| GloveGesture () | |
| virtual bool | config (jccl::ConfigElementPtr e) |
| virtual std::string | getGestureString (int gestureId=-1) |
| Gets a gesture name. More... | |
| virtual int | createGesture (std::string gestureName) |
| Creates a new gesture. More... | |
| virtual void | loadFileHeader (std::ifstream &infile) |
| Loads the header of a glove data file. More... | |
| virtual void | saveFileHeader (std::ofstream &outFile) |
| Saves a file header. More... | |
| virtual int | getGestureIndex (std::string gestureName) |
| Returns the gesture identifier of the gesture. More... | |
| virtual int | getNumGestures () |
| Return the number of gestures in system. More... | |
Protected Attributes | |
| std::vector< std::string > | mGestureNames |
| List of all gesture names. More... | |
| std::vector< GloveData > | mGestureExamples |
| Examples of all gestures. More... | |
| GloveProxy * | mGloveProxy |
| Proxy to the glove. More... | |
Definition at line 51 of file GloveGesture.h.
|
|
Definition at line 54 of file GloveGesture.h. References mGloveProxy.
00055 {
00056 mGloveProxy = NULL;
00057 }
|
|
|
Reimplemented from gadget::Gesture. Reimplemented in gadget::SimGloveGesture. Definition at line 59 of file GloveGesture.h.
00060 {
00061 return Gesture::config(e);
00062 }
|
|
|
Gets a gesture name.
Implements gadget::Gesture. Definition at line 45 of file GloveGesture.cpp. References mGestureNames.
00046 {
00047 if(gestureId < 0)
00048 return getGestureString(this->getGesture()); // Get string of current gesture
00049 else if((unsigned)gestureId < mGestureNames.size())
00050 return mGestureNames[gestureId];
00051 else
00052 return std::string("");
00053 }
|
|
|
Creates a new gesture.
Implements gadget::Gesture. Definition at line 60 of file GloveGesture.cpp. References mGestureExamples, and mGestureNames.
00061 {
00062 mGestureNames.push_back(gestureName); // Push it back
00063 mGestureExamples.push_back(GloveData()); // Push back an empty vector of floats
00064 vprASSERT(mGestureNames.size() == mGestureExamples.size());
00065
00066 return (mGestureExamples.size() -1);
00067 }
|
|
|
Loads the header of a glove data file. This is both for the samples and for the trained files. The header format is: -Comments -- # starting
Definition at line 83 of file GloveGesture.cpp. References mGestureExamples, and mGestureNames. Referenced by gadget::SimGloveGesture::loadTrainedFile.
00084 {
00085 // skip comments
00086 while(infile.peek() == '#')
00087 infile.ignore(4096, '\n'); // Ignore the entire line.
00088
00089 // Get num gestures
00090 int num_gestures;
00091 infile >> num_gestures; // Get the number of gestures
00092
00093 infile.ignore(4096, '\n'); // Ignore the rest of the line
00094
00095 // Get gesture names
00096 int i;
00097 char gest_name[512];
00098
00099 mGestureNames = std::vector<std::string>(num_gestures);
00100 for(i=0;i<num_gestures;i++)
00101 {
00102 infile.getline(gest_name,512);
00103 mGestureNames[i] = std::string(gest_name);
00104 }
00105
00106 mGestureExamples = std::vector<GloveData>(num_gestures);
00107
00108 // Get gesture data
00109 for(i=0;i<num_gestures;i++)
00110 mGestureExamples[i].inputAngles(infile);
00111 }
|
|
|
Saves a file header.
Definition at line 119 of file GloveGesture.cpp. References mGestureExamples, and mGestureNames.
00120 {
00121 vprASSERT(mGestureNames.size() == mGestureExamples.size()); // The must be same size
00122
00123 outFile << "# GloveGesture v1.0" << std::endl
00124 << "# GloveGesture Header" << std::endl
00125 << "# Contains gesture names and examples" << std::endl
00126 << "# As well and trainer information" << std::endl;
00127
00128 outFile << mGestureNames.size() << std::endl;
00129
00130 unsigned int i;
00131 for(i =0;i<mGestureNames.size();i++)
00132 outFile << mGestureNames[i].c_str() << std::endl;
00133
00134 for(i=0;i<mGestureExamples.size();i++)
00135 {
00136 mGestureExamples[i].outputAngles(outFile);
00137 outFile << std::endl;
00138 }
00139 }
|
|
|
Returns the gesture identifier of the gesture.
Implements gadget::Gesture. Definition at line 142 of file GloveGesture.cpp. References mGestureNames.
00143 {
00144 unsigned i = 0;
00145 int found = -1;
00146 while((found <0) && (i<mGestureNames.size()))
00147 {
00148 if(mGestureNames[i] == gestureName)
00149 found = i;
00150 i++;
00151 }
00152
00153 return found;
00154 }
|
|
|
Return the number of gestures in system.
Definition at line 110 of file GloveGesture.h. References mGestureNames. Referenced by gadget::SimGloveGesture::config.
00111 { return mGestureNames.size(); }
|
|
|
List of all gesture names.
Definition at line 115 of file GloveGesture.h. Referenced by createGesture, getGestureIndex, getGestureString, getNumGestures, loadFileHeader, and saveFileHeader. |
|
|
Examples of all gestures.
Definition at line 116 of file GloveGesture.h. Referenced by createGesture, loadFileHeader, and saveFileHeader. |
|
|
Proxy to the glove.
Definition at line 117 of file GloveGesture.h. Referenced by GloveGesture. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002