1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #pragma once
- #include <opencv2/opencv.hpp>
- #include <opencv2/xfeatures2d.hpp>
- #include "schema_struct.h"
- #include <vector>
- #include <boost/smart_ptr.hpp>
- #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<const ISCH_Schema> 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_ptr<const ISCH_Schema>schemaPages;
- //防射变换(由模板变换到图像)
- Mat m_AffineTransform;
- //防射变换逆变换矩阵(由图像变换到模板)
- Mat m_AffineTransformInverseMatrix;
- double m_Scaler0;//存储当前页的缩放率
- int m_pageDirection;//存储当前识别页的旋转方向
- private:
- template<typename T1, typename T2 > double GetDistance(T1 point1, T2 point2);
- template<typename T1, typename T2> 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<CvPoint2D32f> &relationKey, vector<CvPoint2D32f>& relationValue, vector<int> &relationIndex, int first_index);
- //查找模糊定位区定位信息
- int FindLoacteByLocateArea(const IplImage * img, const identify::schema::ISCH_SCHEMA_PAGE& schemaPage, const double estimate_scale, const int rotation, vector<CvPoint2D32f>& relationKey, vector<CvPoint2D32f>& relationValue, vector<int> &relationIndex, int first_index);
- //查找交叉点定位信息
- int FindLoacteByLocateCross(const IplImage * img, const identify::schema::ISCH_SCHEMA_PAGE& schemaPage, const double estimate_scale, const int rotation, vector<CvPoint2D32f>& relationKey, vector<CvPoint2D32f>& relationValue, vector<int> &relationIndex, int first_index);
- //匹配
- int ConfirmLocateInfo(vector<CvPoint2D32f>& relationKey, vector<CvPoint2D32f>& relationValue, int& inliner_count, cv::Mat& _inliner);
- //按照指定模板进行识别
- int Identifi(const IplImage * src, int shemaIndex, MATCH_REUSLT& match_result);
- };
- }
|