From 8a8492472d6f0c009d7ee998ebeec0fa9684fc6d Mon Sep 17 00:00:00 2001 From: liusiyang Date: Tue, 3 Nov 2026 11:17:44 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E8=BF=87=E6=BB=A4=E4=B8=8D=E9=99=90?= =?UTF-8?q?=E5=88=B6=E9=80=9A=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AlgorithmModule/include/ImageResultJudge.h | 10 ++--- AlgorithmModule/src/CameraCheckAnalysisy.cpp | 8 ++-- AlgorithmModule/src/ImageResultJudge.cpp | 43 ++++++++++---------- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/AlgorithmModule/include/ImageResultJudge.h b/AlgorithmModule/include/ImageResultJudge.h index d48586b..517ebd7 100644 --- a/AlgorithmModule/include/ImageResultJudge.h +++ b/AlgorithmModule/include/ImageResultJudge.h @@ -107,12 +107,12 @@ public: int UpdateConfig(std::string strcameraName); int DrawResult(std::shared_ptr pImageResult); - // 盲失联合判断:主通道(ms_main_channel)检出的盲失(Other)若在过滤通道(ms_filter_channels)同位置存在盲失, - // 则不算盲失(撤销NG)。同位置判断参考暗点联合分析:双方按 ms_expand 扩张后计算 IOU, 大于 ms_iou 认为同位置 + // 盲失联合判断:主通道(ms_main_channel)检出的盲失(Other)若在过滤通道(ms_filter_channels)同位置存在缺陷 + // (不限制缺陷类型),则不算盲失(撤销NG)。同位置判断参考暗点联合分析:双方按 ms_expand 扩张后计算 IOU, 大于 ms_iou 认为同位置 int FilterMsBlindNG(std::shared_ptr pCheck_Result); // cell黑白点联合判断:主通道(cellbw_main_channel)检出的cell黑白点在过滤通道(cellbw_filter_channels) - // 同位置存在cell黑白点(白点/黑点均算)时不算cell黑白点(撤销NG) + // 同位置存在缺陷(不限制缺陷类型)时不算cell黑白点(撤销NG) // 同位置判断参考暗点联合分析:双方按 cellbw_expand 扩张后计算 IOU, 大于 cellbw_iou 认为同位置 int FilterCellBwNG(std::shared_ptr pCheck_Result); @@ -147,7 +147,7 @@ private: // 撤销单个缺陷的NG结果:恢复为OK,移除对应NG小图并回退计数 int UndoNGResult(std::shared_ptr pImageResult, int qxidx, QX_ERROR_INFO_ *QX_info); - // 跨通道同位置判断:当前缺陷(产品坐标系ROI)在过滤通道是否存在指定类型的同位置缺陷(双方按 expand 扩张后计算IOU) + // 跨通道同位置判断:当前缺陷(产品坐标系ROI)在过滤通道是否存在同位置缺陷(双方按 expand 扩张后计算IOU) bool IsOverlapQxInFilterChannels(const std::vector> &imgResults, const std::string &cur_channel_name, const std::vector &filter_channels, @@ -157,7 +157,7 @@ private: const std::string &strTag, std::shared_ptr plog); - // 判断盲失(产品坐标系ROI)在配置的过滤通道是否存在同位置盲失缺陷(双方按 expand 扩张后计算IOU) + // 判断盲失(产品坐标系ROI)在配置的过滤通道是否存在同位置缺陷(不限制类型,双方按 expand 扩张后计算IOU) bool IsOverlapQxInMsFilterChannel(const std::vector> &imgResults, const std::string &cur_channel_name, const cv::Rect &qx_product_roi, diff --git a/AlgorithmModule/src/CameraCheckAnalysisy.cpp b/AlgorithmModule/src/CameraCheckAnalysisy.cpp index 770bf0a..99719a2 100644 --- a/AlgorithmModule/src/CameraCheckAnalysisy.cpp +++ b/AlgorithmModule/src/CameraCheckAnalysisy.cpp @@ -342,22 +342,22 @@ int CameraCheckAnalysisy::ResultParamJudge() long t2 = CheckUtil::getcurTime(); } - // 盲失联合判断:主通道(ms_main_channel)检出的盲失若在过滤通道(ms_filter_channels)同位置存在盲失,则不算盲失(撤销NG) + // 盲失联合判断:主通道(ms_main_channel)检出的盲失若在过滤通道(ms_filter_channels)同位置存在缺陷(不限制类型),则不算盲失(撤销NG) { int nMsFilterNum = m_imageResultJudge.FilterMsBlindNG(m_pCheck_Result); if (nMsFilterNum > 0) { - m_pdetlog->AddCheckstr(PrintLevel_1, "ResultParamJudge", "盲失联合判断: 过滤通道同位置存在盲失, 过滤盲失NG %d 个", nMsFilterNum); + m_pdetlog->AddCheckstr(PrintLevel_1, "ResultParamJudge", "盲失联合判断: 过滤通道同位置存在缺陷, 过滤盲失NG %d 个", nMsFilterNum); } } // cell黑白点联合判断:主通道(cellbw_main_channel)检出的cell黑白点若在过滤通道(cellbw_filter_channels)同位置 - // 存在cell黑白点(白点/黑点均算),则不算cell黑白点(撤销NG) + // 存在缺陷(不限制类型),则不算cell黑白点(撤销NG) { int nCellBwFilterNum = m_imageResultJudge.FilterCellBwNG(m_pCheck_Result); if (nCellBwFilterNum > 0) { - m_pdetlog->AddCheckstr(PrintLevel_1, "ResultParamJudge", "cell黑白点联合判断: 过滤通道同位置存在cell黑白点, 过滤NG %d 个", nCellBwFilterNum); + m_pdetlog->AddCheckstr(PrintLevel_1, "ResultParamJudge", "cell黑白点联合判断: 过滤通道同位置存在缺陷, 过滤NG %d 个", nCellBwFilterNum); } } diff --git a/AlgorithmModule/src/ImageResultJudge.cpp b/AlgorithmModule/src/ImageResultJudge.cpp index 492e253..5ee669a 100644 --- a/AlgorithmModule/src/ImageResultJudge.cpp +++ b/AlgorithmModule/src/ImageResultJudge.cpp @@ -955,7 +955,7 @@ int ImageResultJudge::UndoNGResult(std::shared_ptr pImageResult, } /** - * @brief 判断盲失(产品坐标系ROI)在配置的过滤通道是否存在同位置且同为盲失(Other)类型的缺陷 + * @brief 判断盲失(产品坐标系ROI)在配置的过滤通道是否存在同位置缺陷(不限制缺陷类型) * 同位置判断方式参考暗点联合分析:当前ROI与过滤通道缺陷ROI双方均按 expand 扩张后计算 IOU * @param imgResults 当前相机所有通道的检测结果 * @param cur_channel_name 盲失所属通道(主通道) @@ -963,7 +963,7 @@ int ImageResultJudge::UndoNGResult(std::shared_ptr pImageResult, * @param roi_expand 扩张像素(ms_expand) * @param iou_threshold IOU阈值(ms_iou) * @param plog 日志 - * @return bool 过滤通道同位置存在盲失缺陷返回true + * @return bool 过滤通道同位置存在缺陷返回true */ bool ImageResultJudge::IsOverlapQxInMsFilterChannel(const std::vector> &imgResults, const std::string &cur_channel_name, @@ -1014,14 +1014,10 @@ bool ImageResultJudge::IsOverlapQxInMsFilterChannel(const std::vectorpQx_ErrorList->size(); j++) { const QX_ERROR_INFO_ &filter_qx = pFilterDetResult->pQx_ErrorList->at(j); - if (filter_qx.nconfig_qx_type != CONFIG_QX_NAME_Other) - { - continue; - } cv::Rect filter_roi = filter_qx.roi; filter_roi.x += fproduct_offx_piexl; cv::Rect filter_expanded(filter_roi.x - roi_expand, filter_roi.y - roi_expand, @@ -1057,7 +1053,7 @@ bool ImageResultJudge::IsOverlapQxInMsFilterChannel(const std::vector pCheck_Resul if (pImageLog) { pImageLog->AddCheckstr(PrintLevel_1, DET_LOG_LEVEL_3, "MsBlind", - "img %s cam %s blob %d qx %s roi %s : 过滤通道同位置存在盲失, 不算盲失", + "img %s cam %s blob %d qx %s roi %s : 过滤通道同位置存在缺陷, 不算盲失", pImageResult->strChannel.c_str(), pImageResult->cameraBaseResult->strCameraName.c_str(), qxidx, QX_info->qx_name.c_str(), CheckUtil::GetRectString(product_roi).c_str()); } if (m_pQX_Merge_Analysis != nullptr && m_pQX_Merge_Analysis->m_pMergedetlog) { m_pQX_Merge_Analysis->m_pMergedetlog->AddCheckstr(PrintLevel_1, 3, "MsBlind", - "img %s cam %s blob %d qx %s roi %s : 过滤通道同位置存在盲失, 不算盲失", + "img %s cam %s blob %d qx %s roi %s : 过滤通道同位置存在缺陷, 不算盲失", pImageResult->strChannel.c_str(), pImageResult->cameraBaseResult->strCameraName.c_str(), qxidx, QX_info->qx_name.c_str(), CheckUtil::GetRectString(product_roi).c_str()); } @@ -1146,18 +1142,19 @@ int ImageResultJudge::FilterMsBlindNG(std::shared_ptr pCheck_Resul } /** - * @brief 跨通道同位置判断:判断当前缺陷(产品坐标系ROI)在过滤通道是否存在指定类型的同位置缺陷 + * @brief 跨通道同位置判断:判断当前缺陷(产品坐标系ROI)在过滤通道是否存在同位置缺陷 + * (match_qx_types 为空表示不限制缺陷类型) * 同位置判断方式参考暗点联合分析:当前ROI与过滤通道缺陷ROI双方均按 expand 扩张后计算 IOU * @param imgResults 当前相机所有通道的检测结果 * @param cur_channel_name 当前缺陷所属通道(主通道) * @param filter_channels 需要比较的过滤通道 - * @param match_qx_types 过滤通道中参与比较的缺陷类型(CONFIG_QX_NAME_) + * @param match_qx_types 过滤通道中参与比较的缺陷类型(CONFIG_QX_NAME_),为空表示不限制类型 * @param qx_product_roi 当前缺陷的产品坐标系ROI * @param roi_expand 扩张像素 * @param iou_threshold IOU阈值 * @param strTag 日志标签 * @param plog 日志 - * @return bool 过滤通道同位置存在指定类型缺陷返回true + * @return bool 过滤通道同位置存在匹配缺陷返回true */ bool ImageResultJudge::IsOverlapQxInFilterChannels(const std::vector> &imgResults, const std::string &cur_channel_name, @@ -1168,12 +1165,13 @@ bool ImageResultJudge::IsOverlapQxInFilterChannels(const std::vector plog) { - // 防御:ROI非法/未配置过滤通道/未指定匹配类型时不判断,避免无效计算与除零 + // 防御:ROI非法/未配置过滤通道时不判断,避免无效计算与除零 if (qx_product_roi.width <= 0 || qx_product_roi.height <= 0) { return false; } - if (filter_channels.empty() || match_qx_types.empty()) + // match_qx_types 为空表示不限制过滤通道的缺陷类型 + if (filter_channels.empty()) { return false; } @@ -1210,11 +1208,12 @@ bool ImageResultJudge::IsOverlapQxInFilterChannels(const std::vectorpQx_ErrorList->size(); j++) { const QX_ERROR_INFO_ &filter_qx = pFilterDetResult->pQx_ErrorList->at(j); - if (std::find(match_qx_types.begin(), match_qx_types.end(), filter_qx.nconfig_qx_type) == match_qx_types.end()) + if (!match_qx_types.empty() && + std::find(match_qx_types.begin(), match_qx_types.end(), filter_qx.nconfig_qx_type) == match_qx_types.end()) { continue; } @@ -1258,7 +1257,7 @@ bool ImageResultJudge::IsOverlapQxInFilterChannels(const std::vector pCheck_ /** * @brief cell黑白点联合判断:主通道(cellbw_main_channel)检出的cell黑白点在过滤通道(cellbw_filter_channels) - * 同位置存在cell黑白点(白点/黑点均算)时不算cell黑白点(撤销NG) + * 同位置存在缺陷(不限制缺陷类型)时不算cell黑白点(撤销NG) * 同位置判断方式参考暗点联合分析:双方按 cellbw_expand 扩张后计算 IOU, 大于 cellbw_iou 认为同位置 * @param pCheck_Result 当前相机检测结果(包含该相机所有通道的检测结果) * @return int 被过滤的cell黑白点NG个数 @@ -1377,13 +1376,13 @@ int ImageResultJudge::FilterCellBwNG(std::shared_ptr pCheck_Result { return 0; } - // 白点/黑点通用:主通道与过滤通道均按 cell 黑白点匹配(白↔白、黑↔黑、白↔黑都算) + // 主通道只处理 cell 黑白点(白点/黑点都算);过滤通道不限制缺陷类型,同位置存在任意类型缺陷即过滤 const std::vector qxTypes = {CONFIG_QX_NAME_white_Cell, CONFIG_QX_NAME_black_Cell}; return FilterCrossChannelNG(pCheck_Result, pCellBwParam->cellbw_main_channel, pCellBwParam->cellbw_filter_channels, - qxTypes, qxTypes, + qxTypes, std::vector(), (int)(round)(pCellBwParam->CellBW_Expand), pCellBwParam->CellBW_IOU, - "CellBw", "过滤通道同位置存在cell黑白点, 不算cell黑白点"); + "CellBw", "过滤通道同位置存在缺陷, 不算cell黑白点"); } int ImageResultJudge::MergeResult(std::shared_ptr pImageResult, QX_Analysis_Result_List *ptemre)