|
|
|
|
@ -529,19 +529,20 @@ int ImgCheckAnalysisy::CheckRun()
|
|
|
|
|
m_pdetlog->AddCheckstr(PrintLevel_0, "4、BQ Detect", "-------------------------BQ AI Detect--------%ld ms-------\n", t_BQ_e - t_BQ_s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef SAVE_RESIMG
|
|
|
|
|
m_CheckResult_shareP->resultMaskImg = m_pImageAllResult->qx_DetAIResult->AI_MaskImg;
|
|
|
|
|
|
|
|
|
|
// 将BQ标签的AI mask合并到结果mask中
|
|
|
|
|
if (m_pImageAllResult->bq_DetAIResult && !m_pImageAllResult->bq_DetAIResult->AI_MaskImg.empty())
|
|
|
|
|
if (NeedDrawAndSave())
|
|
|
|
|
{
|
|
|
|
|
cv::Mat &bqMask = m_pImageAllResult->bq_DetAIResult->AI_MaskImg;
|
|
|
|
|
if (bqMask.size() == m_CheckResult_shareP->resultMaskImg.size())
|
|
|
|
|
m_CheckResult_shareP->resultMaskImg = m_pImageAllResult->qx_DetAIResult->AI_MaskImg.clone();
|
|
|
|
|
|
|
|
|
|
// 将BQ标签的AI mask合并到结果mask中
|
|
|
|
|
if (m_pImageAllResult->bq_DetAIResult && !m_pImageAllResult->bq_DetAIResult->AI_MaskImg.empty())
|
|
|
|
|
{
|
|
|
|
|
cv::bitwise_or(m_CheckResult_shareP->resultMaskImg, bqMask, m_CheckResult_shareP->resultMaskImg);
|
|
|
|
|
cv::Mat &bqMask = m_pImageAllResult->bq_DetAIResult->AI_MaskImg;
|
|
|
|
|
if (bqMask.size() == m_CheckResult_shareP->resultMaskImg.size())
|
|
|
|
|
{
|
|
|
|
|
cv::bitwise_or(m_CheckResult_shareP->resultMaskImg, bqMask, m_CheckResult_shareP->resultMaskImg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// cv::imwrite("dddddddd.png", m_pImageAllResult->qx_DetAIResult->AI_MaskImg);
|
|
|
|
|
// if (!m_pImageAllResult->qx_DetAIResult->AI_MaskImg.empty())
|
|
|
|
|
@ -3185,16 +3186,17 @@ int ImgCheckAnalysisy::AI_Detect_QX()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 仅在调试模式下保存 AI_Qx_MaskList,并限制数量
|
|
|
|
|
#ifdef SAVE_RESIMG
|
|
|
|
|
if (DetImgInfo_shareP->bDebugsaveImg && pDetAIResult->AI_Qx_MaskList.size() < 200)
|
|
|
|
|
if (NeedDrawAndSave())
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<ImageAllResult::AI_Det_MaskImg> temAIresult = std::make_shared<ImageAllResult::AI_Det_MaskImg>();
|
|
|
|
|
temAIresult->roi = result->roi;
|
|
|
|
|
temAIresult->AI_inImg = result->input;
|
|
|
|
|
temAIresult->AI_mask = outimg;
|
|
|
|
|
pDetAIResult->AI_Qx_MaskList.push_back(temAIresult);
|
|
|
|
|
if (DetImgInfo_shareP->bDebugsaveImg && pDetAIResult->AI_Qx_MaskList.size() < 200)
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<ImageAllResult::AI_Det_MaskImg> temAIresult = std::make_shared<ImageAllResult::AI_Det_MaskImg>();
|
|
|
|
|
temAIresult->roi = result->roi;
|
|
|
|
|
temAIresult->AI_inImg = result->input;
|
|
|
|
|
temAIresult->AI_mask = outimg;
|
|
|
|
|
pDetAIResult->AI_Qx_MaskList.push_back(temAIresult);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<ImageAllResult::AI_Det_MaskImg> temAIresult = std::make_shared<ImageAllResult::AI_Det_MaskImg>();
|
|
|
|
|
@ -3367,7 +3369,7 @@ int ImgCheckAnalysisy::AI_Detect_127Cell()
|
|
|
|
|
AIresult.copyTo(AIresultMask(result->roi), AIresult);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef SAVE_RESIMG
|
|
|
|
|
if (NeedDrawAndSave())
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<ImageAllResult::AI_Det_MaskImg> temAIresult = std::make_shared<ImageAllResult::AI_Det_MaskImg>();
|
|
|
|
|
temAIresult->roi = result->roi;
|
|
|
|
|
@ -3375,8 +3377,6 @@ int ImgCheckAnalysisy::AI_Detect_127Cell()
|
|
|
|
|
temAIresult->AI_mask = outimg;
|
|
|
|
|
pDetAIResult->AI_Qx_MaskList.push_back(temAIresult);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<ImageAllResult::AI_Det_MaskImg> temAIresult = std::make_shared<ImageAllResult::AI_Det_MaskImg>();
|
|
|
|
|
temAIresult->roi = result->roi;
|
|
|
|
|
@ -3560,7 +3560,7 @@ int ImgCheckAnalysisy::AI_Detect_RLine_512()
|
|
|
|
|
AIresult.copyTo(AIresultMask(result->roi), AIresult);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef SAVE_RESIMG
|
|
|
|
|
if (NeedDrawAndSave())
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<ImageAllResult::AI_Det_MaskImg> temAIresult = std::make_shared<ImageAllResult::AI_Det_MaskImg>();
|
|
|
|
|
temAIresult->roi = result->roi;
|
|
|
|
|
@ -3568,8 +3568,6 @@ int ImgCheckAnalysisy::AI_Detect_RLine_512()
|
|
|
|
|
temAIresult->AI_mask = outimg;
|
|
|
|
|
pDetAIResult->AI_Qx_MaskList.push_back(temAIresult);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<ImageAllResult::AI_Det_MaskImg> temAIresult = std::make_shared<ImageAllResult::AI_Det_MaskImg>();
|
|
|
|
|
temAIresult->roi = result->roi;
|
|
|
|
|
@ -3707,6 +3705,12 @@ int ImgCheckAnalysisy::ThreadTask(int nId)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ImgCheckAnalysisy::NeedDrawAndSave()
|
|
|
|
|
{
|
|
|
|
|
// base 层“是否存图绘制”开关:绘制并保存结果图(运行时替代 SAVE_RESIMG 宏)
|
|
|
|
|
return m_pbaseCheckFunction != NULL && m_pbaseCheckFunction->bDrawAndSave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ImgCheckAnalysisy::ResizeImg()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
@ -3716,35 +3720,37 @@ int ImgCheckAnalysisy::ResizeImg()
|
|
|
|
|
float fw = RESIZE_IMAGE_WIDTH * 1.0f / m_pImageAllResult->detImg.cols;
|
|
|
|
|
sz.height = int(m_pImageAllResult->detImg.rows * fw);
|
|
|
|
|
|
|
|
|
|
#ifdef SAVE_RESIMG
|
|
|
|
|
cv::resize(m_pImageAllResult->detImg, m_pImageAllResult->resultImg, sz);
|
|
|
|
|
|
|
|
|
|
// 需要绘制屏蔽区
|
|
|
|
|
if ((m_pBasicConfig && m_pBasicConfig->bDrawShieldRoi) ||
|
|
|
|
|
(m_pFuntion && m_pFuntion->function.f_ShieldRegion.bOpen && m_pFuntion->function.f_ShieldRegion.bDraw))
|
|
|
|
|
if (NeedDrawAndSave())
|
|
|
|
|
{
|
|
|
|
|
m_pdetlog->AddCheckstr(PrintLevel_1, "ResizeImg", "DrawShieldR param is open");
|
|
|
|
|
cv::Mat shieldImg = m_pImageAllResult->shieldImg;
|
|
|
|
|
cv::Mat sizeshieldimg;
|
|
|
|
|
if (!shieldImg.empty())
|
|
|
|
|
cv::resize(m_pImageAllResult->detImg, m_pImageAllResult->resultImg, sz);
|
|
|
|
|
|
|
|
|
|
// 需要绘制屏蔽区
|
|
|
|
|
if ((m_pBasicConfig && m_pBasicConfig->bDrawShieldRoi) ||
|
|
|
|
|
(m_pFuntion && m_pFuntion->function.f_ShieldRegion.bOpen && m_pFuntion->function.f_ShieldRegion.bDraw))
|
|
|
|
|
{
|
|
|
|
|
m_pdetlog->AddCheckstr(PrintLevel_1, "ResizeImg", "DrawShieldR param is open");
|
|
|
|
|
cv::Mat shieldImg = m_pImageAllResult->shieldImg;
|
|
|
|
|
cv::Mat sizeshieldimg;
|
|
|
|
|
if (!shieldImg.empty())
|
|
|
|
|
{
|
|
|
|
|
cv::resize(shieldImg, sizeshieldimg, sz);
|
|
|
|
|
sizeshieldimg *= 0.2;
|
|
|
|
|
m_pImageAllResult->resultImg += sizeshieldimg;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (m_pImageAllResult->resultImg.channels() == 1)
|
|
|
|
|
{
|
|
|
|
|
cv::resize(shieldImg, sizeshieldimg, sz);
|
|
|
|
|
sizeshieldimg *= 0.2;
|
|
|
|
|
m_pImageAllResult->resultImg += sizeshieldimg;
|
|
|
|
|
cv::cvtColor(m_pImageAllResult->resultImg, m_pImageAllResult->resultImg, cv::COLOR_GRAY2BGR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_CheckResult_shareP->resultimg = m_pImageAllResult->resultImg;
|
|
|
|
|
}
|
|
|
|
|
if (m_pImageAllResult->resultImg.channels() == 1)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cv::cvtColor(m_pImageAllResult->resultImg, m_pImageAllResult->resultImg, cv::COLOR_GRAY2BGR);
|
|
|
|
|
m_pImageAllResult->fscale_detToresult_x = RESIZE_IMAGE_WIDTH * 1.0f / m_pImageAllResult->detImg.cols;
|
|
|
|
|
m_pImageAllResult->fscale_detToresult_y = sz.height * 1.0f / m_pImageAllResult->detImg.rows;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_CheckResult_shareP->resultimg = m_pImageAllResult->resultImg;
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
m_pImageAllResult->fscale_detToresult_x = RESIZE_IMAGE_WIDTH * 1.0f / m_pImageAllResult->detImg.cols;
|
|
|
|
|
m_pImageAllResult->fscale_detToresult_y = sz.height * 1.0f / m_pImageAllResult->detImg.rows;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
m_pdetlog->AddCheckstr(PrintLevel_1, "ResizeImg", "showImg size [w %d,h %d]-> show img [w %d,h %d] ",
|
|
|
|
|
m_CutRoi.width, m_CutRoi.height, sz.width, sz.height);
|
|
|
|
|
return 0;
|
|
|
|
|
@ -3973,12 +3979,10 @@ int ImgCheckAnalysisy::UpdateBlobHFlag_RLine_512()
|
|
|
|
|
int ImgCheckAnalysisy::DrawResult_Step_1()
|
|
|
|
|
{
|
|
|
|
|
m_pdetlog->AddCheckstr(PrintLevel_0, "DrawResult_Step_1", "=======start");
|
|
|
|
|
#ifndef SAVE_RESIMG
|
|
|
|
|
if (m_CheckResult_shareP->resultimg.empty())
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
// std::cout << m_pBasicConfig->bDrawPreRoi << std::endl;
|
|
|
|
|
if (m_pBasicConfig->bDrawPreRoi)
|
|
|
|
|
{
|
|
|
|
|
@ -4994,14 +4998,17 @@ int ImgCheckAnalysisy::ImgPreDet()
|
|
|
|
|
creatsavedir();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef SAVE_RESIMG
|
|
|
|
|
m_CheckResult_shareP->cutSrcimg = m_pImageAllResult->detImg;
|
|
|
|
|
ResizeImg();
|
|
|
|
|
m_pImageAllResult->fscale_detToresult_x = m_pImageAllResult->resultImg.cols * 1.0f / m_pImageAllResult->detImg.cols;
|
|
|
|
|
m_pImageAllResult->fscale_detToresult_y = m_pImageAllResult->resultImg.rows * 1.0f / m_pImageAllResult->detImg.rows;
|
|
|
|
|
#else
|
|
|
|
|
ResizeImg();
|
|
|
|
|
#endif
|
|
|
|
|
if (NeedDrawAndSave())
|
|
|
|
|
{
|
|
|
|
|
m_CheckResult_shareP->cutSrcimg = m_pImageAllResult->detImg;
|
|
|
|
|
ResizeImg();
|
|
|
|
|
m_pImageAllResult->fscale_detToresult_x = m_pImageAllResult->resultImg.cols * 1.0f / m_pImageAllResult->detImg.cols;
|
|
|
|
|
m_pImageAllResult->fscale_detToresult_y = m_pImageAllResult->resultImg.rows * 1.0f / m_pImageAllResult->detImg.rows;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ResizeImg();
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|