|
|
|
|
@ -1344,6 +1344,30 @@ int ImgCheckAnalysisy::CheckRun()
|
|
|
|
|
{
|
|
|
|
|
m_tag_roiList.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 标签能量/灰阶差(hj)计算用掩膜:所有标签区域填白(与 blob 检测用 AIMaskImg 的口径一致),
|
|
|
|
|
// 由 calc_blob_info_withstats 按“前景=标签区域、背景=外扩一圈”计算
|
|
|
|
|
long tagEnergy_s = CheckUtil::getcurTime();
|
|
|
|
|
cv::Mat tagMask;
|
|
|
|
|
if (!m_tag_roiList.empty() && !m_pImageAllResult->detImg.empty())
|
|
|
|
|
{
|
|
|
|
|
tagMask = cv::Mat::zeros(m_pImageAllResult->detImg.size(), CV_8UC1);
|
|
|
|
|
std::vector<std::vector<cv::Point>> tagPolys;
|
|
|
|
|
tagPolys.reserve(m_tag_roiList.size());
|
|
|
|
|
for (const auto &tagRoiMask : m_tag_roiList)
|
|
|
|
|
{
|
|
|
|
|
cv::Point2f ptfMask[4];
|
|
|
|
|
tagRoiMask.points(ptfMask);
|
|
|
|
|
std::vector<cv::Point> polyMask(4);
|
|
|
|
|
for (int k = 0; k < 4; k++)
|
|
|
|
|
{
|
|
|
|
|
polyMask[k] = cv::Point(cvRound(ptfMask[k].x), cvRound(ptfMask[k].y));
|
|
|
|
|
}
|
|
|
|
|
tagPolys.push_back(std::move(polyMask));
|
|
|
|
|
}
|
|
|
|
|
cv::fillPoly(tagMask, tagPolys, cv::Scalar(255));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const auto &tagRoi : m_tag_roiList)
|
|
|
|
|
{
|
|
|
|
|
// tag roi 在原图坐标系,按坐标映射转换到检测图(detImg)坐标系
|
|
|
|
|
@ -1365,6 +1389,16 @@ int ImgCheckAnalysisy::CheckRun()
|
|
|
|
|
float th = tagRoi.size.height;
|
|
|
|
|
temerror.flen = (tw > th ? tw : th) * m_fImgage_Scale_X;
|
|
|
|
|
temerror.fbreadth = (tw > th ? th : tw) * m_fImgage_Scale_Y;
|
|
|
|
|
|
|
|
|
|
// 标签区域的能量/灰阶差(hj):与 blob 检测相同口径(前景=标签区域,背景=外扩一圈)
|
|
|
|
|
if (!tagMask.empty())
|
|
|
|
|
{
|
|
|
|
|
cv::Rect roiStat = roi;
|
|
|
|
|
cv::Scalar tagStat = calc_blob_info_withstats(m_pImageAllResult->detImg, tagMask, roiStat);
|
|
|
|
|
temerror.energy = (int)tagStat[1];
|
|
|
|
|
temerror.grayDis = (float)tagStat[2];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
temerror.nconfig_qx_type = CONFIG_QX_NAME_cell_TBBQ;
|
|
|
|
|
temerror.qx_name = CONFIG_QX_NAME_Names[CONFIG_QX_NAME_cell_TBBQ];
|
|
|
|
|
temerror.result = QX_RESULT_TYPE_NG;
|
|
|
|
|
@ -1389,7 +1423,13 @@ int ImgCheckAnalysisy::CheckRun()
|
|
|
|
|
|
|
|
|
|
m_pDetResult->pQx_ErrorList->push_back(temerror);
|
|
|
|
|
|
|
|
|
|
m_pdetlog->AddCheckstr(PrintLevel_0, "Tag检测", "tag %d roi [%d %d %d %d] -> NG", temerror.Idx, roi.x, roi.y, roi.width, roi.height);
|
|
|
|
|
m_pdetlog->AddCheckstr(PrintLevel_0, "Tag检测", "tag %d roi [%d %d %d %d] energy %d hj %.1f -> NG",
|
|
|
|
|
temerror.Idx, roi.x, roi.y, roi.width, roi.height, temerror.energy, temerror.grayDis);
|
|
|
|
|
}
|
|
|
|
|
if (!m_tag_roiList.empty())
|
|
|
|
|
{
|
|
|
|
|
long tagEnergy_e = CheckUtil::getcurTime();
|
|
|
|
|
m_pdetlog->AddCheckstr(PrintLevel_1, DET_LOG_LEVEL_3, "Tag", "tag energy calc use time %ld", tagEnergy_e - tagEnergy_s);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|