/* //实现对部分缺陷 需要进行 数量 和距离上分析的 */ #ifndef QX_Analysis_H_ #define QX_Analysis_H_ #include #include "CheckUtil.hpp" #include "CheckErrorCodeDefine.hpp" using namespace std; enum QX_ANALYSIS_NAME { QX_ANALYSIS_POL_CELL, // 异物 QX_ANALYSIS_AD, // 暗点 QX_ANALYSIS_Scratch, // 划伤 QX_ANALYSIS_LINE, // 线类 QX_ANALYSIS_MTX, // MTX QX_ANALYSIS_ALL, // MTX&异物 QX_ANALYSIS_COUNT, }; // 缺陷项对应在参数中的名称 static const std::string QX_ANALYSIS_NAME_Names[] = { "POL_Cell", "AD", "Scratch", "LINE", "MTX", "POL_Cell&MTX"}; // 记录缺陷信息 struct QX_Info { float area; // 面积 float energy; // 能量 float hj; // 灰阶 float length; // 长度 float density; // 密度 cv::Point plocatin_mm; // 位置,mm cv::Point plocatin_pixel; // 位置 像素 int blobIdx; // blob idx; int result; float fmindis; int nmindis_BlobIdx; cv::Point mindis_locatin_pixel; // 位置 像素 int nstatus; int nqx_type; QX_Info() { Init(); } void Init() { area = 0; energy = 0; hj = 0; length = 0; plocatin_mm = cv::Point(0, 0); plocatin_pixel = cv::Point(0, 0); blobIdx = 0; result = 0; fmindis = 0; mindis_locatin_pixel = cv::Point(0, 0); nstatus = 0; nqx_type = 0; nmindis_BlobIdx = 0; density = 0; } void print(std::string str) { printf("%s blobIdx %d,result %d area %f energy %f hj %f length %f md %f x %d y %d x %d y %d \n", str.c_str(), blobIdx, result, area, energy, hj, length, density, plocatin_mm.x, plocatin_mm.y, plocatin_pixel.x, plocatin_pixel.y); printf("%s blobIdx %d,fmindis %f mindis_locatin_pixel x %d y %d \n", str.c_str(), blobIdx, fmindis, mindis_locatin_pixel.x, mindis_locatin_pixel.y); } }; struct QX_ALL_List { std::vector qxList; QX_ALL_List() { Init(); } void Init() { qxList.erase(qxList.begin(), qxList.end()); qxList.clear(); // config.Init(); } }; struct QXAnalysis_Config { bool bok; int num; float dis; float len; int hj; float density; float area; float sum_area; QXAnalysis_Config() { Init(); } void Init() { bok = false; num = 0; dis = 0; len = 0; area = 0; hj = 0; sum_area = 0; density = 0; } void print(std::string str) { printf("%s bok %d num %d area %f dis %f len %f hj %d md %f\n", str.c_str(), bok, num, area, dis, len, hj,density); } }; struct QX_Config_List { std::vector configlsit; QX_Config_List() { Init(); } void Init() { configlsit.erase(configlsit.begin(), configlsit.end()); configlsit.clear(); // config.Init(); } }; enum QX_ERROR_TYPE_ { QX_ERROR_TYPE_OK, QX_ERROR_TYPE_AREA, QX_ERROR_TYPE_NUM, QX_ERROR_TYPE_DIS, QX_ERROR_TYPE_Len, QX_ERROR_TYPE_NUM_RGB255, }; struct QX_RESULT { int blobIdx; // blob idx; int error_Type; // 错误原因 int qx_Num; // 缺陷的数量 float mindis; float flen; cv::Point qx_MisDis_point_pixel; // 缺陷 间的最小距离 QX_RESULT() { Init(); } void Init() { blobIdx = -1; error_Type = 0; qx_Num = 0; flen = 0; mindis = 0; qx_MisDis_point_pixel = cv::Point(0, 0); } void print(std::string str) { printf("%s blobIdx %d error_Type %d qx_Num %d min dis %f flen %f x %d y %d \n", str.c_str(), blobIdx, error_Type, qx_Num, mindis, flen, qx_MisDis_point_pixel.x, qx_MisDis_point_pixel.y); } }; struct QX_Analysis_Result_List { std::vector resultList; QX_Analysis_Result_List() { Init(); } void Init() { resultList.erase(resultList.begin(), resultList.end()); resultList.clear(); // config.Init(); } }; class QX_Analysis { private: QX_ALL_List m_QXList[QX_ANALYSIS_COUNT]; QX_Config_List m_ConfigList[QX_ANALYSIS_COUNT]; QX_Analysis_Result_List m_reultList; public: CHECK_TEM_RESULT *m_pTemCheck; public: QX_Analysis(); ~QX_Analysis(); void SetConfig(int qxidx, QXAnalysis_Config config); void InitConfig(); bool AddQxInfo(int qxidx, QX_Info qxinfo); int Init(); int GetReusult(QX_Analysis_Result_List *&presult); private: bool Idx(int qxidx); int Analysis(QX_Config_List *pconfigList, QX_ALL_List *pqxList,int qx_type); int Analysis_s(QXAnalysis_Config *pconfig, QX_ALL_List *pqxList,int qx_type); int Analysis_AD_Num(QXAnalysis_Config *pconfig, QX_ALL_List *pqxList,int qx_type); int Analysis_POL_Num(QXAnalysis_Config *pconfig, QX_ALL_List *pqxList,int qx_type); }; #endif