update 过滤不限制通道

dev_lsy
liusiyang 2 days ago
parent 7ef04b6234
commit 8a8492472d

@ -107,12 +107,12 @@ public:
int UpdateConfig(std::string strcameraName); int UpdateConfig(std::string strcameraName);
int DrawResult(std::shared_ptr<ImageAllResult> pImageResult); int DrawResult(std::shared_ptr<ImageAllResult> pImageResult);
// 盲失联合判断:主通道(ms_main_channel)检出的盲失(Other)若在过滤通道(ms_filter_channels)同位置存在盲失, // 盲失联合判断:主通道(ms_main_channel)检出的盲失(Other)若在过滤通道(ms_filter_channels)同位置存在缺陷
// 则不算盲失(撤销NG)。同位置判断参考暗点联合分析:双方按 ms_expand 扩张后计算 IOU, 大于 ms_iou 认为同位置 // (不限制缺陷类型),则不算盲失(撤销NG)。同位置判断参考暗点联合分析:双方按 ms_expand 扩张后计算 IOU, 大于 ms_iou 认为同位置
int FilterMsBlindNG(std::shared_ptr<CameraResult> pCheck_Result); int FilterMsBlindNG(std::shared_ptr<CameraResult> pCheck_Result);
// cell黑白点联合判断:主通道(cellbw_main_channel)检出的cell黑白点在过滤通道(cellbw_filter_channels) // cell黑白点联合判断:主通道(cellbw_main_channel)检出的cell黑白点在过滤通道(cellbw_filter_channels)
// 同位置存在cell黑白点(白点/黑点均算)时不算cell黑白点(撤销NG) // 同位置存在缺陷(不限制缺陷类型)时不算cell黑白点(撤销NG)
// 同位置判断参考暗点联合分析:双方按 cellbw_expand 扩张后计算 IOU, 大于 cellbw_iou 认为同位置 // 同位置判断参考暗点联合分析:双方按 cellbw_expand 扩张后计算 IOU, 大于 cellbw_iou 认为同位置
int FilterCellBwNG(std::shared_ptr<CameraResult> pCheck_Result); int FilterCellBwNG(std::shared_ptr<CameraResult> pCheck_Result);
@ -147,7 +147,7 @@ private:
// 撤销单个缺陷的NG结果:恢复为OK,移除对应NG小图并回退计数 // 撤销单个缺陷的NG结果:恢复为OK,移除对应NG小图并回退计数
int UndoNGResult(std::shared_ptr<ImageAllResult> pImageResult, int qxidx, QX_ERROR_INFO_ *QX_info); int UndoNGResult(std::shared_ptr<ImageAllResult> pImageResult, int qxidx, QX_ERROR_INFO_ *QX_info);
// 跨通道同位置判断:当前缺陷(产品坐标系ROI)在过滤通道是否存在指定类型的同位置缺陷(双方按 expand 扩张后计算IOU) // 跨通道同位置判断:当前缺陷(产品坐标系ROI)在过滤通道是否存在同位置缺陷(双方按 expand 扩张后计算IOU)
bool IsOverlapQxInFilterChannels(const std::vector<std::shared_ptr<ImageAllResult>> &imgResults, bool IsOverlapQxInFilterChannels(const std::vector<std::shared_ptr<ImageAllResult>> &imgResults,
const std::string &cur_channel_name, const std::string &cur_channel_name,
const std::vector<std::string> &filter_channels, const std::vector<std::string> &filter_channels,
@ -157,7 +157,7 @@ private:
const std::string &strTag, const std::string &strTag,
std::shared_ptr<DetLog> plog); std::shared_ptr<DetLog> plog);
// 判断盲失(产品坐标系ROI)在配置的过滤通道是否存在同位置盲失缺陷(双方按 expand 扩张后计算IOU) // 判断盲失(产品坐标系ROI)在配置的过滤通道是否存在同位置缺陷(不限制类型,双方按 expand 扩张后计算IOU)
bool IsOverlapQxInMsFilterChannel(const std::vector<std::shared_ptr<ImageAllResult>> &imgResults, bool IsOverlapQxInMsFilterChannel(const std::vector<std::shared_ptr<ImageAllResult>> &imgResults,
const std::string &cur_channel_name, const std::string &cur_channel_name,
const cv::Rect &qx_product_roi, const cv::Rect &qx_product_roi,

@ -342,22 +342,22 @@ int CameraCheckAnalysisy::ResultParamJudge()
long t2 = CheckUtil::getcurTime(); 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); int nMsFilterNum = m_imageResultJudge.FilterMsBlindNG(m_pCheck_Result);
if (nMsFilterNum > 0) 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黑白点联合判断:主通道(cellbw_main_channel)检出的cell黑白点若在过滤通道(cellbw_filter_channels)同位置
// 存在cell黑白点(白点/黑点均算),则不算cell黑白点(撤销NG) // 存在缺陷(不限制类型),则不算cell黑白点(撤销NG)
{ {
int nCellBwFilterNum = m_imageResultJudge.FilterCellBwNG(m_pCheck_Result); int nCellBwFilterNum = m_imageResultJudge.FilterCellBwNG(m_pCheck_Result);
if (nCellBwFilterNum > 0) if (nCellBwFilterNum > 0)
{ {
m_pdetlog->AddCheckstr(PrintLevel_1, "ResultParamJudge", "cell黑白点联合判断: 过滤通道同位置存在cell黑白点, 过滤NG %d 个", nCellBwFilterNum); m_pdetlog->AddCheckstr(PrintLevel_1, "ResultParamJudge", "cell黑白点联合判断: 过滤通道同位置存在缺陷, 过滤NG %d 个", nCellBwFilterNum);
} }
} }

@ -955,7 +955,7 @@ int ImageResultJudge::UndoNGResult(std::shared_ptr<ImageAllResult> pImageResult,
} }
/** /**
* @brief 判断盲失(产品坐标系ROI)在配置的过滤通道是否存在同位置且同为盲失(Other)类型的缺陷 * @brief 判断盲失(产品坐标系ROI)在配置的过滤通道是否存在同位置缺陷(不限制缺陷类型)
* 同位置判断方式参考暗点联合分析:当前ROI与过滤通道缺陷ROI双方均按 expand 扩张后计算 IOU * 同位置判断方式参考暗点联合分析:当前ROI与过滤通道缺陷ROI双方均按 expand 扩张后计算 IOU
* @param imgResults 当前相机所有通道的检测结果 * @param imgResults 当前相机所有通道的检测结果
* @param cur_channel_name 盲失所属通道(主通道) * @param cur_channel_name 盲失所属通道(主通道)
@ -963,7 +963,7 @@ int ImageResultJudge::UndoNGResult(std::shared_ptr<ImageAllResult> pImageResult,
* @param roi_expand 扩张像素(ms_expand) * @param roi_expand 扩张像素(ms_expand)
* @param iou_threshold IOU阈值(ms_iou) * @param iou_threshold IOU阈值(ms_iou)
* @param plog 日志 * @param plog 日志
* @return bool 过滤通道同位置存在盲失缺陷返回true * @return bool 过滤通道同位置存在缺陷返回true
*/ */
bool ImageResultJudge::IsOverlapQxInMsFilterChannel(const std::vector<std::shared_ptr<ImageAllResult>> &imgResults, bool ImageResultJudge::IsOverlapQxInMsFilterChannel(const std::vector<std::shared_ptr<ImageAllResult>> &imgResults,
const std::string &cur_channel_name, const std::string &cur_channel_name,
@ -1014,14 +1014,10 @@ bool ImageResultJudge::IsOverlapQxInMsFilterChannel(const std::vector<std::share
continue; continue;
} }
// 只统计过滤通道内同为盲失(Other)类型的缺陷,与具体判定结果无关 // 过滤通道不限制缺陷类型:任意类型缺陷都参与同位置比较,与具体判定结果无关
for (int j = 0; j < (int)pFilterDetResult->pQx_ErrorList->size(); j++) for (int j = 0; j < (int)pFilterDetResult->pQx_ErrorList->size(); j++)
{ {
const QX_ERROR_INFO_ &filter_qx = pFilterDetResult->pQx_ErrorList->at(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; cv::Rect filter_roi = filter_qx.roi;
filter_roi.x += fproduct_offx_piexl; filter_roi.x += fproduct_offx_piexl;
cv::Rect filter_expanded(filter_roi.x - roi_expand, filter_roi.y - roi_expand, cv::Rect filter_expanded(filter_roi.x - roi_expand, filter_roi.y - roi_expand,
@ -1057,7 +1053,7 @@ bool ImageResultJudge::IsOverlapQxInMsFilterChannel(const std::vector<std::share
/** /**
* @brief 盲失联合判断:主通道(ms_main_channel)检出的盲失(Other)需要和过滤通道(ms_filter_channels)同位置判断, * @brief 盲失联合判断:主通道(ms_main_channel)检出的盲失(Other)需要和过滤通道(ms_filter_channels)同位置判断,
* 过滤通道同位置存在同为盲失(Other)类型的缺陷时不算盲失(撤销NG) * 过滤通道同位置存在缺陷(不限制缺陷类型)时不算盲失(撤销NG)
* 同位置判断方式参考暗点联合分析:双方按 ms_expand 扩张后计算 IOU, 大于 ms_iou 认为同位置 * 同位置判断方式参考暗点联合分析:双方按 ms_expand 扩张后计算 IOU, 大于 ms_iou 认为同位置
* @param pCheck_Result 当前相机检测结果(包含该相机所有通道的检测结果) * @param pCheck_Result 当前相机检测结果(包含该相机所有通道的检测结果)
* @return int 被过滤的盲失NG个数 * @return int 被过滤的盲失NG个数
@ -1128,14 +1124,14 @@ int ImageResultJudge::FilterMsBlindNG(std::shared_ptr<CameraResult> pCheck_Resul
if (pImageLog) if (pImageLog)
{ {
pImageLog->AddCheckstr(PrintLevel_1, DET_LOG_LEVEL_3, "MsBlind", 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(), pImageResult->strChannel.c_str(), pImageResult->cameraBaseResult->strCameraName.c_str(),
qxidx, QX_info->qx_name.c_str(), CheckUtil::GetRectString(product_roi).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) if (m_pQX_Merge_Analysis != nullptr && m_pQX_Merge_Analysis->m_pMergedetlog)
{ {
m_pQX_Merge_Analysis->m_pMergedetlog->AddCheckstr(PrintLevel_1, 3, "MsBlind", 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(), pImageResult->strChannel.c_str(), pImageResult->cameraBaseResult->strCameraName.c_str(),
qxidx, QX_info->qx_name.c_str(), CheckUtil::GetRectString(product_roi).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<CameraResult> pCheck_Resul
} }
/** /**
* @brief 跨通道同位置判断:判断当前缺陷(产品坐标系ROI)在过滤通道是否存在指定类型的同位置缺陷 * @brief 跨通道同位置判断:判断当前缺陷(产品坐标系ROI)在过滤通道是否存在同位置缺陷
* (match_qx_types 为空表示不限制缺陷类型)
* 同位置判断方式参考暗点联合分析:当前ROI与过滤通道缺陷ROI双方均按 expand 扩张后计算 IOU * 同位置判断方式参考暗点联合分析:当前ROI与过滤通道缺陷ROI双方均按 expand 扩张后计算 IOU
* @param imgResults 当前相机所有通道的检测结果 * @param imgResults 当前相机所有通道的检测结果
* @param cur_channel_name 当前缺陷所属通道(主通道) * @param cur_channel_name 当前缺陷所属通道(主通道)
* @param filter_channels 需要比较的过滤通道 * @param filter_channels 需要比较的过滤通道
* @param match_qx_types 过滤通道中参与比较的缺陷类型(CONFIG_QX_NAME_) * @param match_qx_types 过滤通道中参与比较的缺陷类型(CONFIG_QX_NAME_),为空表示不限制类型
* @param qx_product_roi 当前缺陷的产品坐标系ROI * @param qx_product_roi 当前缺陷的产品坐标系ROI
* @param roi_expand 扩张像素 * @param roi_expand 扩张像素
* @param iou_threshold IOU阈值 * @param iou_threshold IOU阈值
* @param strTag 日志标签 * @param strTag 日志标签
* @param plog 日志 * @param plog 日志
* @return bool 过滤通道同位置存在指定类型缺陷返回true * @return bool 过滤通道同位置存在匹配缺陷返回true
*/ */
bool ImageResultJudge::IsOverlapQxInFilterChannels(const std::vector<std::shared_ptr<ImageAllResult>> &imgResults, bool ImageResultJudge::IsOverlapQxInFilterChannels(const std::vector<std::shared_ptr<ImageAllResult>> &imgResults,
const std::string &cur_channel_name, const std::string &cur_channel_name,
@ -1168,12 +1165,13 @@ bool ImageResultJudge::IsOverlapQxInFilterChannels(const std::vector<std::shared
const std::string &strTag, const std::string &strTag,
std::shared_ptr<DetLog> plog) std::shared_ptr<DetLog> plog)
{ {
// 防御:ROI非法/未配置过滤通道/未指定匹配类型时不判断,避免无效计算与除零 // 防御:ROI非法/未配置过滤通道时不判断,避免无效计算与除零
if (qx_product_roi.width <= 0 || qx_product_roi.height <= 0) if (qx_product_roi.width <= 0 || qx_product_roi.height <= 0)
{ {
return false; return false;
} }
if (filter_channels.empty() || match_qx_types.empty()) // match_qx_types 为空表示不限制过滤通道的缺陷类型
if (filter_channels.empty())
{ {
return false; return false;
} }
@ -1210,11 +1208,12 @@ bool ImageResultJudge::IsOverlapQxInFilterChannels(const std::vector<std::shared
continue; continue;
} }
// 只统计过滤通道内指定类型的缺陷,与具体判定结果无关 // 只统计过滤通道内匹配类型的缺陷(未指定类型时不限制),与具体判定结果无关
for (int j = 0; j < (int)pFilterDetResult->pQx_ErrorList->size(); j++) for (int j = 0; j < (int)pFilterDetResult->pQx_ErrorList->size(); j++)
{ {
const QX_ERROR_INFO_ &filter_qx = pFilterDetResult->pQx_ErrorList->at(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; continue;
} }
@ -1258,7 +1257,7 @@ bool ImageResultJudge::IsOverlapQxInFilterChannels(const std::vector<std::shared
* @param main_channels 主通道 * @param main_channels 主通道
* @param filter_channels 过滤通道 * @param filter_channels 过滤通道
* @param main_qx_types 参与判断的主通道缺陷类型(CONFIG_QX_NAME_) * @param main_qx_types 参与判断的主通道缺陷类型(CONFIG_QX_NAME_)
* @param match_qx_types 过滤通道中参与比较的缺陷类型(CONFIG_QX_NAME_) * @param match_qx_types 过滤通道中参与比较的缺陷类型(CONFIG_QX_NAME_),为空表示不限制类型
* @param roi_expand 扩张像素 * @param roi_expand 扩张像素
* @param iou_threshold IOU阈值 * @param iou_threshold IOU阈值
* @param strTag 日志标签 * @param strTag 日志标签
@ -1360,7 +1359,7 @@ int ImageResultJudge::FilterCrossChannelNG(std::shared_ptr<CameraResult> pCheck_
/** /**
* @brief cell黑白点联合判断:主通道(cellbw_main_channel)检出的cell黑白点在过滤通道(cellbw_filter_channels) * @brief cell黑白点联合判断:主通道(cellbw_main_channel)检出的cell黑白点在过滤通道(cellbw_filter_channels)
* 同位置存在cell黑白点(白点/黑点均算)时不算cell黑白点(撤销NG) * 同位置存在缺陷(不限制缺陷类型)时不算cell黑白点(撤销NG)
* 同位置判断方式参考暗点联合分析:双方按 cellbw_expand 扩张后计算 IOU, 大于 cellbw_iou 认为同位置 * 同位置判断方式参考暗点联合分析:双方按 cellbw_expand 扩张后计算 IOU, 大于 cellbw_iou 认为同位置
* @param pCheck_Result 当前相机检测结果(包含该相机所有通道的检测结果) * @param pCheck_Result 当前相机检测结果(包含该相机所有通道的检测结果)
* @return int 被过滤的cell黑白点NG个数 * @return int 被过滤的cell黑白点NG个数
@ -1377,13 +1376,13 @@ int ImageResultJudge::FilterCellBwNG(std::shared_ptr<CameraResult> pCheck_Result
{ {
return 0; return 0;
} }
// 白点/黑点通用:主通道与过滤通道均按 cell 黑白点匹配(白↔白、黑↔黑、白↔黑都算) // 主通道只处理 cell 黑白点(白点/黑点都算);过滤通道不限制缺陷类型,同位置存在任意类型缺陷即过滤
const std::vector<int> qxTypes = {CONFIG_QX_NAME_white_Cell, CONFIG_QX_NAME_black_Cell}; const std::vector<int> qxTypes = {CONFIG_QX_NAME_white_Cell, CONFIG_QX_NAME_black_Cell};
return FilterCrossChannelNG(pCheck_Result, return FilterCrossChannelNG(pCheck_Result,
pCellBwParam->cellbw_main_channel, pCellBwParam->cellbw_filter_channels, pCellBwParam->cellbw_main_channel, pCellBwParam->cellbw_filter_channels,
qxTypes, qxTypes, qxTypes, std::vector<int>(),
(int)(round)(pCellBwParam->CellBW_Expand), pCellBwParam->CellBW_IOU, (int)(round)(pCellBwParam->CellBW_Expand), pCellBwParam->CellBW_IOU,
"CellBw", "过滤通道同位置存在cell黑白点, 不算cell黑白点"); "CellBw", "过滤通道同位置存在缺陷, 不算cell黑白点");
} }
int ImageResultJudge::MergeResult(std::shared_ptr<ImageAllResult> pImageResult, QX_Analysis_Result_List *ptemre) int ImageResultJudge::MergeResult(std::shared_ptr<ImageAllResult> pImageResult, QX_Analysis_Result_List *ptemre)

Loading…
Cancel
Save