|
|
|
|
@ -170,7 +170,7 @@ int ImgCheckAnalysisy::GetStatus()
|
|
|
|
|
|
|
|
|
|
std::string ImgCheckAnalysisy::GetVersion()
|
|
|
|
|
{
|
|
|
|
|
return std::string("BOE_1.2.5_" + std::string(__DATE__) + "_" + std::string(__TIME__));
|
|
|
|
|
return std::string("BOE_1.2.7_" + std::string(__DATE__) + "_" + std::string(__TIME__));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string ImgCheckAnalysisy::GetErrorInfo()
|
|
|
|
|
@ -1451,6 +1451,9 @@ int ImgCheckAnalysisy::GetCheckResultBLob()
|
|
|
|
|
|
|
|
|
|
BLobToDetResult();
|
|
|
|
|
|
|
|
|
|
// 计算缺陷密度
|
|
|
|
|
CalBlobDensity_QX();
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -3359,6 +3362,7 @@ int ImgCheckAnalysisy::BLobToDetResult()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool bLD_Standard = false; // 是否通过LD标准判定(跳过UP/DP的IOU检查)
|
|
|
|
|
if (config_qx_type == CONFIG_QX_NAME_MTX ||
|
|
|
|
|
config_qx_type == CONFIG_QX_NAME_POL_Cell ||
|
|
|
|
|
config_qx_type == CONFIG_QX_NAME_Other ||
|
|
|
|
|
@ -3366,7 +3370,24 @@ int ImgCheckAnalysisy::BLobToDetResult()
|
|
|
|
|
{
|
|
|
|
|
qx_name = CONFIG_QX_NAME_Names[config_qx_type];
|
|
|
|
|
// m_TemCheck.AddCheckstr(PrintLevel_3, DET_LOG_LEVEL_3, "LD", "stsrt config_qx_type %s ", qx_name.c_str());
|
|
|
|
|
int dbresult = LDJudge(config_qx_type, roi, JudgArea, blobs.blobTab[i].maxValue, blobs.blobTab[i].grayDis, pQxlog);
|
|
|
|
|
int dbresult = -1;
|
|
|
|
|
if(m_pFuntion->function.f_LDConfig.bOpen && m_pFuntion->function.f_LDConfig.bUseLD_Standard)
|
|
|
|
|
{
|
|
|
|
|
if(blobs.blobTab[i].JudgArea >= m_pFuntion->function.f_LDConfig.fLD_Area &&
|
|
|
|
|
blobs.blobTab[i].grayDis >= m_pFuntion->function.f_LDConfig.fLD_HJ &&
|
|
|
|
|
blobs.blobTab[i].energy >= m_pFuntion->function.f_LDConfig.fLD_En &&
|
|
|
|
|
blobs.blobTab[i].len >= m_pFuntion->function.f_LDConfig.fLD_Len)
|
|
|
|
|
{
|
|
|
|
|
dbresult = 1;
|
|
|
|
|
bLD_Standard = true;
|
|
|
|
|
}
|
|
|
|
|
pQxlog->AddCheckstr(PrintLevel_3, DET_LOG_LEVEL_3, "LD Analysis", "Area %0.2f > %0.2f , hj %0.2f > %0.2f , Energy %0.2f > %0.2f , len %0.2f > %0.2f",
|
|
|
|
|
blobs.blobTab[i].JudgArea, m_pFuntion->function.f_LDConfig.fLD_Area, blobs.blobTab[i].grayDis, m_pFuntion->function.f_LDConfig.fLD_HJ, blobs.blobTab[i].energy, m_pFuntion->function.f_LDConfig.fLD_En, blobs.blobTab[i].len, m_pFuntion->function.f_LDConfig.fLD_Len);
|
|
|
|
|
}
|
|
|
|
|
if(dbresult != 1)
|
|
|
|
|
{
|
|
|
|
|
dbresult = LDJudge(config_qx_type, roi, JudgArea, blobs.blobTab[i].maxValue, blobs.blobTab[i].grayDis, pQxlog);
|
|
|
|
|
}
|
|
|
|
|
//int detre = 1;
|
|
|
|
|
// 表示L0 和 DP 都有的 亮的
|
|
|
|
|
if (dbresult == 1)
|
|
|
|
|
@ -3374,8 +3395,7 @@ int ImgCheckAnalysisy::BLobToDetResult()
|
|
|
|
|
config_qx_type = CONFIG_QX_NAME_LD;
|
|
|
|
|
qx_name = CONFIG_QX_NAME_Names[config_qx_type];
|
|
|
|
|
}
|
|
|
|
|
pQxlog->AddCheckstr(PrintLevel_2, DET_LOG_LEVEL_3, " LD Judge ", "%s qx %s ", Re_TO_STR_Pass_1(dbresult), qx_name.c_str());
|
|
|
|
|
}
|
|
|
|
|
pQxlog->AddCheckstr(PrintLevel_2, DET_LOG_LEVEL_3, " LD Judge ", "%s qx %s ", Re_TO_STR_Pass_1(dbresult), qx_name.c_str()); }
|
|
|
|
|
// 如果是chess 画面,缺陷类型直接是chess异常。
|
|
|
|
|
if (m_pFuntion->function.f_AIQX.bAllToChess)
|
|
|
|
|
{
|
|
|
|
|
@ -3436,8 +3456,8 @@ int ImgCheckAnalysisy::BLobToDetResult()
|
|
|
|
|
|
|
|
|
|
QX_Stauts qx_status = QX_Stauts_Analysis;
|
|
|
|
|
|
|
|
|
|
// 和UP画面进行IOU判断
|
|
|
|
|
if (m_pFuntion->function.f_UseUpQX.bOpen)
|
|
|
|
|
// 和UP画面进行IOU判断 (通过亮点标准的缺陷跳过此检查)
|
|
|
|
|
if (!bLD_Standard && m_pFuntion->function.f_UseUpQX.bOpen)
|
|
|
|
|
{
|
|
|
|
|
if (fupS >= m_pFuntion->function.f_UseUpQX.fIOU)
|
|
|
|
|
{
|
|
|
|
|
@ -3449,6 +3469,10 @@ int ImgCheckAnalysisy::BLobToDetResult()
|
|
|
|
|
pQxlog->AddCheckstr(PrintLevel_2, DET_LOG_LEVEL_3, "Up Mask judge", "UseUpQX.bOpen = true ;fupS = %0.2f < %02f ", fupS, m_pFuntion->function.f_UseUpQX.fIOU);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (bLD_Standard)
|
|
|
|
|
{
|
|
|
|
|
pQxlog->AddCheckstr(PrintLevel_2, DET_LOG_LEVEL_3, "Up Mask judge", "bLD_Standard = true, skip UP/DP IOU check ;fupS = %0.2f ", fupS);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pQxlog->AddCheckstr(PrintLevel_2, DET_LOG_LEVEL_3, "Up Mask judge", "UseUpQX.bOpen = false ;fupS = %0.2f ", fupS);
|
|
|
|
|
@ -3504,6 +3528,7 @@ int ImgCheckAnalysisy::BLobToDetResult()
|
|
|
|
|
temerror.grayDis = blobs.blobTab[i].grayDis;
|
|
|
|
|
temerror.density = blobs.blobTab[i].density;
|
|
|
|
|
temerror.fUpIou = fupS;
|
|
|
|
|
temerror.bIsStandardLD = bLD_Standard;
|
|
|
|
|
temerror.whiteOrBlack = blobs.blobTab[i].whiteOrblack;
|
|
|
|
|
temerror.qx_status = qx_status;
|
|
|
|
|
|
|
|
|
|
@ -3921,24 +3946,34 @@ int ImgCheckAnalysisy::AI_Classify_New(const cv::Mat &src_Img, cv::Rect qx_roi,
|
|
|
|
|
len = qx_roi.height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 长宽比过大,判断成
|
|
|
|
|
if (flenr > 18 &&
|
|
|
|
|
len > 70 &&
|
|
|
|
|
widt < 220 &&
|
|
|
|
|
fjustarea < 800)
|
|
|
|
|
{
|
|
|
|
|
// printf("\n\n\n\n\n\n\n\n\n--------- flenr %f len %d,widt %d,fjustarea %f\n", flenr,len,widt,fjustarea);
|
|
|
|
|
// getchar();
|
|
|
|
|
cls_num = AI_CLass_QX_NAME_line;
|
|
|
|
|
strclassName = "line";
|
|
|
|
|
bIsLine = true;
|
|
|
|
|
}
|
|
|
|
|
// 长宽比过小,判断成
|
|
|
|
|
else if (flenr > 4 &&
|
|
|
|
|
len > 180 &&
|
|
|
|
|
widt < 220 &&
|
|
|
|
|
fjustarea < 800 &&
|
|
|
|
|
fjustarea > 20)
|
|
|
|
|
// // 长宽比过大,判断成
|
|
|
|
|
// if (flenr > 18 &&
|
|
|
|
|
// len > 70 &&
|
|
|
|
|
// widt < 220 &&
|
|
|
|
|
// fjustarea < 800)
|
|
|
|
|
// {
|
|
|
|
|
// // printf("\n\n\n\n\n\n\n\n\n--------- flenr %f len %d,widt %d,fjustarea %f\n", flenr,len,widt,fjustarea);
|
|
|
|
|
// // getchar();
|
|
|
|
|
// cls_num = AI_CLass_QX_NAME_line;
|
|
|
|
|
// strclassName = "line";
|
|
|
|
|
// bIsLine = true;
|
|
|
|
|
// }
|
|
|
|
|
// // 长宽比过小,判断成
|
|
|
|
|
// else if (flenr > 4 &&
|
|
|
|
|
// len > 180 &&
|
|
|
|
|
// widt < 220 &&
|
|
|
|
|
// fjustarea < 800 &&
|
|
|
|
|
// fjustarea > 20)
|
|
|
|
|
// {
|
|
|
|
|
// // printf("\n\n\n\n\n\n\n\n\n--------- flenr %f len %d,widt %d,fjustarea %f\n", flenr,len,widt,fjustarea);
|
|
|
|
|
// // getchar();
|
|
|
|
|
// cls_num = AI_CLass_QX_NAME_line;
|
|
|
|
|
// strclassName = "line";
|
|
|
|
|
// bIsLine = true;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
//长宽比满足,判断为线
|
|
|
|
|
if (flenr > 10)
|
|
|
|
|
{
|
|
|
|
|
// printf("\n\n\n\n\n\n\n\n\n--------- flenr %f len %d,widt %d,fjustarea %f\n", flenr,len,widt,fjustarea);
|
|
|
|
|
// getchar();
|
|
|
|
|
@ -4456,4 +4491,105 @@ bool ImgCheckAnalysisy::JudgeQXAnalysis(int nqx_configType, std::shared_ptr<DetL
|
|
|
|
|
pQxlog->AddCheckstr(PrintLevel_3, DET_LOG_LEVEL_3, "Judge QX ", "det qx %s -> Funtion qx %s open = %s ", qx_name.c_str(), det_qx.c_str(), BOOL_TO_STR(re));
|
|
|
|
|
|
|
|
|
|
return re;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ImgCheckAnalysisy::CalBlobDensity_QX()
|
|
|
|
|
{
|
|
|
|
|
float fs_x = m_fImgage_Scale_X;
|
|
|
|
|
float fs_y = m_fImgage_Scale_Y;
|
|
|
|
|
double dis_T = m_pBasicConfig->density_R_mm;
|
|
|
|
|
if (dis_T <= 0 || dis_T > 99999)
|
|
|
|
|
{
|
|
|
|
|
dis_T = 5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!m_pDetResult || !m_pDetResult->pQx_ErrorList || m_pDetResult->pQx_ErrorList->size() <= 0)
|
|
|
|
|
{
|
|
|
|
|
m_pdetlog->AddCheckstr(PrintLevel_1, "Density_QX", "pQx_ErrorList is empty, skip density calc");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_pdetlog->AddCheckstr(PrintLevel_1, "Density_QX", "Start: dis_T=%.1fmm qx_count=%zu", dis_T, m_pDetResult->pQx_ErrorList->size());
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < m_pDetResult->pQx_ErrorList->size(); i++)
|
|
|
|
|
{
|
|
|
|
|
m_pDetResult->pQx_ErrorList->at(i).density = 1;
|
|
|
|
|
|
|
|
|
|
if (m_pDetResult->pQx_ErrorList->at(i).nconfig_qx_type == CONFIG_QX_NAME_MTX ||
|
|
|
|
|
m_pDetResult->pQx_ErrorList->at(i).nconfig_qx_type == CONFIG_QX_NAME_POL_Cell ||
|
|
|
|
|
m_pDetResult->pQx_ErrorList->at(i).nconfig_qx_type == CONFIG_QX_NAME_LD ||
|
|
|
|
|
m_pDetResult->pQx_ErrorList->at(i).nconfig_qx_type == CONFIG_QX_NAME_AD)
|
|
|
|
|
{
|
|
|
|
|
/* code */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cv::Rect roi = m_pDetResult->pQx_ErrorList->at(i).roi;
|
|
|
|
|
|
|
|
|
|
cv::Point p;
|
|
|
|
|
p.x = roi.x + roi.width * 0.5;
|
|
|
|
|
p.y = roi.y + roi.height * 0.5;
|
|
|
|
|
|
|
|
|
|
int num = 1;
|
|
|
|
|
double sum_dis = 0;
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < m_pDetResult->pQx_ErrorList->size(); j++)
|
|
|
|
|
{
|
|
|
|
|
if (i == j)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (m_pDetResult->pQx_ErrorList->at(j).nconfig_qx_type == CONFIG_QX_NAME_MTX ||
|
|
|
|
|
m_pDetResult->pQx_ErrorList->at(j).nconfig_qx_type == CONFIG_QX_NAME_POL_Cell ||
|
|
|
|
|
m_pDetResult->pQx_ErrorList->at(j).nconfig_qx_type == CONFIG_QX_NAME_LD ||
|
|
|
|
|
m_pDetResult->pQx_ErrorList->at(j).nconfig_qx_type == CONFIG_QX_NAME_AD)
|
|
|
|
|
{
|
|
|
|
|
/* code */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
cv::Rect roi123 = m_pDetResult->pQx_ErrorList->at(j).roi;
|
|
|
|
|
|
|
|
|
|
cv::Point p123;
|
|
|
|
|
p123.x = roi123.x + roi123.width * 0.5;
|
|
|
|
|
p123.y = roi123.y + roi123.height * 0.5;
|
|
|
|
|
|
|
|
|
|
double dis_x = std::abs(p123.x - p.x) * fs_x;
|
|
|
|
|
double dis_y = std::abs(p123.y - p.y) * fs_y;
|
|
|
|
|
double dis = std::sqrt(dis_x * dis_x + dis_y * dis_y);
|
|
|
|
|
if (dis > dis_T)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
num++;
|
|
|
|
|
sum_dis += dis;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float avdis = dis_T;
|
|
|
|
|
if (num > 1)
|
|
|
|
|
{
|
|
|
|
|
avdis = sum_dis / (num - 1);
|
|
|
|
|
}
|
|
|
|
|
float fScore = (dis_T - avdis) / dis_T;
|
|
|
|
|
|
|
|
|
|
double fD = num + fScore;
|
|
|
|
|
m_pDetResult->pQx_ErrorList->at(i).density = fD;
|
|
|
|
|
|
|
|
|
|
m_pdetlog->AddCheckstr(PrintLevel_2, "Density_QX", " idx=%d type=%d(%s) roi[%d,%d,%d,%d] near_num=%d avgDis=%.2f score=%.3f density=%.2f",
|
|
|
|
|
i,
|
|
|
|
|
m_pDetResult->pQx_ErrorList->at(i).nconfig_qx_type,
|
|
|
|
|
m_pDetResult->pQx_ErrorList->at(i).qx_name.c_str(),
|
|
|
|
|
roi.x, roi.y, roi.width, roi.height,
|
|
|
|
|
num, avdis, fScore, fD);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_pdetlog->AddCheckstr(PrintLevel_1, "Density_QX", "End: processed %zu defects", m_pDetResult->pQx_ErrorList->size());
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|