You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
2.1 KiB
101 lines
2.1 KiB
/*
|
|
//实现对部分缺陷 需要进行 数量 和距离上分析的
|
|
*/
|
|
#ifndef AI_Second_Det_H_
|
|
#define AI_Second_Det_H_
|
|
#include <opencv2/opencv.hpp>
|
|
#include "CheckUtil.hpp"
|
|
#include "OtherDetect.h"
|
|
#include "OtherDetBaseDefine.h"
|
|
#include "CheckErrorCodeDefine.hpp"
|
|
#include "ImageDetConfig.h"
|
|
#include "CheckConfigDefine.h"
|
|
#include "ImageStorage.h"
|
|
#include "AI_Factory.h"
|
|
|
|
using namespace std;
|
|
using namespace cv;
|
|
|
|
// 二次分割求面积
|
|
class AI_SecondDet : public AIDetectBase
|
|
{
|
|
public:
|
|
// 检测参数和结果
|
|
struct DetConfigResult
|
|
{
|
|
Function_SecondDet *pfunction_secondDet;
|
|
float fImgage_Scale_X;
|
|
float fImgage_Scale_Y;
|
|
float min_DetArea;
|
|
cv::Rect qx_roi;
|
|
int qx_type;
|
|
std::string qx_name;
|
|
int old_Area;
|
|
float old_len;
|
|
int new_Area;
|
|
float new_len;
|
|
int nresult;
|
|
std::string strChannel;
|
|
std::shared_ptr<DetLog> pdetlog; // 检测日志
|
|
|
|
DetConfigResult()
|
|
{
|
|
qx_roi = cv::Rect(0, 0, 0, 0);
|
|
qx_type = 0;
|
|
min_DetArea = 0;
|
|
qx_name = "";
|
|
old_Area = 0;
|
|
old_len = 0;
|
|
new_Area = 0;
|
|
new_len = 0;
|
|
nresult = 0;
|
|
pfunction_secondDet = NULL;
|
|
strChannel = "";
|
|
fImgage_Scale_X = 0.0333;
|
|
fImgage_Scale_Y = 0.0333;
|
|
}
|
|
void SetAreaAndLen(int oldArea, float oldLen)
|
|
{
|
|
old_Area = oldArea;
|
|
old_len = oldLen;
|
|
new_Area = old_Area;
|
|
new_len = old_len;
|
|
}
|
|
};
|
|
|
|
public:
|
|
AI_SecondDet(/* args */);
|
|
~AI_SecondDet();
|
|
int Detect(const cv::Mat &img, const cv::Mat &mask, DetConfigResult *pDetConfig);
|
|
|
|
private:
|
|
|
|
cv::Rect GetCutRoi(cv::Rect &roi, const cv::Mat &img);
|
|
|
|
int Det_Pol(const cv::Mat &img, DetConfigResult *pDetConfig);
|
|
int Det_AD(const cv::Mat &img, DetConfigResult *pDetConfig);
|
|
|
|
// 分析结果
|
|
int Analysisy(const cv::Mat &maskImg, DetConfigResult *pDetConfig);
|
|
|
|
// 存储过程图片
|
|
int SaveProcessImg(const cv::Mat &inImg, const cv::Mat &outImg, const cv::Mat &oldmask, DetConfigResult *pDetConfig);
|
|
|
|
private:
|
|
bool m_bModelSucc_AD;
|
|
bool m_bModelSucc_POL;
|
|
cv::Mat detimg123;
|
|
ImageStorage *m_pImageStorage;
|
|
std::shared_ptr<AIFactory> AI_Factory;
|
|
|
|
int m_Show_Area;
|
|
float m_Show_Len;
|
|
cv::Point m_Len_P1;
|
|
cv::Point m_Len_P2;
|
|
std::shared_ptr<DetLog> m_pdetlog;
|
|
|
|
private:
|
|
/* data */
|
|
};
|
|
|
|
#endif |