update 修改为4相机

dev_lsy
liusiyang 1 month ago
parent 6da5477823
commit d64b07472e

@ -105,7 +105,7 @@ string JudgeMaterialPosition(Mat img) {
bool ifExchange(cv::Mat &img, const cv::Mat &img_B, std::string strcam ){ bool ifExchange(cv::Mat &img, const cv::Mat &img_B, std::string strcam ){
string img_position = JudgeMaterialPosition(img); string img_position = JudgeMaterialPosition(img);
string img_B_position = JudgeMaterialPosition(img_B); 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"){ if (img_position == "Left" && img_B_position == "Right"){
return true; return true;
} }
@ -163,6 +163,9 @@ int CameraCheckAnalysisy::Detect_Pre()
int re = Mergimg(pImageResult->result->in_shareImage->img, pImageResult->result->in_shareImage->img_B, int re = Mergimg(pImageResult->result->in_shareImage->img, pImageResult->result->in_shareImage->img_B,
pImageResult->result->in_shareImage->strCameraName, pImageResult->result->in_shareImage->strChannel); 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) if (pImageResult->result->in_shareImage->Det_Mode == DET_MODE_MergeImg)
{ {
cv::imwrite(pImageResult->result->in_shareImage->strCameraName + "_MergeImg.png", pImageResult->result->in_shareImage->img); 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::Mat AllImg = cv::Mat::zeros(img.rows, img.cols * 2, img.type());
// cv::imwrite(strcam + strchannel + "_img.png", img); // cv::imwrite(strcam + strchannel + "_img.png", img);
// cv::imwrite(strcam + strchannel + "img_B.png", img_B); // 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::Rect Left_Tem_Roi;
cv::Point Left_Tem_Point_Up; cv::Point Left_Tem_Point_Up;

@ -181,7 +181,7 @@ int ImgCheckAnalysisy::GetStatus()
std::string ImgCheckAnalysisy::GetVersion() std::string ImgCheckAnalysisy::GetVersion()
{ {
return std::string("BOE_1.7.91"); return std::string("BOE_1.0.0");
} }
std::string ImgCheckAnalysisy::GetErrorInfo() std::string ImgCheckAnalysisy::GetErrorInfo()
@ -1189,7 +1189,7 @@ int ImgCheckAnalysisy::GetALLBlob()
ERROR_DOTS_BLOBS blobs_big_2; ERROR_DOTS_BLOBS blobs_big_2;
memset(&blobs_big_2, 0x00, sizeof(ERROR_DOTS_BLOBS)); memset(&blobs_big_2, 0x00, sizeof(ERROR_DOTS_BLOBS));
printf("=====>>>> GetALLBlob m_strCurDetChannel %s \n", m_strCurDetChannel.c_str()); 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()); printf("=====>>>>GetALLBlob USE CA %s \n", m_strCurDetChannel.c_str());
GetBlobs_ALL_New(&blobs_v1, pGrayErrordata, m_ImgBlobHFlagData, width, height, 15); 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<AIModel_Base> pAIDet; std::shared_ptr<AIModel_Base> pAIDet;
// printf("=====>>>>AI_Detect_Thread m_strCurDetChannel %s \n", m_strCurDetChannel.c_str()); // 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()); // printf("=====>>>>AI_Detect_Thread USE CA %s \n", m_strCurDetChannel.c_str());
pAIDet = AI_Factory->CELL_CA_Det; 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) int ImgCheckAnalysisy::Traditional_Detect_Thread(const cv::Mat &img, cv::Mat &ResultImg)
{ {
std::string strBaseLog = "Traditional_Detect"; 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) // 输出与AI推理相同格式的二值mask图 (CV_8UC1)
ResultImg = cv::Mat::zeros(img.size(), 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) // 输出: 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; return 0;
} }
@ -1637,7 +1637,7 @@ int ImgCheckAnalysisy::AI_QX_Class_Thread()
std::shared_ptr<AIModel_Base> pAIDet; std::shared_ptr<AIModel_Base> pAIDet;
// printf("=====>>>>AI_QX_Class_Thread m_strCurDetChannel %s \n", m_strCurDetChannel.c_str()); // 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()); // printf("=====>>>>AI_QX_Class_Thread USE CA %s \n", m_strCurDetChannel.c_str());
pAIDet = AI_Factory->CELL_CA_Cls; pAIDet = AI_Factory->CELL_CA_Cls;
@ -1765,7 +1765,7 @@ int ImgCheckAnalysisy::AI_QX_Class_Thread()
std::string saveimgpaht = ""; 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"; saveimgpaht = m_strRootPath_TA_cls + std::to_string(cls_num) + "/" + std::to_string(CheckUtil::getcurTime()) + "_" + std::to_string(result->cls_score) + ".png";
} }

