00001 #ifndef QUANTIZER_H 00002 #define QUANTIZER_H 00003 00004 #include <vector> 00005 #include <string> 00006 //#include "TimeSlot.h" 00007 00008 using namespace std; 00009 00010 namespace WiimoteGR{ 00011 00012 /* 00013 Wiimote acceleration data structures 00014 */ 00015 struct Acceleration{ 00016 double x,y,z; 00017 }; 00018 00019 struct Gesture{ 00020 string gestureName; 00021 vector<Acceleration> data; 00022 Gesture(const char* gestureName):gestureName(gestureName){ /* nothing */ } 00023 }; 00024 00025 struct TimeSlot; 00026 00027 /* 00028 Abstract base Quantizer 00029 Extend it and use it to construct a TimeSlot. 00030 */ 00031 class Quantizer{ 00032 public: 00033 const string name; 00034 const size_t M; //number of observation symbols 00035 00036 Quantizer(const char* name, size_t M):name(name),M(M) { /*nothing*/ } 00037 00038 virtual size_t Quantize(const Acceleration& acc) const = 0; 00039 virtual void Quantize(const Gesture& gesture, TimeSlot& symbolSeq) const; 00040 }; 00041 00042 /* 00043 Default quantizer 00044 */ 00045 class DefaultQuantizer : public Quantizer{ 00046 const double rho_threshold; 00047 public: 00048 DefaultQuantizer():Quantizer("M16Quantizer",16),rho_threshold(1.0) {/*nothing*/} 00049 00050 virtual size_t Quantize(const Acceleration& acc) const; 00051 00052 virtual void Quantize(const Gesture& gesture, TimeSlot& symbolSeq) const{ 00053 Quantizer::Quantize(gesture,symbolSeq); 00054 } 00055 }; 00056 00057 /* 00058 M32 quantizer 00059 */ 00060 class M32Quantizer : public Quantizer{ 00061 public: 00062 M32Quantizer():Quantizer("M32Quantizer",32) {/*nothing*/} 00063 00064 virtual size_t Quantize(const Acceleration& acc) const; 00065 00066 virtual void Quantize(const Gesture& gesture, TimeSlot& symbolSeq) const{ 00067 Quantizer::Quantize(gesture,symbolSeq); 00068 } 00069 }; 00070 00071 } 00072 00073 #endif