update 修改读取defect_list方式

main
liusiyang 3 weeks ago
parent f5748700b7
commit dca60c28e1

@ -429,7 +429,14 @@ int ALLImgCheckAnalysisy::ExitSystem()
int ALLImgCheckAnalysisy::InitCameraCheckAnalysisy()
{
ReadFlawCodeConfig("/var/aidlux/efs/cell_aoi/model/defect_list.json");
string defect_list_file = m_pConfigManager->GetJsonPath();
if (defect_list_file == "") {
defect_list_file = "/var/aidlux/efs/model/defect_list.json";
}
else{
defect_list_file += "/defect_list.json";
}
ReadFlawCodeConfig(defect_list_file);
m_pCameraCheckAnalysisyList.clear();
// m_pQX_Merge_Analysis->Clear();
for (const auto &config : m_pConfigManager->Config_instances_)

@ -82,6 +82,7 @@ public:
virtual int LoadAnalysisConfig(std::string strConfigPath) = 0;
virtual int UpdateConfig() = 0;
virtual int GetConfig(int nConfigType, void *pconfig) = 0;
virtual std::string GetJsonPath() = 0;
static ConfigManagerBase *m_pInstance;
public:

@ -34,6 +34,7 @@ public:
int LoadAnalysisConfig(std::string strConfigPath);
int UpdateConfig();
int GetConfig(int nConfigType, void *pconfig);
std::string GetJsonPath();
struct CameraParam
{
std::string identity;

@ -10,6 +10,7 @@
#include "ConfigManager.h"
#include <regex>
#include "ConfigBase.h"
#include "../../AlgorithmModule/include/ImgCheckConfig.h"
ConfigManager::ConfigManager()
{
@ -20,6 +21,120 @@ ConfigManager::~ConfigManager()
{
}
std::vector <std::string> QX_Result_Names =
{
"OK",
"AD_YX",
"X_Line",
"Y_Line",
"fangge",
"Rubbing_Mura",
"Broken_line",
"ZARA",
"MTX",
"POL_Cell",
"Bright_Point",
"Dark_Point",
"BLack_Point",
"White_Point",
"Scratch",
"Weak_Bright_Mura",
"No_Label",
"Bright_Mura_Exe",
"Sweak_Line_Dark",
"STEAM_POCKET",
"Dirty",
"other",
"Cell_W",
"Cell_B",
"LackPol"};
std::vector <std::string> QX_Result_Code =
{
"P1153",
"P6873",
"P3351",
"P3452",
"P3453",
"P1550",
"P3379",
"P1153",
"P1164",
"P1101",
"P1112",
"P1111",
"P1104",
"P1103",
"P1557",
"P1654",
"P2833",
"P1549",
"P1204",
"P2534",
"P2534",
"P1101",
"P1103",
"P1104",
"P8001",
};
int ReadFlawCodeConfig(std::string json_path)
{
m_FlawCodeList.erase(m_FlawCodeList.begin(), m_FlawCodeList.end());
std::string strPath = json_path;
printf("ReadFlawCodeConfig path %s\n", strPath.c_str());
Json::CharReaderBuilder builder;
builder["collectComments"] = true;
Json::Value root;
std::string err;
std::ifstream ifs(strPath);
if (!ifs.is_open())
{
printf("error:file is open\n");
return 0;
}
if (!Json::parseFromStream(builder, ifs, &root, &err))
{
printf("error:parseFromStream\n");
return 0;
}
for (int i = 0; i < root.size(); i++)
{
// printf("Node idx %d /%d \n", i, root.size());
ReadFlawCode tem;
tem.flaw_name = root[i]["zh_name"].asString();
tem.flaw_code = root[i]["en_name"].asString();
string desc = root[i]["desc"].asString();
{
std::istringstream stream(desc);
std::string token;
// 使用 getline 按照分号分割
while (std::getline(stream, token, ';'))
{
tem.config_flaw_name.push_back(token);
}
}
m_FlawCodeList.push_back(tem);
}
for(int i = 0; i < m_FlawCodeList.size(); i++)
{
if(i >= QX_Result_Names.size()) {
QX_Result_Names.push_back(m_FlawCodeList.at(i).flaw_name);
QX_Result_Code.push_back(m_FlawCodeList.at(i).flaw_code);
}
else
{
QX_Result_Names.at(i) = m_FlawCodeList.at(i).flaw_name;
QX_Result_Code.at(i) = m_FlawCodeList.at(i).flaw_code;
}
}
return 0;
}
int ConfigManager::LoadParamConfig(std::shared_ptr<ConfigBase> &Config, std::string strConfigPath)
{
Json::Reader json_reader;
@ -58,8 +173,21 @@ int ConfigManager::LoadAnalysisConfig(std::string strConfigPath)
return re;
}
std::string ConfigManager::GetJsonPath()
{
return m_strConfigRootPath;
}
int ConfigManager::UpdateConfig()
{
string defect_list_file = GetJsonPath();
if (defect_list_file == "") {
defect_list_file = "/var/aidlux/efs/model/defect_list.json";
}
else{
defect_list_file += "/defect_list.json";
}
ReadFlawCodeConfig(defect_list_file);
std::vector<CameraParam> camera_list;
int re = ReadParamName(camera_list);
if (re != 0)

Loading…
Cancel
Save