@ -134,7 +134,8 @@ int ConfigManager::UpdateConfig()
ReadFlawCodeConfig(defect_list_file); ReadFlawCodeConfig(defect_list_file);
bool bFileName = false; bool bFileName = false;
// std::regex pattern(R"(param_[0-9]\.json)"); // 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)) if (!fs::exists(m_strConfigRootPath))
{ {
std::cerr << "目录不存在: " << m_strConfigRootPath << std::endl; std::cerr << "目录不存在: " << m_strConfigRootPath << std::endl;

@ -207,13 +207,15 @@ std::string Extract_ALL::Extract_Camera_Name(std::string strPath, int userflag)
fs::path p = fs::path(strPath); fs::path p = fs::path(strPath);
std::string filename = p.stem(); std::string filename = p.stem();
// 文件名包含 CA 或 TA 即判定对应相机 // 文件名包含 BCA/BTA/DCA/DTA/CA/TA 即判定对应相机
// 支持旧格式: CA_20250508074237.ytimage if (filename.find("BCA") != std::string::npos)
// 支持新格式: A_CAA.png, M_CAB.png (A_/M_ 仅是打光方式同属一个camera) return "BCA";
if (filename.find("TA") != std::string::npos) else if (filename.find("DCA") != std::string::npos)
return "TA"; return "DCA";
else if (filename.find("CA") != std::string::npos) else if (filename.find("BTA") != std::string::npos)
return "CA"; return "BTA";
else if (filename.find("DTA") != std::string::npos)
return "DTA";
return ""; return "";
} }
@ -247,32 +249,40 @@ std::string Extract_ALL::Extract_Channel_Name(std::string strPath, int userflag)
fs::path p = fs::path(strPath); fs::path p = fs::path(strPath);
std::string filename = p.stem(); std::string filename = p.stem();
// 新格式: {Prefix}_{Type}{AB}, 如 A_CAA, M_TAB // 新格式: {Prefix}_{Camera}{AB}, 如 A_BCAA, M_DTAB, A_BCAB
// 通道名 = 前缀 (A/M), 表示不同打光方式 // 通道名 = 前缀 (A/M), 表示不同打光方式
// 支持4相机: BCAA, BCAB, BTAA, BTAB, DCAA, DCAB, DTAA, DTAB
size_t underscorePos = filename.find('_'); size_t underscorePos = filename.find('_');
if (underscorePos != std::string::npos) if (underscorePos != std::string::npos)
{ {
std::string prefix = filename.substr(0, underscorePos); std::string prefix = filename.substr(0, underscorePos);
std::string rest = filename.substr(underscorePos + 1); 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" return prefix; // "A" or "M"
} }
} }
// 旧格式兼容: CA_xxx.ytimage, TA_xxx.ytimage // 旧格式兼容: CA_xxx.ytimage, TA_xxx.ytimage
if (filename.find("TAA") != std::string::npos) // 4相机格式兼容: BCA_xxx, BTA_xxx, DCA_xxx, DTA_xxx
strchannelName = "TA"; if (filename.find("BCAA") != std::string::npos || filename.find("BCAB") != std::string::npos)
else if (filename.find("TAB") != std::string::npos) strchannelName = "BCA";
strchannelName = "TA"; else if (filename.find("BTAA") != std::string::npos || filename.find("BTAB") != std::string::npos)
else if (filename.find("CAA") != std::string::npos) strchannelName = "BTA";
strchannelName = "CA"; else if (filename.find("DCAA") != std::string::npos || filename.find("DCAB") != std::string::npos)
else if (filename.find("CAB") != std::string::npos) strchannelName = "DCA";
strchannelName = "CA"; else if (filename.find("DTAA") != std::string::npos || filename.find("DTAB") != std::string::npos)
else if (filename.find("CA") != std::string::npos) strchannelName = "DTA";
strchannelName = "CA"; else if (filename.find("BCA") != std::string::npos)
else if (filename.find("TA") != std::string::npos) strchannelName = "BCA";
strchannelName = "TA"; 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; return strchannelName;
} }
int Extract_ALL::Read_Image_List(std::string strPath, std::string strproduct) int Extract_ALL::Read_Image_List(std::string strPath, std::string strproduct)

@ -105,8 +105,10 @@ enum START_SYSTEM_STEP_
}; };
struct SystemConfigParam struct SystemConfigParam
{ {
std::string Analysis_Config_path; std::string Analysis_Config_path; // Cam1: BCA
std::string Analysis_Config_path_Cam2; 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 Check_Config_path;
std::string config_Root_Path; std::string config_Root_Path;
@ -125,6 +127,9 @@ struct SystemConfigParam
bool valid() bool valid()
{ {
if (Analysis_Config_path.size() && if (Analysis_Config_path.size() &&
Analysis_Config_path_Cam2.size() &&
Analysis_Config_path_Cam3.size() &&
Analysis_Config_path_Cam4.size() &&
Check_Config_path.size() && Check_Config_path.size() &&
preCheckImg_Path.size() && preCheckImg_Path.size() &&
config_Root_Path.size() && config_Root_Path.size() &&

@ -1085,6 +1085,8 @@ bool deal::ReadSystemConfig(const std::string &strPath)
// path // path
m_system_param.Analysis_Config_path = root["Analysis_Config_path"].asString(); 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_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.config_Root_Path = root["Config_Root_Path"].asString();
m_system_param.Check_Config_path = root["Check_Config_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; std::string strImageChannel;
// 使用 find 检查是否包含 "CA" 或 "TA" // 使用 find 检查是否包含 4 个相机标识 (BCA, BTA, DCA, DTA) 及兼容旧 CA/TA
if (strName.find("CA") != std::string::npos || strName.find("CF") != std::string::npos) 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 else
{ {
@ -1582,13 +1592,21 @@ int deal::ReJson_product(std::vector<Json_Det_Path> &jsonList, std::string strPr
std::cout << str1 << std::endl; std::cout << str1 << std::endl;
std::cout << str2 << 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 else
{ {

Loading…
Cancel
Save