feat 添加混料判断

dev_lsy
liusiyang 3 weeks ago
parent fe9fdcd781
commit 2ce4bf4f17

@ -648,6 +648,12 @@ int ImgCheckAnalysisy::CheckRun()
float aouter = CheckUtil::getLongAxisAngle(m_outer_rroi);
float ainner = CheckUtil::getLongAxisAngle(m_inner_rroi);
// 计算内边缘宽高与标准差值
float dinnerLen = std::abs(m_inner_rroi.size.width - m_pbaseCheckFunction->ALign_Config.len) * m_fImgage_Scale_X;
float dinnerWidth = std::abs(m_inner_rroi.size.height - m_pbaseCheckFunction->ALign_Config.width) * m_fImgage_Scale_Y;
bool bSizeerr = (dinnerLen > m_pbaseCheckFunction->ALign_Config.len_diff || dinnerWidth > m_pbaseCheckFunction->ALign_Config.width_diff);
float diff_align = std::fabs(aouter - ainner);
diff_align = std::fmod(diff_align, 180.0f); // 模 180 度
@ -665,31 +671,31 @@ int ImgCheckAnalysisy::CheckRun()
}
// 2. 使用 ALign_Config.x_offset / y_offset (mm) 卡控内外边缘中心偏移(mm 转像素)
float offX_px = 0.0f;
float offY_px = 0.0f;
float offX_mm = 0.0f;
float offY_mm = 0.0f;
if (m_pbaseCheckFunction != NULL)
{
if (m_fImgage_Scale_X > 0.0f)
{
offX_px = m_pbaseCheckFunction->ALign_Config.x_offset / m_fImgage_Scale_X;
offX_mm = m_pbaseCheckFunction->ALign_Config.x_offset;
}
if (m_fImgage_Scale_Y > 0.0f)
{
offY_px = m_pbaseCheckFunction->ALign_Config.y_offset / m_fImgage_Scale_Y;
offY_mm = m_pbaseCheckFunction->ALign_Config.y_offset;
}
}
// 3. 内外边缘中心坐标偏移(像素)
float dx_px = std::fabs(m_outer_rroi.center.x - m_inner_rroi.center.x);
float dy_px = std::fabs(m_outer_rroi.center.y - m_inner_rroi.center.y);
float dx_mm = std::fabs(m_outer_rroi.center.x - m_inner_rroi.center.x) * m_fImgage_Scale_X;
float dy_mm = std::fabs(m_outer_rroi.center.y - m_inner_rroi.center.y) * m_fImgage_Scale_Y;
bool bAngleErr = diff_align > angleTh;
bool bOffsetXErr = (offX_px > 0.0f) && (dx_px > offX_px);
bool bOffsetYErr = (offY_px > 0.0f) && (dy_px > offY_px);
bool bOffsetXErr = (offX_mm > 0.0f) && (dx_mm > offX_mm);
bool bOffsetYErr = (offY_mm > 0.0f) && (dy_mm > offY_mm);
bool bOffsetErr = bOffsetXErr || bOffsetYErr;
// 角度超差或中心偏移超差 -> 添加到缺陷列表
if (bAngleErr || bOffsetErr)
if (bAngleErr || bOffsetErr || bSizeerr)
{
QX_ERROR_INFO_ alignErr;
alignErr.Idx = static_cast<int>(m_pDetResult->pQx_ErrorList->size());
@ -703,8 +709,8 @@ int ImgCheckAnalysisy::CheckRun()
alignErr.fbreadth = tplRect.height * m_fImgage_Scale_Y;
// 缺陷列表中原 other(其他)已移除;内外边缘对齐超差暂按 C型卡口异常 上报(待确认)
alignErr.nconfig_qx_type = CONFIG_QX_NAME_C_BianXing;
alignErr.qx_name = CONFIG_QX_NAME_Names[CONFIG_QX_NAME_C_BianXing];
alignErr.nconfig_qx_type = CONFIG_QX_NAME_HunLiao;
alignErr.qx_name = CONFIG_QX_NAME_Names[CONFIG_QX_NAME_HunLiao];
alignErr.grayDis = diff_align; // 记录内外边缘夹角(度)
alignErr.detRegionidxList.push_back(0);
@ -718,13 +724,18 @@ int ImgCheckAnalysisy::CheckRun()
}
if (bOffsetXErr)
{
m_pdetlog->AddCheckstr(PrintLevel_0, "Align Check", "center offset dx %.1f px > %.1f px",
dx_px, offX_px);
m_pdetlog->AddCheckstr(PrintLevel_0, "Align Check", "center offset dx %.1f mm > %.1f mm",
dx_mm, offX_mm);
}
if (bOffsetYErr)
{
m_pdetlog->AddCheckstr(PrintLevel_0, "Align Check", "center offset dy %.1f px > %.1f px",
dy_px, offY_px);
m_pdetlog->AddCheckstr(PrintLevel_0, "Align Check", "center offset dy %.1f mm > %.1f mm",
dy_mm, offY_mm);
}
if (bSizeerr)
{
m_pdetlog->AddCheckstr(PrintLevel_0, "Align Check", "inner size diff len %.1f mm, width %.1f mm > threshold",
dinnerLen, dinnerWidth);
}
}

