From 494d0da8f72cfaeaa56becda66fec87393d99c2a Mon Sep 17 00:00:00 2001 From: liusiyang Date: Mon, 1 Jun 2026 12:00:00 +0800 Subject: [PATCH] =?UTF-8?q?fix=20paraMaskImg=E6=B7=BB=E5=8A=A0clone?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AlgorithmModule/src/Edge_Search.cpp | 46 ++++++++++++++++------- AlgorithmModule/src/ImgCheckAnalysisy.cpp | 2 +- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/AlgorithmModule/src/Edge_Search.cpp b/AlgorithmModule/src/Edge_Search.cpp index ce2d45d..70054b2 100644 --- a/AlgorithmModule/src/Edge_Search.cpp +++ b/AlgorithmModule/src/Edge_Search.cpp @@ -212,9 +212,18 @@ int Edge_Search::Detect_AI(const cv::Mat &detimg, DetConfigResult *pDetConfig, s int Edge_Search::Detect_Draw(const cv::Mat &detimg, DetConfigResult *pDetConfig, std::shared_ptr &pEdgeDetResult) { Function_EdgeROI *pEdgeROI = pDetConfig->pEdgeROI; - cv::Mat paraMaskImg = pEdgeROI->EdgeMask; + cv::Mat paraMaskImg = pEdgeROI->EdgeMask.clone(); bool bsucc = false; cv::Rect roi; + if (pDetConfig) + { + for (auto p:pDetConfig->pEdgeROI->pointArry1) + { + m_pdetlog->AddCheckstr(PrintLevel_3, "Detect_Draw", "pointArry1: %d , %d", p.x, p.y); + } + + } + if (!paraMaskImg.empty()) { if (pDetConfig->bDebugsaveImg) @@ -228,27 +237,36 @@ int Edge_Search::Detect_Draw(const cv::Mat &detimg, DetConfigResult *pDetConfig, pEdgeDetResult->shieldMask_Src = paraMaskImg; // m_DetEdge.detmask = paraMaskImg; // 查找轮廓 - std::vector> contours; - std::vector hierarchy; - cv::findContours(paraMaskImg, contours, hierarchy, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE); + // std::vector> contours; + // std::vector hierarchy; + // cv::findContours(paraMaskImg.clone(), contours, hierarchy, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE); // 找到最大轮廓 int max_contour_index = -1; double max_area = 0; - for (size_t i = 0; i < contours.size(); i++) + // for (size_t i = 0; i < contours.size(); i++) + // { + // double area = cv::contourArea(contours[i]); + // if (area > max_area) + // { + // max_area = area; + // max_contour_index = i; + // } + // } + if(pDetConfig->pEdgeROI->pointArry1.size() > 0) { - double area = cv::contourArea(contours[i]); - if (area > max_area) + // roi = cv::boundingRect(contours[max_contour_index]); + roi = cv::boundingRect(pDetConfig->pEdgeROI->pointArry1); + m_pdetlog->AddCheckstr(PrintLevel_3, "Detect_Draw", "ROI %d %d %d %d", roi.x, roi.y, roi.width, roi.height); + if(CheckUtil::JudgRect(roi, pEdgeROI->EdgeMask.cols, pEdgeROI->EdgeMask.rows)) { - max_area = area; - max_contour_index = i; + bsucc = true; + } + else + { + m_pdetlog->AddCheckstr(PrintLevel_3, "Detect_Draw", "Error DrMaskImg Get roi out of range"); } - } - if (max_contour_index >= 0) - { - roi = cv::boundingRect(contours[max_contour_index]); - bsucc = true; } else { diff --git a/AlgorithmModule/src/ImgCheckAnalysisy.cpp b/AlgorithmModule/src/ImgCheckAnalysisy.cpp index e18f897..6390ad9 100644 --- a/AlgorithmModule/src/ImgCheckAnalysisy.cpp +++ b/AlgorithmModule/src/ImgCheckAnalysisy.cpp @@ -170,7 +170,7 @@ int ImgCheckAnalysisy::GetStatus() std::string ImgCheckAnalysisy::GetVersion() { - return std::string("BOE_1.7.51"); + return std::string("BOE_1.2.0"); } std::string ImgCheckAnalysisy::GetErrorInfo()