Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Examples  

gadget::GloveGesture Class Reference

Abstract base class for all glove gesture recognition. More...

#include <GloveGesture.h>

Inheritance diagram for gadget::GloveGesture:

Inheritance graph
[legend]
Collaboration diagram for gadget::GloveGesture:

Collaboration graph
[legend]
List of all members.

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< GloveDatamGestureExamples
 Examples of all gestures. More...

GloveProxymGloveProxy
 Proxy to the glove. More...


Detailed Description

Abstract base class for all glove gesture recognition.

Definition at line 51 of file GloveGesture.h.


Constructor & Destructor Documentation

gadget::GloveGesture::GloveGesture   [inline]
 

Definition at line 54 of file GloveGesture.h.

References mGloveProxy.

00055    {
00056       mGloveProxy = NULL;
00057    }


Member Function Documentation

virtual bool gadget::GloveGesture::config jccl::ConfigElementPtr    e [inline, virtual]
 

Reimplemented from gadget::Gesture.

Reimplemented in gadget::SimGloveGesture.

Definition at line 59 of file GloveGesture.h.

00060    {
00061       return Gesture::config(e);
00062    }

std::string gadget::GloveGesture::getGestureString int    gestureId = -1 [virtual]
 

Gets a gesture name.

Returns:
Name of gesture with the given id (gestureId).
Note:
if gestureId = -1, returns name of current gesture.

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 }

int gadget::GloveGesture::createGesture std::string    gestureName [virtual]
 

Creates a new gesture.

Parameters:
gestureName  Name of the new gesture.
Returns:
int id of the 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 }

void gadget::GloveGesture::loadFileHeader std::ifstream &    infile [virtual]
 

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

  • <num gestures> -Gesture names -Gesture samples infile is a file that is already open and ready for reading.
Postcondition:
After running, this routines will leave the file pointer immedately after the header.
mGestureNames & mGestureExamples will be filled with correct data.

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 }

void gadget::GloveGesture::saveFileHeader std::ofstream &    outFile [virtual]
 

Saves a file header.

Note:
The client of this routine may add their own initial lines to the header as long as they remove them before calling loadFileHeader.

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 }

int gadget::GloveGesture::getGestureIndex std::string    gestureName [virtual]
 

Returns the gesture identifier of the gesture.

Returns:
-1 if not found.

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 }

virtual int gadget::GloveGesture::getNumGestures   [inline, virtual]
 

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(); }


Member Data Documentation

std::vector<std::string> gadget::GloveGesture::mGestureNames [protected]
 

List of all gesture names.

Definition at line 115 of file GloveGesture.h.

Referenced by createGesture, getGestureIndex, getGestureString, getNumGestures, loadFileHeader, and saveFileHeader.

std::vector<GloveData> gadget::GloveGesture::mGestureExamples [protected]
 

Examples of all gestures.

Definition at line 116 of file GloveGesture.h.

Referenced by createGesture, loadFileHeader, and saveFileHeader.

GloveProxy* gadget::GloveGesture::mGloveProxy [protected]
 

Proxy to the glove.

Definition at line 117 of file GloveGesture.h.

Referenced by GloveGesture.


The documentation for this class was generated from the following files:
Generated on Sun May 2 14:26:59 2004 for Gadgeteer by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002