From e0913f2ac7fbb7b22fb9271e2f86b4f9b59e5c8c Mon Sep 17 00:00:00 2001 From: liusiyang Date: Fri, 9 Oct 2026 12:44:29 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E6=B7=BB=E5=8A=A0=E6=94=AF=E6=9E=B6?= =?UTF-8?q?=EF=BC=8C=E6=A0=87=E7=AD=BE=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AlgorithmModule/include/AI_Edge_Algin.h | 2 + AlgorithmModule/src/AI_Edge_Algin.cpp | 9 ++++- AlgorithmModule/src/ImgCheckAnalysisy.cpp | 46 ++++++++++++++--------- 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/AlgorithmModule/include/AI_Edge_Algin.h b/AlgorithmModule/include/AI_Edge_Algin.h index 8fff4ec..d21b22b 100644 --- a/AlgorithmModule/include/AI_Edge_Algin.h +++ b/AlgorithmModule/include/AI_Edge_Algin.h @@ -107,6 +107,7 @@ public: int nAIErodesize; // 边缘腐蚀强度 bool bSaveResultImg; // 保存结果图片 SaveProcessType saveProcessImg; // 保存过程图片 + bool bDetTag; // 标签检测开关(关闭时不跑 Tag_Loc 模型) bool bUseDrawRoi_Check; // 是否用绘制的ROI进行校验 cv::Rect drawRoi; // 绘制的 ROi; cv::Mat drawMask; // 绘制的maksk @@ -122,6 +123,7 @@ public: nAIErodesize = 7; bSaveResultImg = false; saveProcessImg = Save_Close; + bDetTag = true; bUseDrawRoi_Check = false; drawRoi = cv::Rect(0, 0, 0, 0); if (!drawMask.empty()) diff --git a/AlgorithmModule/src/AI_Edge_Algin.cpp b/AlgorithmModule/src/AI_Edge_Algin.cpp index cd630bc..c9ece66 100644 --- a/AlgorithmModule/src/AI_Edge_Algin.cpp +++ b/AlgorithmModule/src/AI_Edge_Algin.cpp @@ -248,7 +248,14 @@ int AI_Edge_Algin::Detect(const cv::Mat &img, DetConfig *pDetConfig, std::shared re0 = Get_Edge(0, img, pDetConfig, m_pDetConfig->strChannel, Big_roi, Big_outimg, true); cv::Mat Big_outimg_src = img(Big_roi[0].boundingRect()); vecThreads.emplace_back([&]() { re1 = Get_Edge(1, Big_outimg_src, pDetConfig, m_pDetConfig->strChannel, Small_roi, Small_outimg, false); }); - vecThreads.emplace_back([&]() { re2 = Get_Edge(2, Big_outimg_src, pDetConfig, m_pDetConfig->strChannel, Tag_roi, Tag_outimg, false); }); + if (pDetConfig->bDetTag) + { + vecThreads.emplace_back([&]() { re2 = Get_Edge(2, Big_outimg_src, pDetConfig, m_pDetConfig->strChannel, Tag_roi, Tag_outimg, false); }); + } + else + { + m_pdetlog->AddCheckstr(PrintLevel_2, DET_LOG_LEVEL_3, "AI_Edge_Algin ", "bDetTag close, skip Tag_Loc"); + } for (auto &t : vecThreads) { t.join(); diff --git a/AlgorithmModule/src/ImgCheckAnalysisy.cpp b/AlgorithmModule/src/ImgCheckAnalysisy.cpp index 238596b..b95814d 100644 --- a/AlgorithmModule/src/ImgCheckAnalysisy.cpp +++ b/AlgorithmModule/src/ImgCheckAnalysisy.cpp @@ -815,18 +815,26 @@ int ImgCheckAnalysisy::CheckRun() long handle_e = CheckUtil::getcurTime(); m_pdetlog->AddCheckstr(PrintLevel_1, DET_LOG_LEVEL_3, "Handle", "handle detect use time %ld", handle_e - handle_s); } - // 标签检测(独立步骤):暗场图像 + 明场 bigmask(不再沿用明场检出的标签) + // 标签检测(独立步骤):暗场图像 + 明场 bigmask(不再沿用明场检出的标签);bDetTag 关闭时跳过 { - long tag_s = CheckUtil::getcurTime(); - int reTag = CheckTagByBigMask(m_CheckResult_shareP->in_shareImage->img, m_pEdge_Align_Result->bigmask); - long tag_e = CheckUtil::getcurTime(); - m_pdetlog->AddCheckstr(PrintLevel_1, DET_LOG_LEVEL_3, "Tag", "tag detect use time %ld", tag_e - tag_s); - if (reTag != 0) + if (m_pFuntion->function.f_supportDet.bDetTag) { - m_pdetlog->AddCheckstr(PrintLevel_0, "Error", "CheckTagByBigMask is error type = %d", reTag); - m_nErrorCode = reTag; - m_nCheckResultErrorCode = m_nErrorCode; - return m_nErrorCode; + long tag_s = CheckUtil::getcurTime(); + int reTag = CheckTagByBigMask(m_CheckResult_shareP->in_shareImage->img, m_pEdge_Align_Result->bigmask); + long tag_e = CheckUtil::getcurTime(); + m_pdetlog->AddCheckstr(PrintLevel_1, DET_LOG_LEVEL_3, "Tag", "tag detect use time %ld", tag_e - tag_s); + if (reTag != 0) + { + m_pdetlog->AddCheckstr(PrintLevel_0, "Error", "CheckTagByBigMask is error type = %d", reTag); + m_nErrorCode = reTag; + m_nCheckResultErrorCode = m_nErrorCode; + return m_nErrorCode; + } + } + else + { + m_tag_roiList.clear(); + m_pdetlog->AddCheckstr(PrintLevel_1, DET_LOG_LEVEL_3, "Tag", "bDetTag close, skip tag detect"); } } } @@ -949,10 +957,11 @@ int ImgCheckAnalysisy::CheckRun() m_pdetlog->AddCheckstr(PrintLevel_0, "3、pre detect", "-------------------------pre Det--------------- \n"); - /* 检测支架偏移 */ + /* 检测支架偏移(bDetSupport 开关关闭时不做支架判定) */ { Function_Support_Det &supportDet = m_pFuntion->function.f_supportDet; - if (supportDet.bOpen && supportDet.supportRect.size.width > 0 && supportDet.supportRect.size.height > 0) + if (supportDet.bOpen && supportDet.bDetSupport && + supportDet.supportRect.size.width > 0 && supportDet.supportRect.size.height > 0) { cv::RotatedRect &inner = m_inner_rroi; cv::RotatedRect &support = supportDet.supportRect; @@ -1089,8 +1098,12 @@ int ImgCheckAnalysisy::CheckRun() } } - /* Tag检测 */ + /* Tag检测(bDetTag 关闭时不上报标签 NG) */ { + if (!m_pFuntion->function.f_supportDet.bDetTag) + { + m_tag_roiList.clear(); + } for (const auto &tagRoi : m_tag_roiList) { // tag roi 在原图坐标系,按摆正仿射转换到检测图(detImg)坐标系 @@ -2529,6 +2542,7 @@ int ImgCheckAnalysisy::AI_Edge(const cv::Mat &img, cv::RotatedRect &outerRoi, cv } config.strChannel = DetImgInfo_shareP->strChannel; config.pBaseCheckFunction = m_pbaseCheckFunction; + config.bDetTag = m_pFuntion->function.f_supportDet.bDetTag; // 标签检测开关:关闭时不跑 Tag_Loc /* 定位获取三个roi */ int re = m_pAI_Edge_Algin.Detect(img, &config, m_pEdge_Align_Result); @@ -2544,10 +2558,8 @@ int ImgCheckAnalysisy::AI_Edge(const cv::Mat &img, cv::RotatedRect &outerRoi, cv { innerRoi = m_pEdge_Align_Result->smallroi[0]; } - if (!m_pEdge_Align_Result->tagroi.empty()) - { - tagroiList = m_pEdge_Align_Result->tagroi; - } + // 无条件赋值:Tag_Loc 未检出或 bDetTag 关闭(tagroi 为空)时清空,避免残留上一张图的标签 + tagroiList = m_pEdge_Align_Result->tagroi; /*使用m_pEdge_Align_Result->bigmask检测把手是否缺失*/ {