#pragma once #include "stdafx.h" #include #include #include #include #include #include "schema_struct.h" #ifdef IDENTIFIER_EXPORTS #define IDENTIFIER_API __declspec(dllexport) #else #define IDENTIFIER_API __declspec(dllimport) #endif using namespace identify::schema; struct CvCross{ int sign; int x; int y; int arg; }; enum SIGND{ SIGND_TL = DIR_FLAG_UP | DIR_FLAG_LEFT, SIGND_TR = DIR_FLAG_UP | DIR_FLAG_RIGHT, SIGND_TLR = DIR_FLAG_UP | DIR_FLAG_LEFT | DIR_FLAG_RIGHT, SIGND_BL = DIR_FLAG_DOWN | DIR_FLAG_LEFT, SIGND_BR = DIR_FLAG_DOWN | DIR_FLAG_RIGHT, SIGND_BLR = DIR_FLAG_DOWN | DIR_FLAG_LEFT | DIR_FLAG_RIGHT, SIGND_TBL = DIR_FLAG_UP | DIR_FLAG_DOWN | DIR_FLAG_LEFT, SIGND_TBR = DIR_FLAG_UP | DIR_FLAG_DOWN | DIR_FLAG_RIGHT, SIGND_TBLR = DIR_FLAG_UP | DIR_FLAG_DOWN | DIR_FLAG_LEFT | DIR_FLAG_RIGHT, }; class IDENTIFIER_API CCrossDetector { private: struct SIGN { int x; int y; SIGND sign; }; public: CCrossDetector(int unit_count = 15, double angle = 0, double angle_unit = 0.5, int cross_break = 4, int cross_burr = 15, int grayvalve = 180, int cross_len = 20, int cross_percent = 80); ~CCrossDetector(void); int Detect(const IplImage*img, std::vector&cross); private: bool isSign(const IplImage * img_binary, int x, int y, SIGN &sign_); bool isSignPossable(const IplImage * img_binary, int x, int y); private: double * dx[4]; double * dy[4]; int unit_count; double angle_unit; double angle; int total_angle_count; std::vector arglist_t; std::vector buffer_t; double* buffer; int* arglist; struct{ //灰度阀值 int m_CrossGray; //检测范围 int m_CrossArg; //交叉点的长度 int m_CrossLen; //最大断点长度 int m_CrossBreak; //毛刺 int m_CrossBurr; //周围空白百分比 int m_CrossPercent; }options; };