#ifndef SHWR_H #define SHWR_H #include #include namespace shwr { struct ModelHeader { char sign[4]; char lang[6]; short ver; short type; short width; short height; short pointdist; int count; }; struct FeatureHeader { char word[4]; int strokecount; int count; }; struct Feature { int strokecount; std::string word; std::vector feature; }; struct Point { Point(int xv, int yv) : x(xv), y(yv) {} int x; int y; }; struct Word { std::string word; int dist; }; class Stroke { public: Stroke(); int add(int x, int y); void fill(); void thin(int pointdist); void resize(int aw, int bw, int ah, int bh); void move(int dx, int dy); std::vector * points(); private: std::vector m_points; }; class Character { public: Character(); int add(int idx, int x, int y); void fullpoints(bool full); void fillstrokes(); void fill(); void thin(); void resize(int aw, int bw, int ah, int bh); void move(int dx, int dy); void rect(int* x, int* y, int* w, int* h); int feature(std::vector * featurelist); int strokecount(); void pointdist(int dist); void print(); private: int m_lastidx; int m_mindist; int m_strokecount; bool m_fullpoints; std::vector m_strokes; }; class Recognizer { public: Recognizer(); int ver(); int type(); int width(); int height(); int pointdist(); int modelsize(); std::string lang(); bool ready(); int init(const std::string& modelfile); int feature(const std::string& word, std::vector< std::vector > * featurelists); int recognize(Character* cha, std::vector * words, int maxcount = 10, int dynstroke = 2); int recognize(Character* cha, std::vector * words, int maxcount = 10, int dynstroke = 2); private: int m_ver; int m_type; int m_width; int m_height; int m_pointdist; std::string m_lang; std::vector m_features; }; } #endif // SHWR_H