|
|
|
@ -12,99 +12,6 @@
|
|
|
|
#include "AI_Factory.h"
|
|
|
|
#include "AI_Factory.h"
|
|
|
|
#include <fstream>
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<ReadFlawCode> m_FlawCodeList;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> QX_Result_Names =
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"OK",
|
|
|
|
|
|
|
|
"aotudian",
|
|
|
|
|
|
|
|
"other",
|
|
|
|
|
|
|
|
"line",
|
|
|
|
|
|
|
|
"zangwu",
|
|
|
|
|
|
|
|
"edge",
|
|
|
|
|
|
|
|
"ymhs",
|
|
|
|
|
|
|
|
"dianzhuang",
|
|
|
|
|
|
|
|
"posun",
|
|
|
|
|
|
|
|
"xianwei",
|
|
|
|
|
|
|
|
"shuizi",
|
|
|
|
|
|
|
|
"danban",
|
|
|
|
|
|
|
|
"fuchen",
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<std::string> QX_Result_Code =
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"P0000",
|
|
|
|
|
|
|
|
"MA507",
|
|
|
|
|
|
|
|
"MA508",
|
|
|
|
|
|
|
|
"MA506",
|
|
|
|
|
|
|
|
"MA504",
|
|
|
|
|
|
|
|
"MA503",
|
|
|
|
|
|
|
|
"MA502",
|
|
|
|
|
|
|
|
"MA505",
|
|
|
|
|
|
|
|
"MA501",
|
|
|
|
|
|
|
|
"P0001",
|
|
|
|
|
|
|
|
"P0002",
|
|
|
|
|
|
|
|
"P0003",
|
|
|
|
|
|
|
|
"P0004",
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double calculateDistanceBetweenRectCenters(const cv::Rect &rect1, const cv::Rect &rect2, float fx, float fy)
|
|
|
|
double calculateDistanceBetweenRectCenters(const cv::Rect &rect1, const cv::Rect &rect2, float fx, float fy)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// 计算矩形1的中心点
|
|
|
|
// 计算矩形1的中心点
|
|
|
|
@ -519,14 +426,6 @@ int ALLImgCheckAnalysisy::ExitSystem()
|
|
|
|
|
|
|
|
|
|
|
|
int ALLImgCheckAnalysisy::InitCameraCheckAnalysisy()
|
|
|
|
int ALLImgCheckAnalysisy::InitCameraCheckAnalysisy()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
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_pCameraCheckAnalysisyList.clear();
|
|
|
|
for (const auto &config : m_pConfigManager->Config_instances_)
|
|
|
|
for (const auto &config : m_pConfigManager->Config_instances_)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|