|
|
|
@ -312,6 +312,13 @@ cv::Scalar ImgCheckAnalysisy::calc_blob_info_withstats(cv::Mat &img, const cv::M
|
|
|
|
// 计算感兴趣区域 (ROI)
|
|
|
|
// 计算感兴趣区域 (ROI)
|
|
|
|
cv::Rect roi(x - expand, y - expand, w + 2 * expand, h + 2 * expand);
|
|
|
|
cv::Rect roi(x - expand, y - expand, w + 2 * expand, h + 2 * expand);
|
|
|
|
roi &= cv::Rect(0, 0, img.cols, img.rows); // 确保ROI在图像内
|
|
|
|
roi &= cv::Rect(0, 0, img.cols, img.rows); // 确保ROI在图像内
|
|
|
|
|
|
|
|
roi &= cv::Rect(0, 0, mask.cols, mask.rows); // 确保ROI在mask内
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 检查 mask 是否有效
|
|
|
|
|
|
|
|
if (mask.empty() || roi.width <= 0 || roi.height <= 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return cv::Scalar(0, 0, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cv::Mat cimg = img(roi);
|
|
|
|
cv::Mat cimg = img(roi);
|
|
|
|
|
|
|
|
|
|
|
|
@ -846,6 +853,18 @@ int ImgCheckAnalysisy::CalBlob_Other()
|
|
|
|
|
|
|
|
|
|
|
|
m_pdetlog->AddCheckstr(PrintLevel_1, DET_LOG_LEVEL_3, "CalBlob_Other", " Start");
|
|
|
|
m_pdetlog->AddCheckstr(PrintLevel_1, DET_LOG_LEVEL_3, "CalBlob_Other", " Start");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 检查 detImg 和 AIMaskImg 是否为空
|
|
|
|
|
|
|
|
if (m_pImageAllResult->detImg.empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_pdetlog->AddCheckstr(PrintLevel_1, DET_LOG_LEVEL_3, "CalBlob_Other", " detImg is empty, return");
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_pImageAllResult->AIMaskImg.empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_pdetlog->AddCheckstr(PrintLevel_1, DET_LOG_LEVEL_3, "CalBlob_Other", " AIMaskImg is empty, return");
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float fs_x = m_fImgage_Scale_X;
|
|
|
|
float fs_x = m_fImgage_Scale_X;
|
|
|
|
float fs_y = m_fImgage_Scale_Y;
|
|
|
|
float fs_y = m_fImgage_Scale_Y;
|
|
|
|
|
|
|
|
|
|
|
|
@ -1631,7 +1650,7 @@ int ImgCheckAnalysisy::Traditional_Detect_Thread(const cv::Mat &img, cv::Mat &Re
|
|
|
|
bTcsInited = true;
|
|
|
|
bTcsInited = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 调用传统检测:输出残点二值图
|
|
|
|
// 调用传统检测:输出残点二值图(已内部完成 crop+resize 反向映射,与 img 同尺寸)
|
|
|
|
int ret = m_tcsCheck.TraditionalDetect(img, ResultImg);
|
|
|
|
int ret = m_tcsCheck.TraditionalDetect(img, ResultImg);
|
|
|
|
if (ret != 0)
|
|
|
|
if (ret != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|