From d64b07472ef331d87d550feb45f5f7f7a61dd252 Mon Sep 17 00:00:00 2001 From: liusiyang Date: Fri, 26 Jun 2026 11:16:03 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BF=AE=E6=94=B9=E4=B8=BA4=E7=9B=B8?= =?UTF-8?q?=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AlgorithmModule/src/CameraCheckAnalysisy.cpp | 7 ++- AlgorithmModule/src/ImgCheckAnalysisy.cpp | 14 +++--- ConfigModule/src/ConfigManager.cpp | 3 +- example/Read_Image.cpp | 52 ++++++++++++-------- example/SystemCommonDefine.h | 9 +++- example/deal.cpp | 36 ++++++++++---- 6 files changed, 79 insertions(+), 42 deletions(-) diff --git a/AlgorithmModule/src/CameraCheckAnalysisy.cpp b/AlgorithmModule/src/CameraCheckAnalysisy.cpp index bc36188..0295a84 100644 --- a/AlgorithmModule/src/CameraCheckAnalysisy.cpp +++ b/AlgorithmModule/src/CameraCheckAnalysisy.cpp @@ -105,7 +105,7 @@ string JudgeMaterialPosition(Mat img) { bool ifExchange(cv::Mat &img, const cv::Mat &img_B, std::string strcam ){ string img_position = JudgeMaterialPosition(img); string img_B_position = JudgeMaterialPosition(img_B); - if (strcam == "TA"){ + if (strcam.find("TA") != std::string::npos){ if (img_position == "Left" && img_B_position == "Right"){ return true; } @@ -163,6 +163,9 @@ int CameraCheckAnalysisy::Detect_Pre() int re = Mergimg(pImageResult->result->in_shareImage->img, pImageResult->result->in_shareImage->img_B, pImageResult->result->in_shareImage->strCameraName, pImageResult->result->in_shareImage->strChannel); + // 拼接完成后 img_B 不再需要,立即释放内存 + pImageResult->result->in_shareImage->img_B.release(); + if (pImageResult->result->in_shareImage->Det_Mode == DET_MODE_MergeImg) { cv::imwrite(pImageResult->result->in_shareImage->strCameraName + "_MergeImg.png", pImageResult->result->in_shareImage->img); @@ -188,7 +191,7 @@ int CameraCheckAnalysisy::Mergimg(cv::Mat &img, const cv::Mat &img_B, std::strin cv::Mat AllImg = cv::Mat::zeros(img.rows, img.cols * 2, img.type()); // cv::imwrite(strcam + strchannel + "_img.png", img); // cv::imwrite(strcam + strchannel + "img_B.png", img_B); - if (strcam == "TA") + if (strcam.find("TA") != std::string::npos) { cv::Rect Left_Tem_Roi; cv::Point Left_Tem_Point_Up; diff --git a/AlgorithmModule/src/ImgCheckAnalysisy.cpp b/AlgorithmModule/src/ImgCheckAnalysisy.cpp index 5d41fb7..a8f7e10 100644 --- a/AlgorithmModule/src/ImgCheckAnalysisy.cpp +++ b/AlgorithmModule/src/ImgCheckAnalysisy.cpp @@ -181,7 +181,7 @@ int ImgCheckAnalysisy::GetStatus() std::string ImgCheckAnalysisy::GetVersion() { - return std::string("BOE_1.7.91"); + return std::string("BOE_1.0.0"); } std::string ImgCheckAnalysisy::GetErrorInfo() @@ -1189,7 +1189,7 @@ int ImgCheckAnalysisy::GetALLBlob() ERROR_DOTS_BLOBS blobs_big_2; memset(&blobs_big_2, 0x00, sizeof(ERROR_DOTS_BLOBS)); printf("=====>>>> GetALLBlob m_strCurDetChannel %s \n", m_strCurDetChannel.c_str()); - if (m_strCurDetChannel == "CA") + if (m_strCurDetChannel.find("CA") != std::string::npos) { printf("=====>>>>GetALLBlob USE CA %s \n", m_strCurDetChannel.c_str()); GetBlobs_ALL_New(&blobs_v1, pGrayErrordata, m_ImgBlobHFlagData, width, height, 15); @@ -1483,7 +1483,7 @@ int ImgCheckAnalysisy::AI_Detect_Thread(const cv::Mat &img, cv::Mat &ResultImg) { std::shared_ptr pAIDet; // printf("=====>>>>AI_Detect_Thread m_strCurDetChannel %s \n", m_strCurDetChannel.c_str()); - if (m_strCurDetChannel == "CA") + if (m_strCurDetChannel.find("CA") != std::string::npos) { // printf("=====>>>>AI_Detect_Thread USE CA %s \n", m_strCurDetChannel.c_str()); pAIDet = AI_Factory->CELL_CA_Det; @@ -1615,7 +1615,7 @@ int ImgCheckAnalysisy::AI_Detect_Thread(const cv::Mat &img, cv::Mat &ResultImg) int ImgCheckAnalysisy::Traditional_Detect_Thread(const cv::Mat &img, cv::Mat &ResultImg) { std::string strBaseLog = "Traditional_Detect"; - m_pdetlog->AddCheckstr(PrintLevel_0, DET_LOG_LEVEL_3, strBaseLog, "Traditional_Detect Start (placeholder)"); + m_pdetlog->AddCheckstr(PrintLevel_0, DET_LOG_LEVEL_3, strBaseLog, "Traditional_Detect Start"); // 输出与AI推理相同格式的二值mask图 (CV_8UC1) ResultImg = cv::Mat::zeros(img.size(), CV_8UC1); @@ -1626,7 +1626,7 @@ int ImgCheckAnalysisy::Traditional_Detect_Thread(const cv::Mat &img, cv::Mat &Re // 输出: ResultImg (二值mask, CV_8UC1, 0/255) // ========================================== - m_pdetlog->AddCheckstr(PrintLevel_0, DET_LOG_LEVEL_3, strBaseLog, "Traditional_Detect End (placeholder)"); + m_pdetlog->AddCheckstr(PrintLevel_0, DET_LOG_LEVEL_3, strBaseLog, "Traditional_Detect End"); return 0; } @@ -1637,7 +1637,7 @@ int ImgCheckAnalysisy::AI_QX_Class_Thread() std::shared_ptr pAIDet; // printf("=====>>>>AI_QX_Class_Thread m_strCurDetChannel %s \n", m_strCurDetChannel.c_str()); - if (m_strCurDetChannel == "CA") + if (m_strCurDetChannel.find("CA") != std::string::npos) { // printf("=====>>>>AI_QX_Class_Thread USE CA %s \n", m_strCurDetChannel.c_str()); pAIDet = AI_Factory->CELL_CA_Cls; @@ -1765,7 +1765,7 @@ int ImgCheckAnalysisy::AI_QX_Class_Thread() std::string saveimgpaht = ""; - if (m_strCurDetChannel == "TA") + if (m_strCurDetChannel.find("TA") != std::string::npos) { saveimgpaht = m_strRootPath_TA_cls + std::to_string(cls_num) + "/" + std::to_string(CheckUtil::getcurTime()) + "_" + std::to_string(result->cls_score) + ".png"; } diff --git a/ConfigModule/src/ConfigManager.cpp b/ConfigModule/src/ConfigManager.cpp index f913b5d..0fce4fd 100644 --- a/ConfigModule/src/ConfigManager.cpp +++ b/ConfigModule/src/ConfigManager.cpp @@ -134,7 +134,8 @@ int ConfigManager::UpdateConfig() ReadFlawCodeConfig(defect_list_file); bool bFileName = false; // std::regex pattern(R"(param_[0-9]\.json)"); - std::regex pattern(R"(param_(\d+|left|right)\.json)"); + // 匹配 param_XXX.json (e.g. param_BCA.json, param_BTA.json, param_DCA.json, param_DTA.json) + std::regex pattern(R"(param_[A-Za-z0-9]+\.json)"); if (!fs::exists(m_strConfigRootPath)) { std::cerr << "目录不存在: " << m_strConfigRootPath << std::endl; diff --git a/example/Read_Image.cpp b/example/Read_Image.cpp index fa06f1b..6d37a9a 100644 --- a/example/Read_Image.cpp +++ b/example/Read_Image.cpp @@ -207,13 +207,15 @@ std::string Extract_ALL::Extract_Camera_Name(std::string strPath, int userflag) fs::path p = fs::path(strPath); std::string filename = p.stem(); - // 文件名包含 CA 或 TA 即判定对应相机 - // 支持旧格式: CA_20250508074237.ytimage - // 支持新格式: A_CAA.png, M_CAB.png (A_/M_ 仅是打光方式,同属一个camera) - if (filename.find("TA") != std::string::npos) - return "TA"; - else if (filename.find("CA") != std::string::npos) - return "CA"; + // 文件名包含 BCA/BTA/DCA/DTA/CA/TA 即判定对应相机 + if (filename.find("BCA") != std::string::npos) + return "BCA"; + else if (filename.find("DCA") != std::string::npos) + return "DCA"; + else if (filename.find("BTA") != std::string::npos) + return "BTA"; + else if (filename.find("DTA") != std::string::npos) + return "DTA"; return ""; } @@ -247,32 +249,40 @@ std::string Extract_ALL::Extract_Channel_Name(std::string strPath, int userflag) fs::path p = fs::path(strPath); std::string filename = p.stem(); - // 新格式: {Prefix}_{Type}{AB}, 如 A_CAA, M_TAB + // 新格式: {Prefix}_{Camera}{AB}, 如 A_BCAA, M_DTAB, A_BCAB // 通道名 = 前缀 (A/M), 表示不同打光方式 + // 支持4相机: BCAA, BCAB, BTAA, BTAB, DCAA, DCAB, DTAA, DTAB size_t underscorePos = filename.find('_'); if (underscorePos != std::string::npos) { std::string prefix = filename.substr(0, underscorePos); std::string rest = filename.substr(underscorePos + 1); - if (rest == "CAA" || rest == "CAB" || rest == "TAA" || rest == "TAB") + // 4相机格式 + if (rest == "BCAA" || rest == "BCAB" || rest == "BTAA" || rest == "BTAB" || + rest == "DCAA" || rest == "DCAB" || rest == "DTAA" || rest == "DTAB" ) { return prefix; // "A" or "M" } } // 旧格式兼容: CA_xxx.ytimage, TA_xxx.ytimage - if (filename.find("TAA") != std::string::npos) - strchannelName = "TA"; - else if (filename.find("TAB") != std::string::npos) - strchannelName = "TA"; - else if (filename.find("CAA") != std::string::npos) - strchannelName = "CA"; - else if (filename.find("CAB") != std::string::npos) - strchannelName = "CA"; - else if (filename.find("CA") != std::string::npos) - strchannelName = "CA"; - else if (filename.find("TA") != std::string::npos) - strchannelName = "TA"; + // 4相机格式兼容: BCA_xxx, BTA_xxx, DCA_xxx, DTA_xxx + if (filename.find("BCAA") != std::string::npos || filename.find("BCAB") != std::string::npos) + strchannelName = "BCA"; + else if (filename.find("BTAA") != std::string::npos || filename.find("BTAB") != std::string::npos) + strchannelName = "BTA"; + else if (filename.find("DCAA") != std::string::npos || filename.find("DCAB") != std::string::npos) + strchannelName = "DCA"; + else if (filename.find("DTAA") != std::string::npos || filename.find("DTAB") != std::string::npos) + strchannelName = "DTA"; + else if (filename.find("BCA") != std::string::npos) + strchannelName = "BCA"; + else if (filename.find("BTA") != std::string::npos) + strchannelName = "BTA"; + else if (filename.find("DCA") != std::string::npos) + strchannelName = "DCA"; + else if (filename.find("DTA") != std::string::npos) + strchannelName = "DTA"; return strchannelName; } int Extract_ALL::Read_Image_List(std::string strPath, std::string strproduct) diff --git a/example/SystemCommonDefine.h b/example/SystemCommonDefine.h index fda622a..773cce8 100644 --- a/example/SystemCommonDefine.h +++ b/example/SystemCommonDefine.h @@ -105,8 +105,10 @@ enum START_SYSTEM_STEP_ }; struct SystemConfigParam { - std::string Analysis_Config_path; - std::string Analysis_Config_path_Cam2; + std::string Analysis_Config_path; // Cam1: BCA + std::string Analysis_Config_path_Cam2; // Cam2: BTA + std::string Analysis_Config_path_Cam3; // Cam3: DCA + std::string Analysis_Config_path_Cam4; // Cam4: DTA std::string Check_Config_path; std::string config_Root_Path; @@ -125,6 +127,9 @@ struct SystemConfigParam bool valid() { if (Analysis_Config_path.size() && + Analysis_Config_path_Cam2.size() && + Analysis_Config_path_Cam3.size() && + Analysis_Config_path_Cam4.size() && Check_Config_path.size() && preCheckImg_Path.size() && config_Root_Path.size() && diff --git a/example/deal.cpp b/example/deal.cpp index 3172e92..b8f467f 100644 --- a/example/deal.cpp +++ b/example/deal.cpp @@ -1085,6 +1085,8 @@ bool deal::ReadSystemConfig(const std::string &strPath) // path m_system_param.Analysis_Config_path = root["Analysis_Config_path"].asString(); m_system_param.Analysis_Config_path_Cam2 = root["Analysis_Config_path_Cam2"].asString(); + m_system_param.Analysis_Config_path_Cam3 = root["Analysis_Config_path_Cam3"].asString(); + m_system_param.Analysis_Config_path_Cam4 = root["Analysis_Config_path_Cam4"].asString(); m_system_param.config_Root_Path = root["Config_Root_Path"].asString(); m_system_param.Check_Config_path = root["Check_Config_path"].asString(); @@ -1162,14 +1164,22 @@ int deal::GetImgInfo_POL_ET(std::string strImgPath, JC_IMAGE_INFO_ *pImageInfo) std::string strImageChannel; - // 使用 find 检查是否包含 "CA" 或 "TA" - if (strName.find("CA") != std::string::npos || strName.find("CF") != std::string::npos) + // 使用 find 检查是否包含 4 个相机标识 (BCA, BTA, DCA, DTA) 及兼容旧 CA/TA + if (strName.find("BCA") != std::string::npos) { - strImageChannel = "CA"; + strImageChannel = "BCA"; } - else if (strName.find("TA") != std::string::npos || strName.find("TFT") != std::string::npos) + else if (strName.find("BTA") != std::string::npos) { - strImageChannel = "TA"; + strImageChannel = "BTA"; + } + else if (strName.find("DCA") != std::string::npos) + { + strImageChannel = "DCA"; + } + else if (strName.find("DTA") != std::string::npos) + { + strImageChannel = "DTA"; } else { @@ -1582,13 +1592,21 @@ int deal::ReJson_product(std::vector &jsonList, std::string strPr std::cout << str1 << std::endl; std::cout << str2 << std::endl; - if (str1.find("CA") != std::string::npos) + if (str1.find("BCA") != std::string::npos) + { + str2 = "BCA"; + } + else if (str1.find("BTA") != std::string::npos) + { + str2 = "BTA"; + } + else if (str1.find("DCA") != std::string::npos) { - str2 = "CA"; + str2 = "DCA"; } - else if (str1.find("TA") != std::string::npos) + else if (str1.find("DTA") != std::string::npos) { - str2 = "TA"; + str2 = "DTA"; } else {