#pragma once #include #include #include "schema_struct.h" #include #include #ifdef IDENTIFIER_EXPORTS #define IDENTIFIER_API __declspec(dllexport) #else #define IDENTIFIER_API __declspec(dllimport) #endif using namespace std; using namespace cv::xfeatures2d; using namespace identify::result; using namespace identify::schema; using namespace identify::analysis; namespace identify{ class IDENTIFIER_API CPageMatcher { public: CPageMatcher(void); ~CPageMatcher(void); //设置模板信息 void SetSchemaPages(boost::shared_ptr schema); //识别指定图像 int Identify(const IplImage* img, MATCH_REUSLT & match_result); //旋转指定角度后按照指定模板进行识别 int Identifi(const IplImage * src, int shemaIndex, const int rotation, MATCH_REUSLT& result); private: //模板 boost::shared_ptrschemaPages; //防射变换(由模板变换到图像) Mat m_AffineTransform; //防射变换逆变换矩阵(由图像变换到模板) Mat m_AffineTransformInverseMatrix; double m_Scaler0;//存储当前页的缩放率 int m_pageDirection;//存储当前识别页的旋转方向 private: template double GetDistance(T1 point1, T2 point2); template T2 warpAffinePoint(T1& src, Mat * map_matrix); /************************************************************************/ /*图像基本信息检查,最小宽高限制,长宽比例限制 */ /************************************************************************/ inline int BaseCheck(const IplImage * src, const identify::schema::ISCH_SCHEMA_PAGE& schemaPage); //查找定位点定位信息 int FindLoacteByLocatePoint(const IplImage * img, const identify::schema::ISCH_SCHEMA_PAGE& schemaPage, const double estimate_scale, const int rotation, vector &relationKey, vector& relationValue, vector &relationIndex, int first_index); //查找模糊定位区定位信息 int FindLoacteByLocateArea(const IplImage * img, const identify::schema::ISCH_SCHEMA_PAGE& schemaPage, const double estimate_scale, const int rotation, vector& relationKey, vector& relationValue, vector &relationIndex, int first_index); //查找交叉点定位信息 int FindLoacteByLocateCross(const IplImage * img, const identify::schema::ISCH_SCHEMA_PAGE& schemaPage, const double estimate_scale, const int rotation, vector& relationKey, vector& relationValue, vector &relationIndex, int first_index); //匹配 int ConfirmLocateInfo(vector& relationKey, vector& relationValue, int& inliner_count, cv::Mat& _inliner); //按照指定模板进行识别 int Identifi(const IplImage * src, int shemaIndex, MATCH_REUSLT& match_result); }; }