GestureRecognition/stlrecogniserinterface.h

Go to the documentation of this file.
00001 /*  -*- c++ -*-  (for Emacs)
00002  *
00003  *  stlrecogniserinterface.h
00004  *  Digest
00005  * 
00006  *  Created by Aidan Lane on Tue Jan 17 2006.
00007  *  Copyright (c) 2006 Optimisation and Constraint Solving Group,
00008  *  Monash University. All rights reserved.
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License
00021  *  along with this program; if not, write to the Free Software
00022  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00023  */
00024 
00025 #ifndef STLRECOGNISERINTERFACE_H
00026 #define STLRECOGNISERINTERFACE_H
00027 
00028 
00029 #include <algorithm> // for std::copy
00030 #include <list>
00031 #include <map>
00032 #include <set>
00033 #include <string>
00034 
00035 #include "stlrecognitioncommon.h"
00036 
00037 
00038 #ifndef DECLARE_STL_RECOGNISER_KEY(KEY)
00039 #define DECLARE_STL_RECOGNISER_KEY(KEY)                         \
00040   static const std::string& classKey() {                        \
00041     static const std::string str(KEY);                          \
00042     return str;                                                 \
00043   }                                                             \
00044   virtual const std::string& key() const { return classKey(); }
00045 #endif
00046 
00047 #ifndef DECLARE_STL_RECOGNISER_TITLE(TITLE)
00048 #define DECLARE_STL_RECOGNISER_TITLE(TITLE)                             \
00049   static const std::string& classTitle() {                              \
00050     static const std::string str(TITLE);                                \
00051     return str;                                                         \
00052   }                                                                     \
00053   virtual const std::string& title() const { return classTitle(); }
00054 #endif
00055 
00056 #ifndef DECLARE_STL_RECOGNISER_DESCRIPTION(DESCRIPTION)
00057 #define DECLARE_STL_RECOGNISER_DESCRIPTION(DESCRIPTION)                 \
00058   static const std::string& classDescription() {                        \
00059     static const std::string str(DESCRIPTION);                          \
00060     return str;                                                         \
00061   }                                                                     \
00062   virtual const std::string& description() const { return classDescription(); }
00063 #endif
00064 
00065 
00066 
00076 class StlRecogniserInterface {
00077 
00078 public:
00079   virtual ~StlRecogniserInterface() {}
00080 
00081   virtual const std::string& key() const = 0;
00082   virtual const std::string& title() const = 0;
00083   virtual const std::string& description() const = 0;
00084 
00085   virtual const std::map<std::string, std::string>& defaultParams() const = 0;
00086 
00087   virtual bool initTraining( const std::list<std::string>& featureKeys,
00088                              const std::map<std::string, std::string>& params ) = 0;
00089   virtual bool examineSample( const StlFeatureVec& featureVec,
00090                               const std::set<int>& classes ) = 0;
00091   virtual bool finaliseTraining() = 0;
00092 
00093   virtual bool writeModelFile( const std::string& fileName ) = 0;
00094   virtual bool readModelFile( const std::string& fileName ) = 0;
00095 
00096   virtual StlStroke flatten( const StlStrokeList& strokes ) {
00097     StlStroke stroke;
00098     StlStrokeList::const_iterator it = strokes.begin();
00099     while ( it != strokes.end() ) {
00100       std::copy( (*it).begin(), (*it).end(), back_inserter(stroke) );
00101       ++it;
00102     }
00103     return stroke;
00104   }
00105 
00106   virtual StlClassProbabilities classify( const StlFeatureVec& featureVec ) = 0;
00107 };
00108 
00109 
00130 #endif  // ! STLRECOGNISERINTERFACE_H

Generated on Mon Jul 30 09:46:50 2007 for Digest by  doxygen 1.5.2