00001 #ifndef HMMMODULE_H 00002 #define HMMMODULE_H 00003 00004 #include "ProcessModule.h" 00005 #include "../framedata/IFrameData.h" 00006 #include "../classification/KMeanCluster.h" 00007 #include "../classification/LeftToRightHMM.h" 00008 #include "../util/ConfigManager.h" 00009 #include <vector> 00010 #include <list> 00011 #include <utility> 00012 00014 00019 class HMMModule : public ProcessModule 00020 { 00021 public: 00025 HMMModule(AbstractModule *successor); 00026 00028 virtual ~HMMModule(); 00029 00036 virtual void processFrameData(IFrameData *data); 00037 00044 int addGesture(int nClusters, int nStates); 00045 00050 void delGesture(size_t gestureID); 00051 00055 void clearGestures(); 00056 00061 void trainGesture(size_t gestureID); 00062 00064 void stopTraining(); 00065 00073 bool serializeGesture(ConfigManager &gestureFile, std::string gestureName, int gestureId); 00074 00081 bool deserializeGesture(ConfigSection §ion, std::string gestureName); 00082 00083 private: 00084 typedef std::pair<KMeanCluster*, LeftToRightHMM*> EvalPair; 00085 typedef std::vector<EvalPair> Evaluators; 00086 typedef std::list<Vector3d> Gesture; 00087 00088 void classifyRecordedGesture(); 00089 void trainRecordedGesture(); 00090 00091 void addGesure(KMeanCluster *clusterizer, LeftToRightHMM *hmm); 00092 00093 Evaluators m_gestureClassificators; 00094 bool m_hasGestureStarted; 00095 Gesture m_gesture; 00096 00097 size_t m_trainGestureID; 00098 }; 00099 00100 #endif