@ -44,6 +44,7 @@ enum CONFIG_QX_NAME_
CONFIG_QX_NAME_BTB_DuanLie, // 分类 BTB断裂
CONFIG_QX_NAME_LianXi, // 分类 连锡
CONFIG_QX_NAME_QueXi, // 分类 缺锡
CONFIG_QX_NAME_HunLiao, // 分类 混料
CONFIG_QX_NAME_YiWu, // 分类 异物
CONFIG_QX_NAME_C_BianXing, // 分类 C型卡口异常
CONFIG_QX_NAME_PIN_PianYi, // 分类 PIN偏移
@ -1019,6 +1020,10 @@ struct Base_Function_ALign
float angle_diff;
float x_offset;
float y_offset;
float len;
float width;
float len_diff;
float width_diff;
Base_Function_ALign()
@ -1031,6 +1036,10 @@ struct Base_Function_ALign
angle_diff = 0.0;
x_offset = 0.0;
y_offset = 0.0;
len = 0.0;
width = 0.0;
len_diff = 0.0;
width_diff = 0.0;
}
void copy(Base_Function_ALign tem)
@ -1039,17 +1048,21 @@ struct Base_Function_ALign
this->angle_diff = tem.angle_diff;
this->x_offset = tem.x_offset;
this->y_offset = tem.y_offset;
this->len = tem.len;
this->width = tem.width;
this->len_diff = tem.len_diff;
this->width_diff = tem.width_diff;
}
void print(std::string str)
{
printf("%s>>bOpen %d angle_diff %f x_offset %f y_offset %f \n", str.c_str(),
bOpen, angle_diff, x_offset, y_offset);
printf("%s>>bOpen %d angle_diff %f x_offset %f y_offset %f len %f width %f len_diff %f width_diff %f\n", str.c_str(),
bOpen, angle_diff, x_offset, y_offset, len, width, len_diff, width_diff);
}
std::string GetInfo(std::string str)
{
char buffer[256];
sprintf(buffer, "%s>>bOpen %d angle_diff %f x_offset %f y_offset %f \n", str.c_str(),
bOpen, angle_diff, x_offset, y_offset);
sprintf(buffer, "%s>>bOpen %d angle_diff %f x_offset %f y_offset %f len %f width %f len_diff %f width_diff %f\n", str.c_str(),
bOpen, angle_diff, x_offset, y_offset, len, width, len_diff, width_diff);
std::string str123 = buffer;
return str123;
}

@ -790,6 +790,23 @@ int BaseFuntonConfigJson::GetFunction(Json::Value value)
{
_config.ALign_Config.y_offset = value_f["form"]["ALign_Config"]["y_offset"].asFloat();
}
if (value_f["form"]["ALign_Config"]["len"])
{
_config.ALign_Config.len = value_f["form"]["ALign_Config"]["len"].asFloat();
}
if (value_f["form"]["ALign_Config"]["width"])
{
_config.ALign_Config.width = value_f["form"]["ALign_Config"]["width"].asFloat();
}
if (value_f["form"]["ALign_Config"]["len_diff"])
{
_config.ALign_Config.len_diff = value_f["form"]["ALign_Config"]["len_diff"].asFloat();
}
if (value_f["form"]["ALign_Config"]["width_diff"])
{
_config.ALign_Config.width_diff = value_f["form"]["ALign_Config"]["width_diff"].asFloat();
}
}
else
{

Loading…
Cancel
Save