You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1449 lines
62 KiB
1449 lines
62 KiB
#include "JsonConfig.h"
|
|
|
|
Json::Value CommonParamJson::toJsonValue()
|
|
{
|
|
return Json::Value();
|
|
}
|
|
|
|
void CommonParamJson::toObjectFromValue(Json::Value root)
|
|
{
|
|
_config.image = root["image"].asString();
|
|
_config.skuName = root["sku_name"].asString();
|
|
_config.value = root["value"].asString();
|
|
}
|
|
|
|
int CommonParamJson::GetConfig(CommonParamST &config)
|
|
{
|
|
config.copy(_config);
|
|
return 0;
|
|
}
|
|
|
|
Json::Value CommonParamToCheckConfigJson::toJsonValue()
|
|
{
|
|
return Json::Value();
|
|
}
|
|
|
|
// 读取和图片相关的参数
|
|
void CommonParamToCheckConfigJson::toObjectFromValue(Json::Value root)
|
|
{
|
|
|
|
auto strJson = root.asString();
|
|
Json::CharReaderBuilder builder;
|
|
std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
|
|
Json::Value rootvalue;
|
|
std::string err;
|
|
// std::cout << strJson << std::endl;
|
|
auto nSize = strJson.size();
|
|
if (reader->parse(strJson.c_str(), strJson.c_str() + nSize, &rootvalue, &err))
|
|
{
|
|
|
|
// 和节点无关参数提取
|
|
{
|
|
auto value = rootvalue["base"];
|
|
// std::cout << value << std::endl;
|
|
// getchar();
|
|
if (value.isObject())
|
|
{
|
|
_config.baseConfig.strConfigVersion = value["version"].asString();
|
|
if ( _config.baseConfig.strConfigVersion == "")
|
|
{
|
|
_config.baseConfig.strConfigVersion = "NULL";
|
|
}
|
|
_config.baseConfig.image_widht = value["image_widht"].asInt();
|
|
_config.baseConfig.Image_height = value["Image_height"].asInt();
|
|
_config.baseConfig.bDrawShieldRoi = value["bDrawShieldRoi"].asBool();
|
|
_config.baseConfig.bDrawPreRoi = value["Draw_PreROI"].asBool();
|
|
_config.baseConfig.bShield_ZF = value["bShield_ZF"].asBool();
|
|
_config.baseConfig.fUP_IOU = value["UP_IOU"].asFloat();
|
|
_config.baseConfig.fProduct_Off_X_mm = value["Product_Off_X"].asFloat();
|
|
_config.baseConfig.strCamName = value["cameraCode"].asString();
|
|
_config.baseConfig.strCamearName = value["cameraCode"].asString();
|
|
_config.baseConfig.bCal_ImageScale = value["bImageScale_Cal"].asBool();
|
|
_config.baseConfig.Product_Size_Width_mm = value["Product_Size_W"].asFloat();
|
|
_config.baseConfig.Product_Size_Height_mm = value["Product_Size_H"].asFloat();
|
|
_config.baseConfig.fImage_Scale_x = value["Image_Scale_X"].asFloat();
|
|
_config.baseConfig.fImage_Scale_y = value["Image_Scale_Y"].asFloat();
|
|
if (value["Density_R"])
|
|
{
|
|
_config.baseConfig.density_R_mm = value["Density_R"].asFloat();
|
|
if (_config.baseConfig.density_R_mm <= 0 || _config.baseConfig.density_R_mm > 99999)
|
|
{
|
|
_config.baseConfig.density_R_mm = 5;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 读取每个节点的参数
|
|
{
|
|
auto value_node = rootvalue["node"];
|
|
// 读取每个节点的参数
|
|
for (int i = 0; i < value_node.size(); i++)
|
|
{
|
|
printf("Node idx %d /%d \n", i, value_node.size());
|
|
|
|
CommonConfigNodeST tem_node;
|
|
// 和节点相关基础参数
|
|
{
|
|
auto value_node_base = value_node[i]["node_base"];
|
|
// std::cout << value_node_base << std::endl;
|
|
|
|
if (value_node_base.isObject())
|
|
{
|
|
|
|
tem_node.nodebasicConfog.calss_conf = value_node_base["class_conf"].asFloat();
|
|
tem_node.nodebasicConfog.calss_area = value_node_base["Class_AreaT"].asFloat();
|
|
|
|
// tem_node.nodebasicConfog.print("nodebasicConfog");
|
|
}
|
|
}
|
|
|
|
// 读取当前节点下 的每张图片 一般只读第一张图
|
|
{
|
|
auto value_node_imgs = value_node[i]["node_images"];
|
|
|
|
if (value_node_imgs.size() > 0)
|
|
{
|
|
int img_idx = 0;
|
|
tem_node.nodebasicConfog.img_width = value_node_imgs[img_idx]["width"].asInt();
|
|
tem_node.nodebasicConfog.img_height = value_node_imgs[img_idx]["height"].asInt();
|
|
|
|
auto value_node_imgs_region = value_node_imgs[img_idx]["params"];
|
|
printf("tem_node.img_height %d, tem_node.img_width %d region num %d\n",
|
|
tem_node.nodebasicConfog.img_height,
|
|
tem_node.nodebasicConfog.img_width,
|
|
value_node_imgs_region.size());
|
|
|
|
for (int region_idx = 0; region_idx < value_node_imgs_region.size(); region_idx++)
|
|
{
|
|
// printf("region idx %d /%d \n", region_idx, value_node_imgs_region.size());
|
|
|
|
RegionConfigST temRegion;
|
|
temRegion.buse = true;
|
|
// 1、读取基本参数
|
|
{
|
|
auto value_node_imgs_region_base = value_node_imgs_region[region_idx];
|
|
// std::cout<<value_node_imgs_region_base<<std::endl;
|
|
if (value_node_imgs_region_base.isObject())
|
|
{
|
|
temRegion.basicInfo.lay = value_node_imgs_region_base["tier"].asInt();
|
|
temRegion.basicInfo.type = value_node_imgs_region_base["areaType"].asInt();
|
|
temRegion.basicInfo.name = value_node_imgs_region_base["en_name"].asString();
|
|
temRegion.basicInfo.bdraw = value_node_imgs_region_base["bdraw"].asInt();
|
|
// printf("--- tier %d type %d\n ", temRegion.basicInfo.lay, temRegion.basicInfo.type);
|
|
}
|
|
}
|
|
// 读取通道
|
|
{
|
|
auto value_node_imgs_region_chanel = value_node_imgs_region[region_idx]["Channel_Param"]["channel"];
|
|
if (value_node_imgs_region_chanel.isArray())
|
|
{
|
|
for (int idx = 0; idx < value_node_imgs_region_chanel.size(); idx++)
|
|
{
|
|
std::string str = value_node_imgs_region_chanel[idx].asString();
|
|
temRegion.basicInfo.ChannelArry.emplace_back(str);
|
|
}
|
|
}
|
|
}
|
|
// 2、读取区域点
|
|
{
|
|
auto value_node_imgs_region_coord = value_node_imgs_region[region_idx]["coord"];
|
|
if (value_node_imgs_region_coord.isArray())
|
|
{
|
|
for (int idx = 0; idx < value_node_imgs_region_coord.size(); idx++)
|
|
{
|
|
cv::Point p;
|
|
p.x = value_node_imgs_region_coord[idx][0].asInt();
|
|
p.y = value_node_imgs_region_coord[idx][1].asInt();
|
|
if (p.x < 0)
|
|
{
|
|
p.x = 0;
|
|
}
|
|
if (p.x > tem_node.nodebasicConfog.img_width)
|
|
{
|
|
p.x = tem_node.nodebasicConfog.img_width;
|
|
}
|
|
if (p.y < 0)
|
|
{
|
|
p.y = 0;
|
|
}
|
|
if (p.y > tem_node.nodebasicConfog.img_height)
|
|
{
|
|
p.y = tem_node.nodebasicConfog.img_height;
|
|
}
|
|
temRegion.basicInfo.pointArry.emplace_back(p);
|
|
}
|
|
}
|
|
}
|
|
// 3、读取检测参数 和存图参数
|
|
for (int ParamType_idx = 0; ParamType_idx < ANALYSIS_TYPE_COUNT; ParamType_idx++)
|
|
{
|
|
if (temRegion.basicInfo.type == 1)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
// int param_type = ParamType_idx;
|
|
|
|
auto value_node_imgs_region_Check_Param = value_node_imgs_region[region_idx][ANALYSIS_TYPE_Names[ParamType_idx]];
|
|
|
|
if (value_node_imgs_region_Check_Param.isObject())
|
|
{
|
|
|
|
for (Json::ValueIterator iter = value_node_imgs_region_Check_Param.begin(); iter != value_node_imgs_region_Check_Param.end(); iter++)
|
|
{
|
|
CheckConfig_Regions_Param tem_paramValue;
|
|
|
|
// const char *name = iter.memberName();
|
|
std::string name = iter.name(); // 新方法,推荐使用
|
|
tem_paramValue.param_name = name;
|
|
auto value_node_imgs_region_Check_Param_value = value_node_imgs_region_Check_Param[name];
|
|
|
|
if (value_node_imgs_region_Check_Param_value.isArray())
|
|
{
|
|
|
|
for (int idx = 0; idx < value_node_imgs_region_Check_Param_value.size(); idx++)
|
|
{
|
|
|
|
AandEParam temparam;
|
|
temparam.bEnable = value_node_imgs_region_Check_Param_value[idx]["state"].asBool();
|
|
temparam.bOk = value_node_imgs_region_Check_Param_value[idx]["bOK"].asBool();
|
|
if (value_node_imgs_region_Check_Param_value[idx]["area"])
|
|
{
|
|
temparam.area = value_node_imgs_region_Check_Param_value[idx]["area"].asFloat();
|
|
}
|
|
if (value_node_imgs_region_Check_Param_value[idx]["area_max"])
|
|
{
|
|
temparam.area_max = value_node_imgs_region_Check_Param_value[idx]["area_max"].asFloat();
|
|
}
|
|
if (value_node_imgs_region_Check_Param_value[idx]["energy"])
|
|
{
|
|
temparam.energy = value_node_imgs_region_Check_Param_value[idx]["energy"].asFloat();
|
|
}
|
|
|
|
if (value_node_imgs_region_Check_Param_value[idx]["hj"])
|
|
{
|
|
temparam.hj = value_node_imgs_region_Check_Param_value[idx]["hj"].asFloat();
|
|
}
|
|
|
|
if (value_node_imgs_region_Check_Param_value[idx]["length"])
|
|
{
|
|
temparam.length = value_node_imgs_region_Check_Param_value[idx]["length"].asFloat();
|
|
}
|
|
|
|
if (value_node_imgs_region_Check_Param_value[idx]["num"])
|
|
{
|
|
temparam.num = value_node_imgs_region_Check_Param_value[idx]["num"].asInt();
|
|
}
|
|
|
|
if (value_node_imgs_region_Check_Param_value[idx]["dis"])
|
|
{
|
|
temparam.dis = value_node_imgs_region_Check_Param_value[idx]["dis"].asFloat();
|
|
}
|
|
if (value_node_imgs_region_Check_Param_value[idx]["density"])
|
|
{
|
|
temparam.density = value_node_imgs_region_Check_Param_value[idx]["density"].asFloat();
|
|
}
|
|
std::string str = ANALYSIS_TYPE_Names[ParamType_idx] + " " + name + " " + std::to_string(idx);
|
|
// temparam.print(str);
|
|
tem_paramValue.addParam(temparam);
|
|
}
|
|
}
|
|
temRegion.checkConfig_Regions_type[ParamType_idx].checkConfig_Regions_Param.push_back(tem_paramValue);
|
|
}
|
|
}
|
|
}
|
|
|
|
tem_node.regionConfigArr.push_back(temRegion);
|
|
}
|
|
}
|
|
}
|
|
|
|
_config.nodeConfigArr.push_back(tem_node);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
printf("--- ******error json*** \n");
|
|
}
|
|
}
|
|
int CommonParamToCheckConfigJson::GetConfig(CommonCheckConfigST &config)
|
|
{
|
|
config.copy(_config);
|
|
return 0;
|
|
}
|
|
|
|
Json::Value CheckConfigJson::toJsonValue()
|
|
{
|
|
return Json::Value();
|
|
}
|
|
|
|
void CheckConfigJson::toObjectFromValue(Json::Value root)
|
|
{
|
|
{
|
|
auto value = root["AI_Model_Path"];
|
|
if (value.isObject())
|
|
{
|
|
|
|
_config.modelConfig.defect_model_path = value["defect"].asString();
|
|
_config.modelConfig.YX_1_model_path = value["yx_1"].asString();
|
|
_config.modelConfig.YX_2_model_path = value["yx_2"].asString();
|
|
_config.modelConfig.class_model_path = value["class"].asString();
|
|
_config.modelConfig.defect_wtb_model_path = value["defect_wtb"].asString();
|
|
_config.modelConfig.zf_model_path = value["defect_zf"].asString();
|
|
_config.modelConfig.UP_model_path = value["defect_UP"].asString();
|
|
_config.modelConfig.class_L0_model_path = value["class_L0"].asString();
|
|
_config.modelConfig.class_L255_model_path = value["class_L255"].asString();
|
|
if (value["defect_chess"])
|
|
{
|
|
_config.modelConfig.defect_chess_model_path = value["defect_chess"].asString();
|
|
}
|
|
|
|
// 1024dyy
|
|
std::cout << "_config.modelConfig.defect_model_path=" << _config.modelConfig.defect_model_path << std::endl; // 1126dyy-add
|
|
std::cout << "_config.modelConfig.YX_1_model_path=" << _config.modelConfig.YX_1_model_path << std::endl; // 1126dyy
|
|
std::cout << "_config.modelConfig.YX_2_model_path=" << _config.modelConfig.YX_2_model_path << std::endl; // 1126dyy
|
|
std::cout << "_config.modelConfig.class_model_path=" << _config.modelConfig.class_model_path << std::endl; // 1126dyy-add
|
|
std::cout << "_config.modelConfig.defect_wtb_model_path=" << _config.modelConfig.defect_wtb_model_path << std::endl; // 1126dyy-add
|
|
std::cout << "_config.modelConfig.defect_chess_model_path=" << _config.modelConfig.defect_chess_model_path << std::endl; // 1126dyy-add
|
|
std::cout << "_config.modelConfig.zf_model_path=" << _config.modelConfig.zf_model_path << std::endl; // 1126dyy-add
|
|
std::cout << "_config.modelConfig.UP_model_path=" << _config.modelConfig.UP_model_path << std::endl; // 1126dyy-add
|
|
std::cout << "_config.modelConfig.class_L0_model_path=" << _config.modelConfig.class_L0_model_path << std::endl; // 1126dyy-add
|
|
std::cout << "_config.modelConfig.class_L255_model_path=" << _config.modelConfig.class_L255_model_path << std::endl; // 1126dyy-add
|
|
}
|
|
}
|
|
|
|
{
|
|
auto value = root["image_preprocess_param"];
|
|
if (value.isObject())
|
|
{
|
|
auto arr = value["crop_roi"];
|
|
if (arr.isArray())
|
|
{
|
|
_config.preDealImgConfig.cutRoi.x = arr[0].asInt();
|
|
_config.preDealImgConfig.cutRoi.y = arr[1].asInt();
|
|
_config.preDealImgConfig.cutRoi.width = arr[2].asInt();
|
|
_config.preDealImgConfig.cutRoi.height = arr[3].asInt();
|
|
}
|
|
_config.preDealImgConfig.bresize = value["resize"].asBool();
|
|
_config.preDealImgConfig.bInAI_ImgFflip = value["ai_input_image_flip"].asBool();
|
|
_config.preDealImgConfig.bOutAI_ImgFflip = value["ai_output_image_flip"].asBool();
|
|
}
|
|
}
|
|
{
|
|
auto value = root["Camer_param"];
|
|
if (value.isObject())
|
|
{
|
|
|
|
_config.camConfig.fscale_x = value["scale_x"].asFloat();
|
|
_config.camConfig.fscale_y = value["scale_y"].asFloat();
|
|
|
|
std::cout << "_config.camConfig.fscale_x=" << _config.camConfig.fscale_x << std::endl;
|
|
std::cout << "_config.camConfig.fscale_y=" << _config.camConfig.fscale_y << std::endl;
|
|
}
|
|
}
|
|
{
|
|
auto value = root["image_Info"];
|
|
if (value.isObject())
|
|
{
|
|
|
|
_config.resultimg_out.width = value["result_image_width"].asInt();
|
|
_config.resultimg_out.height = value["result_image_height"].asInt();
|
|
_config.resultimg_out.channels = value["result_image_channels"].asInt();
|
|
|
|
_config.resultimg_out.print("resultimg_out");
|
|
|
|
_config.Srcimg_in.width = value["src_image_width"].asInt();
|
|
_config.Srcimg_in.height = value["src_image_height"].asInt();
|
|
_config.Srcimg_in.channels = value["src_image_channels"].asInt();
|
|
|
|
_config.Srcimg_in.print("Srcimg_in");
|
|
}
|
|
}
|
|
}
|
|
int CheckConfigJson::GetConfig(CheckConfigST &config)
|
|
{
|
|
config.copy(_config);
|
|
return 0;
|
|
}
|
|
|
|
Json::Value ChannelFuntonConfigJson::toJsonValue()
|
|
{
|
|
return Json::Value();
|
|
}
|
|
|
|
void ChannelFuntonConfigJson::toObjectFromValue(Json::Value root)
|
|
{
|
|
auto strJson = root.asString();
|
|
Json::CharReaderBuilder builder;
|
|
std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
|
|
Json::Value rootvalue;
|
|
std::string err;
|
|
std::cout << "ChannelFuntonConfigJson" << std::endl
|
|
<< std::endl
|
|
<< std::endl;
|
|
// std::cout << strJson << std::endl;
|
|
auto nSize = strJson.size();
|
|
|
|
if (reader->parse(strJson.c_str(), strJson.c_str() + nSize, &rootvalue, &err))
|
|
{
|
|
// 和节点无关参数提取
|
|
|
|
auto value = rootvalue["checkData"];
|
|
if (value.isArray())
|
|
{
|
|
for (int idx = 0; idx < value.size(); idx++)
|
|
{
|
|
ChannelCheckFunction channel;
|
|
if (value[idx]["panelCode"])
|
|
{
|
|
channel.strChannelName = value[idx]["panelCode"].asString();
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
GetFunction(value[idx]["checkItem"], channel.function);
|
|
|
|
// up 特殊处理
|
|
if (channel.strChannelName == "Up-Particle" && channel.function.f_BaseDet.bOpen)
|
|
{
|
|
channel.function.f_OnlyBLob.bOpen = true;
|
|
}
|
|
|
|
// channel.print("channel");
|
|
// getchar();
|
|
_config.channelFunctionArr.push_back(channel);
|
|
}
|
|
// _config.print("channelFunction");
|
|
}
|
|
}
|
|
}
|
|
|
|
int ChannelFuntonConfigJson::GetConfig(ALLChannelCheckFunction &config)
|
|
{
|
|
config.copy(_config);
|
|
return 0;
|
|
}
|
|
|
|
int ChannelFuntonConfigJson::GetFunction(Json::Value value, CheckFunction &function)
|
|
{
|
|
// std::cout << value << std::endl;
|
|
|
|
if (value.isArray())
|
|
{
|
|
for (int i = 0; i < value.size(); i++)
|
|
{
|
|
|
|
std::string strCode = value[i]["itemCode"].asString();
|
|
// std::cout << strCode << std::endl;
|
|
// 读取UP 过滤功能
|
|
if ("QX_Detect" == strCode)
|
|
{
|
|
auto value_f = value[i];
|
|
// std::cout << value_f << std::endl;
|
|
function.f_BaseDet.bOpen = value_f["isOpen"].asBool();
|
|
if (function.f_BaseDet.bOpen)
|
|
{
|
|
/* code */
|
|
|
|
if (value_f["form"]["Base_Det"]["AI_Model"])
|
|
{
|
|
function.f_BaseDet.strAIMode = value_f["form"]["Base_Det"]["AI_Model"].asString();
|
|
}
|
|
|
|
auto value_qx = value_f["form"]["Base_Det"]["Det_QX"];
|
|
if (value_qx.isArray())
|
|
{
|
|
for (int idx = 0; idx < value_qx.size(); idx++)
|
|
{
|
|
std::string qx = value_qx[idx].asString();
|
|
function.f_BaseDet.DetQXList.push_back(qx);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
function.f_BaseDet.Init();
|
|
}
|
|
}
|
|
// 读取UP 过滤功能
|
|
if ("UP_Use" == strCode)
|
|
{
|
|
auto value_f = value[i];
|
|
// std::cout << value_f << std::endl;
|
|
function.f_UseUpQX.bOpen = value_f["isOpen"].asBool();
|
|
if (function.f_UseUpQX.bOpen)
|
|
{
|
|
/* code */
|
|
|
|
if (value_f["form"]["UP_QX_Filter"]["IOU"])
|
|
{
|
|
function.f_UseUpQX.fIOU = value_f["form"]["UP_QX_Filter"]["IOU"].asFloat();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
function.f_UseUpQX.Init();
|
|
}
|
|
// function.f_UseUpQX.print("UpQX");
|
|
}
|
|
if ("AI_Class" == strCode)
|
|
{
|
|
auto value_f = value[i];
|
|
// std::cout << value_f << std::endl;
|
|
function.f_AIQX.bOpen = value_f["isOpen"].asBool();
|
|
if (function.f_AIQX.bOpen)
|
|
{
|
|
/* code */
|
|
|
|
if (value_f["form"]["AI_QX"]["POLToWhitePOL"])
|
|
{
|
|
function.f_AIQX.bPOLToWhitePOL = value_f["form"]["AI_QX"]["POLToWhitePOL"].asBool();
|
|
}
|
|
if (value_f["form"]["AI_QX"]["ALLToChess"])
|
|
{
|
|
function.f_AIQX.bAllToChess = value_f["form"]["AI_QX"]["ALLToChess"].asBool();
|
|
}
|
|
if (value_f["form"]["AI_QX"]["UseDP"])
|
|
{
|
|
function.f_AIQX.b127WhitePOl_UseDP = value_f["form"]["AI_QX"]["UseDP"].asBool();
|
|
}
|
|
if (value_f["form"]["AI_QX"]["DP_IOU"])
|
|
{
|
|
function.f_AIQX.f127WhitePOl_DP_IOU = value_f["form"]["AI_QX"]["DP_IOU"].asFloat();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
function.f_AIQX.Init();
|
|
}
|
|
|
|
// function.f_UseUpQX.print("UpQX");
|
|
}
|
|
if ("YX_Detect" == strCode)
|
|
{
|
|
auto value_f = value[i];
|
|
// std::cout << value_f << std::endl;
|
|
function.f_YXDet.bOpen = value_f["isOpen"].asBool();
|
|
if (value_f["form"]["YX_Det"]["AI_Model"])
|
|
{
|
|
function.f_YXDet.strModle = value_f["form"]["YX_Det"]["AI_Model"].asString();
|
|
}
|
|
|
|
// function.f_UseUpQX.print("UpQX");
|
|
}
|
|
if ("LD_Detect" == strCode)
|
|
{
|
|
auto value_f = value[i];
|
|
// std::cout << value_f << std::endl;
|
|
function.f_LDConfig.bOpen = value_f["isOpen"].asBool();
|
|
if (function.f_LDConfig.bOpen)
|
|
{
|
|
/* code */
|
|
|
|
if (value_f["form"]["LD_Det"]["bUseDP"])
|
|
{
|
|
function.f_LDConfig.bUseDP = value_f["form"]["LD_Det"]["bUseDP"].asBool();
|
|
}
|
|
if (value_f["form"]["LD_Det"]["WTB_LD"])
|
|
{
|
|
function.f_LDConfig.bWTBLD = value_f["form"]["LD_Det"]["WTB_LD"].asBool();
|
|
}
|
|
if (value_f["form"]["LD_Det"]["HS_LD"])
|
|
{
|
|
function.f_LDConfig.bHSLD = value_f["form"]["LD_Det"]["HS_LD"].asBool();
|
|
}
|
|
|
|
if (value_f["form"]["LD_Det"]["DP_IOU"])
|
|
{
|
|
function.f_LDConfig.fDP_IOU = value_f["form"]["LD_Det"]["DP_IOU"].asFloat();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
function.f_LDConfig.Init();
|
|
}
|
|
|
|
// function.f_UseUpQX.print("UpQX");
|
|
}
|
|
if ("Det_Cell" == strCode)
|
|
{
|
|
auto value_f = value[i];
|
|
// std::cout << value_f << std::endl;
|
|
function.f_Det127Cell.bOpen = value_f["isOpen"].asBool();
|
|
}
|
|
// 大缺陷检测
|
|
if ("BigQX_Detect" == strCode)
|
|
{
|
|
auto value_f = value[i];
|
|
// std::cout << value_f << std::endl;
|
|
function.f_Big_QX.bOpen = value_f["isOpen"].asBool();
|
|
if (value_f["form"]["SingleConfig"]["Area"])
|
|
{
|
|
function.f_Big_QX.Single_Area = value_f["form"]["SingleConfig"]["Area"].asFloat();
|
|
}
|
|
if (value_f["form"]["SingleConfig"]["HJ"])
|
|
{
|
|
function.f_Big_QX.Single_HJ = value_f["form"]["SingleConfig"]["HJ"].asInt();
|
|
}
|
|
if (value_f["form"]["SingleConfig"]["Length"])
|
|
{
|
|
function.f_Big_QX.Single_Len = value_f["form"]["SingleConfig"]["Length"].asFloat();
|
|
}
|
|
if (value_f["form"]["Sum_Area"]["Blob_Num"])
|
|
{
|
|
function.f_Big_QX.Sum_blob_Num = value_f["form"]["Sum_Area"]["Blob_Num"].asInt();
|
|
}
|
|
if (value_f["form"]["Sum_Area"]["Area_Sum"])
|
|
{
|
|
function.f_Big_QX.Sum_Area = value_f["form"]["Sum_Area"]["Area_Sum"].asFloat();
|
|
}
|
|
}
|
|
// 屏蔽区域
|
|
if ("ShieldRegion" == strCode)
|
|
{
|
|
auto value_f = value[i];
|
|
// std::cout << value_f << std::endl;
|
|
function.f_ShieldRegion.bOpen = value_f["isOpen"].asBool();
|
|
if (function.f_ShieldRegion.bOpen)
|
|
{
|
|
/* code */
|
|
|
|
if (value_f["form"]["ShieldRegionConfig"]["bDraw"])
|
|
{
|
|
function.f_ShieldRegion.bDraw = value_f["form"]["ShieldRegionConfig"]["bDraw"].asBool();
|
|
}
|
|
{
|
|
auto region_coord = value_f["form"]["ShieldRegionConfig"]["region_1"];
|
|
if (region_coord.isArray())
|
|
{
|
|
for (int idx = 0; idx < region_coord.size(); idx++)
|
|
{
|
|
cv::Point p;
|
|
p.x = region_coord[idx][0].asInt();
|
|
p.y = region_coord[idx][1].asInt();
|
|
function.f_ShieldRegion.pointArry1.emplace_back(p);
|
|
function.f_ShieldRegion.bHave = true;
|
|
}
|
|
}
|
|
// printf(" pointArry1 size %d \n", function.f_ShieldRegion.pointArry1.size());
|
|
}
|
|
|
|
{
|
|
auto region_coord = value_f["form"]["ShieldRegionConfig"]["region_2"];
|
|
if (region_coord.isArray())
|
|
{
|
|
for (int idx = 0; idx < region_coord.size(); idx++)
|
|
{
|
|
cv::Point p;
|
|
p.x = region_coord[idx][0].asInt();
|
|
p.y = region_coord[idx][1].asInt();
|
|
function.f_ShieldRegion.pointArry2.emplace_back(p);
|
|
function.f_ShieldRegion.bHave = true;
|
|
}
|
|
}
|
|
// printf(" pointArry2 size %d \n", function.f_ShieldRegion.pointArry2.size());
|
|
}
|
|
{
|
|
auto region_coord = value_f["form"]["ShieldRegionConfig"]["region_3"];
|
|
if (region_coord.isArray())
|
|
{
|
|
for (int idx = 0; idx < region_coord.size(); idx++)
|
|
{
|
|
cv::Point p;
|
|
p.x = region_coord[idx][0].asInt();
|
|
p.y = region_coord[idx][1].asInt();
|
|
function.f_ShieldRegion.pointArry3.emplace_back(p);
|
|
function.f_ShieldRegion.bHave = true;
|
|
}
|
|
}
|
|
// printf(" pointArry3 size %d \n", function.f_ShieldRegion.pointArry3.size());
|
|
}
|
|
{
|
|
auto region_coord = value_f["form"]["ShieldRegionConfig"]["region_4"];
|
|
if (region_coord.isArray())
|
|
{
|
|
for (int idx = 0; idx < region_coord.size(); idx++)
|
|
{
|
|
cv::Point p;
|
|
p.x = region_coord[idx][0].asInt();
|
|
p.y = region_coord[idx][1].asInt();
|
|
function.f_ShieldRegion.pointArry4.emplace_back(p);
|
|
function.f_ShieldRegion.bHave = true;
|
|
}
|
|
}
|
|
// printf(" pointArry4 size %d \n", function.f_ShieldRegion.pointArry4.size());
|
|
}
|
|
{
|
|
auto region_coord = value_f["form"]["ShieldRegionConfig"]["region_5"];
|
|
if (region_coord.isArray())
|
|
{
|
|
for (int idx = 0; idx < region_coord.size(); idx++)
|
|
{
|
|
cv::Point p;
|
|
p.x = region_coord[idx][0].asInt();
|
|
p.y = region_coord[idx][1].asInt();
|
|
function.f_ShieldRegion.pointArry5.emplace_back(p);
|
|
function.f_ShieldRegion.bHave = true;
|
|
}
|
|
}
|
|
// printf(" pointArry5 size %d \n", function.f_ShieldRegion.pointArry5.size());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
function.f_ShieldRegion.Init();
|
|
}
|
|
}
|
|
// 边缘roi
|
|
if ("Crop_ROI" == strCode)
|
|
{
|
|
auto value_f = value[i];
|
|
// std::cout << value_f << std::endl;
|
|
function.f_EdgeROI.bOpen = value_f["isOpen"].asBool();
|
|
if (function.f_EdgeROI.bOpen)
|
|
{
|
|
/* code */
|
|
|
|
if (value_f["form"]["ROI_Config"]["Use_DrawROI"])
|
|
{
|
|
function.f_EdgeROI.Use_DrawROI = value_f["form"]["ROI_Config"]["Use_DrawROI"].asBool();
|
|
}
|
|
if (value_f["form"]["ROI_Config"]["Use_DetEdge"])
|
|
{
|
|
function.f_EdgeROI.Use_DetEdge = value_f["form"]["ROI_Config"]["Use_DetEdge"].asBool();
|
|
}
|
|
if (value_f["form"]["ROI_Config"]["Use_AIEdge"])
|
|
{
|
|
function.f_EdgeROI.Use_AIEdge = value_f["form"]["ROI_Config"]["Use_AIEdge"].asBool();
|
|
}
|
|
if (value_f["form"]["ROI_Config"]["AI_Fail_UseDraw"])
|
|
{
|
|
function.f_EdgeROI.AI_Fail_UseDraw = value_f["form"]["ROI_Config"]["AI_Fail_UseDraw"].asBool();
|
|
}
|
|
if (value_f["form"]["ROI_Config"]["threshold_value"])
|
|
{
|
|
function.f_EdgeROI.threshold_value = value_f["form"]["ROI_Config"]["threshold_value"].asInt();
|
|
}
|
|
if (value_f["form"]["ROI_Config"]["threshold_value"])
|
|
{
|
|
function.f_EdgeROI.AI_Erode_Size = value_f["form"]["ROI_Config"]["AI_Erode_Size"].asInt();
|
|
}
|
|
{
|
|
auto region_coord = value_f["form"]["ROI_Config"]["ROI"];
|
|
if (region_coord.isArray())
|
|
{
|
|
for (int idx = 0; idx < region_coord.size(); idx++)
|
|
{
|
|
cv::Point p;
|
|
p.x = region_coord[idx][0].asInt();
|
|
p.y = region_coord[idx][1].asInt();
|
|
function.f_EdgeROI.pointArry1.emplace_back(p);
|
|
}
|
|
}
|
|
// printf(" pointArry1 size %d \n", function.f_ShieldRegion.pointArry1.size());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
function.f_EdgeROI.Init();
|
|
}
|
|
}
|
|
// 边缘roi
|
|
if ("Image_Align_T" == strCode)
|
|
{
|
|
auto value_f = value[i];
|
|
// std::cout << value_f << std::endl;
|
|
function.f_Image_Align.bOpen = value_f["isOpen"].asBool();
|
|
if (function.f_Image_Align.bOpen)
|
|
{
|
|
/* code */
|
|
|
|
{
|
|
auto region_coord = value_f["form"]["Align_Config"]["Edge_TZ"];
|
|
if (region_coord.isArray())
|
|
{
|
|
for (int idx = 0; idx < region_coord.size(); idx++)
|
|
{
|
|
cv::Point p;
|
|
p.x = region_coord[idx][0].asInt();
|
|
p.y = region_coord[idx][1].asInt();
|
|
function.f_Image_Align.pointArry1.emplace_back(p);
|
|
}
|
|
}
|
|
// printf(" pointArry1 size %d \n", function.f_ShieldRegion.pointArry1.size());
|
|
}
|
|
{
|
|
auto region_roi = value_f["form"]["Align_Config"]["Search_ROI"];
|
|
|
|
{
|
|
if (region_roi["x"])
|
|
{
|
|
function.f_Image_Align.search_Roi.x = region_roi["x"].asInt();
|
|
}
|
|
if (region_roi["y"])
|
|
{
|
|
function.f_Image_Align.search_Roi.y = region_roi["y"].asInt();
|
|
}
|
|
if (region_roi["width"])
|
|
{
|
|
function.f_Image_Align.search_Roi.width = region_roi["width"].asInt();
|
|
}
|
|
if (region_roi["height"])
|
|
{
|
|
function.f_Image_Align.search_Roi.height = region_roi["height"].asInt();
|
|
}
|
|
}
|
|
// printf(" pointArry1 size %d \n", function.f_ShieldRegion.pointArry1.size());
|
|
}
|
|
{
|
|
auto Kernel_roi = value_f["form"]["Align_Config"]["Kernel_ROI"];
|
|
|
|
{
|
|
if (Kernel_roi["x"])
|
|
{
|
|
function.f_Image_Align.feature_Roi.x = Kernel_roi["x"].asInt();
|
|
}
|
|
if (Kernel_roi["y"])
|
|
{
|
|
function.f_Image_Align.feature_Roi.y = Kernel_roi["y"].asInt();
|
|
}
|
|
if (Kernel_roi["width"])
|
|
{
|
|
function.f_Image_Align.feature_Roi.width = Kernel_roi["width"].asInt();
|
|
}
|
|
if (Kernel_roi["height"])
|
|
{
|
|
function.f_Image_Align.feature_Roi.height = Kernel_roi["height"].asInt();
|
|
}
|
|
}
|
|
// printf(" pointArry1 size %d \n", function.f_ShieldRegion.pointArry1.size());
|
|
}
|
|
{
|
|
auto crop_roi = value_f["form"]["Align_Config"]["Crop_ROI"];
|
|
|
|
{
|
|
if (crop_roi["x"])
|
|
{
|
|
function.f_Image_Align.Crop_Roi.x = crop_roi["x"].asInt();
|
|
}
|
|
if (crop_roi["y"])
|
|
{
|
|
function.f_Image_Align.Crop_Roi.y = crop_roi["y"].asInt();
|
|
}
|
|
if (crop_roi["width"])
|
|
{
|
|
function.f_Image_Align.Crop_Roi.width = crop_roi["width"].asInt();
|
|
}
|
|
if (crop_roi["height"])
|
|
{
|
|
function.f_Image_Align.Crop_Roi.height = crop_roi["height"].asInt();
|
|
}
|
|
}
|
|
// printf(" pointArry1 size %d \n", function.f_ShieldRegion.pointArry1.size());
|
|
}
|
|
{
|
|
if (value_f["form"]["Align_Config"]["bDraw"])
|
|
{
|
|
function.f_Image_Align.bDraw = value_f["form"]["Align_Config"]["bDraw"].asBool();
|
|
}
|
|
}
|
|
{
|
|
if (value_f["form"]["Align_Config"]["Score"])
|
|
{
|
|
float fs = value_f["form"]["Align_Config"]["Score"].asFloat();
|
|
if (fs > 0.01 && fs <= 1)
|
|
{
|
|
function.f_Image_Align.fscore = fs;
|
|
}
|
|
}
|
|
}
|
|
if (value_f["form"]["Align_Config"]["UseType"])
|
|
{
|
|
std::string str = value_f["form"]["Align_Config"]["UseType"].asString();
|
|
if (str == "Use")
|
|
{
|
|
function.f_Image_Align.runType = Function_Image_Align::type_Use;
|
|
}
|
|
else if (str == "Test")
|
|
{
|
|
function.f_Image_Align.runType = Function_Image_Align::type_Test;
|
|
}
|
|
else
|
|
{
|
|
function.f_Image_Align.runType = Function_Image_Align::type_Use;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
function.f_Image_Align.Init();
|
|
}
|
|
}
|
|
// 缺pol 检测
|
|
if ("LackPOL_Det" == strCode)
|
|
{
|
|
auto value_f = value[i];
|
|
// std::cout << value_f << std::endl;
|
|
function.f_Dectect_LackPol.bOpen = value_f["isOpen"].asBool();
|
|
}
|
|
|
|
// 二次分类检测
|
|
if ("Second_Det" == strCode)
|
|
{
|
|
auto value_f = value[i];
|
|
// std::cout << value_f << std::endl;
|
|
function.f_SecondDetect.bOpen = value_f["isOpen"].asBool();
|
|
if (function.f_SecondDetect.bOpen)
|
|
{
|
|
if (value_f["form"]["Andain_Config"]["Open_Area"])
|
|
{
|
|
function.f_SecondDetect.andian_Open_area = value_f["form"]["Andain_Config"]["Open_Area"].asBool();
|
|
}
|
|
if (value_f["form"]["Andain_Config"]["Open_Len"])
|
|
{
|
|
function.f_SecondDetect.andian_Open_len = value_f["form"]["Andain_Config"]["Open_Len"].asBool();
|
|
}
|
|
if (value_f["form"]["Andain_Config"]["Area_min"])
|
|
{
|
|
function.f_SecondDetect.andian_area_min = value_f["form"]["Andain_Config"]["Area_min"].asFloat();
|
|
}
|
|
if (value_f["form"]["Andain_Config"]["Area_max"])
|
|
{
|
|
function.f_SecondDetect.andian_area_max = value_f["form"]["Andain_Config"]["Area_max"].asFloat();
|
|
}
|
|
if (value_f["form"]["Andain_Config"]["SaveProcessImg"])
|
|
{
|
|
function.f_SecondDetect.andian_saveProcessImg = value_f["form"]["Andain_Config"]["SaveProcessImg"].asBool();
|
|
}
|
|
|
|
if (value_f["form"]["POL_Config"]["Open_Area"])
|
|
{
|
|
function.f_SecondDetect.pol_Open_area = value_f["form"]["POL_Config"]["Open_Area"].asBool();
|
|
}
|
|
if (value_f["form"]["POL_Config"]["Open_Len"])
|
|
{
|
|
function.f_SecondDetect.pol_Open_len = value_f["form"]["POL_Config"]["Open_Len"].asBool();
|
|
}
|
|
if (value_f["form"]["POL_Config"]["Area_min"])
|
|
{
|
|
function.f_SecondDetect.pol_area_min = value_f["form"]["POL_Config"]["Area_min"].asFloat();
|
|
}
|
|
if (value_f["form"]["POL_Config"]["Area_max"])
|
|
{
|
|
function.f_SecondDetect.pol_area_max = value_f["form"]["POL_Config"]["Area_max"].asFloat();
|
|
}
|
|
if (value_f["form"]["POL_Config"]["Open_Single_Check"])
|
|
{
|
|
function.f_SecondDetect.pol_open_SingleCheck = value_f["form"]["POL_Config"]["Open_Single_Check"].asBool();
|
|
}
|
|
if (value_f["form"]["POL_Config"]["Open_Create_Pol"])
|
|
{
|
|
function.f_SecondDetect.pol_open_Create = value_f["form"]["POL_Config"]["Open_Create_Pol"].asBool();
|
|
}
|
|
if (value_f["form"]["POL_Config"]["SaveProcessImg"])
|
|
{
|
|
function.f_SecondDetect.pol_saveProcessImg = value_f["form"]["POL_Config"]["SaveProcessImg"].asBool();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
function.f_SecondDetect.Init();
|
|
}
|
|
// getchar();
|
|
}
|
|
// 暗点检测
|
|
if ("AD_Check" == strCode)
|
|
{
|
|
auto value_f = value[i];
|
|
// std::cout << value_f << std::endl;
|
|
function.f_AD_Check.bOpen = value_f["isOpen"].asBool();
|
|
if (function.f_AD_Check.bOpen)
|
|
{
|
|
if (value_f["form"]["AD_S_Standard"]["AD_3S_Area"])
|
|
{
|
|
function.f_AD_Check.S_standard_3s.area = value_f["form"]["AD_S_Standard"]["AD_3S_Area"].asFloat();
|
|
}
|
|
if (value_f["form"]["AD_S_Standard"]["AD_3S_Len"])
|
|
{
|
|
function.f_AD_Check.S_standard_3s.len = value_f["form"]["AD_S_Standard"]["AD_3S_Len"].asFloat();
|
|
}
|
|
|
|
if (value_f["form"]["AD_S_Standard"]["AD_2S_Area"])
|
|
{
|
|
function.f_AD_Check.S_standard_2s.area = value_f["form"]["AD_S_Standard"]["AD_2S_Area"].asFloat();
|
|
}
|
|
if (value_f["form"]["AD_S_Standard"]["AD_2S_Len"])
|
|
{
|
|
function.f_AD_Check.S_standard_2s.len = value_f["form"]["AD_S_Standard"]["AD_2S_Len"].asFloat();
|
|
}
|
|
|
|
if (value_f["form"]["AD_S_Standard"]["AD_1S_Area"])
|
|
{
|
|
function.f_AD_Check.S_standard_1s.area = value_f["form"]["AD_S_Standard"]["AD_1S_Area"].asFloat();
|
|
}
|
|
if (value_f["form"]["AD_S_Standard"]["AD_1S_Len"])
|
|
{
|
|
function.f_AD_Check.S_standard_1s.len = value_f["form"]["AD_S_Standard"]["AD_1S_Len"].asFloat();
|
|
}
|
|
|
|
if (value_f["form"]["AD_Check_Num"]["Open"])
|
|
{
|
|
function.f_AD_Check.analysis_num.bOpen = value_f["form"]["AD_Check_Num"]["Open"].asBool();
|
|
}
|
|
if (value_f["form"]["AD_Check_Num"]["Num"])
|
|
{
|
|
function.f_AD_Check.analysis_num.numT = value_f["form"]["AD_Check_Num"]["Num"].asInt();
|
|
}
|
|
|
|
if (value_f["form"]["AD_Check_Dis"]["Open"])
|
|
{
|
|
function.f_AD_Check.analysis_dis.bOpen = value_f["form"]["AD_Check_Dis"]["Open"].asBool();
|
|
}
|
|
if (value_f["form"]["AD_Check_Dis"]["Dis"])
|
|
{
|
|
function.f_AD_Check.analysis_dis.disT = value_f["form"]["AD_Check_Dis"]["Dis"].asFloat();
|
|
}
|
|
|
|
if (value_f["form"]["AD_Check_S"]["Open"])
|
|
{
|
|
function.f_AD_Check.analysis_s.bOpen = value_f["form"]["AD_Check_S"]["Open"].asBool();
|
|
}
|
|
|
|
if (value_f["form"]["AD_Check_S"]["S_value"])
|
|
{
|
|
function.f_AD_Check.analysis_s.Check_s_Value = value_f["form"]["AD_Check_S"]["S_value"].asInt();
|
|
}
|
|
if (value_f["form"]["AD_Check_S"]["NG_3s"])
|
|
{
|
|
function.f_AD_Check.analysis_s.NG_3s = value_f["form"]["AD_Check_S"]["NG_3s"].asBool();
|
|
}
|
|
if (value_f["form"]["AD_Check_S"]["Num"])
|
|
{
|
|
function.f_AD_Check.analysis_s.Check_s_Num = value_f["form"]["AD_Check_S"]["Num"].asInt();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
function.f_AD_Check.Init();
|
|
}
|
|
// getchar();
|
|
}
|
|
// 异物检测
|
|
if ("POL_Cam" == strCode)
|
|
{
|
|
auto value_f = value[i];
|
|
// std::cout << value_f << std::endl;
|
|
function.f_POL_Check.bOpen = value_f["isOpen"].asBool();
|
|
if (function.f_POL_Check.bOpen)
|
|
{
|
|
if (value_f["form"]["AnalysisConfig"]["Num"])
|
|
{
|
|
function.f_POL_Check.numT = value_f["form"]["AnalysisConfig"]["Num"].asInt();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
function.f_POL_Check.Init();
|
|
}
|
|
// getchar();
|
|
}
|
|
if ("Edge_QX_Detect" == strCode)
|
|
{
|
|
auto value_f = value[i];
|
|
// std::cout << value_f << std::endl;
|
|
// getchar();
|
|
function.f_dege_Det.bOpen = value_f["isOpen"].asBool();
|
|
if (function.f_dege_Det.bOpen)
|
|
{
|
|
function.f_dege_Det.bshowRoi = value_f["form"]["Det_Config"]["bShow"].asBool();
|
|
function.f_dege_Det.bsave_qx = value_f["form"]["Det_Config"]["Save_qx"].asBool();
|
|
function.f_dege_Det.bsave_all = value_f["form"]["Det_Config"]["Save_all"].asBool();
|
|
function.f_dege_Det.bdetUse = value_f["form"]["Det_Config"]["Det_Use"].asBool();
|
|
std::string strkey = value_f["form"]["Det_Config"]["UseType"].asString();
|
|
if (strkey == "type_add")
|
|
{
|
|
function.f_dege_Det.type = Function_Edge_Det::Edge_type_Add;
|
|
}
|
|
else if (strkey == "type_and")
|
|
{
|
|
function.f_dege_Det.type = Function_Edge_Det::Edge_type_And;
|
|
}
|
|
else
|
|
{
|
|
function.f_dege_Det.type = Function_Edge_Det::Edge_type_useEdge;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
function.f_dege_Det.Init();
|
|
}
|
|
|
|
// function.f_markDet.print("UpQX");
|
|
// getchar();
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
Json::Value BaseFuntonConfigJson::toJsonValue()
|
|
{
|
|
return Json::Value();
|
|
}
|
|
|
|
void BaseFuntonConfigJson::toObjectFromValue(Json::Value root)
|
|
{
|
|
auto strJson = root.asString();
|
|
Json::CharReaderBuilder builder;
|
|
std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
|
|
Json::Value rootvalue;
|
|
std::string err;
|
|
std::cout << "BaseFuntonConfigJson" << std::endl
|
|
<< std::endl
|
|
<< std::endl;
|
|
// std::cout << strJson << std::endl;
|
|
auto nSize = strJson.size();
|
|
|
|
if (reader->parse(strJson.c_str(), strJson.c_str() + nSize, &rootvalue, &err))
|
|
{
|
|
// 和节点无关参数提取
|
|
|
|
auto value = rootvalue["baseCheckData"];
|
|
// printf("\n\n\n");
|
|
// std::cout << value << std::endl;
|
|
// getchar();
|
|
if (value.isArray())
|
|
{
|
|
for (int idx = 0; idx < value.size(); idx++)
|
|
{
|
|
GetFunction(value[idx]);
|
|
}
|
|
// _config.print("channelFunction");
|
|
}
|
|
}
|
|
}
|
|
|
|
int BaseFuntonConfigJson::GetConfig(BaseCheckFunction &config)
|
|
{
|
|
config.copy(_config);
|
|
return 0;
|
|
}
|
|
|
|
int BaseFuntonConfigJson::GetFunction(Json::Value value)
|
|
{
|
|
|
|
// std::cout << value << std::endl;
|
|
|
|
std::string strCode = value["itemCode"].asString();
|
|
// std::cout << strCode << std::endl;
|
|
// 读取UP 过滤功能
|
|
if ("MarkLine" == strCode)
|
|
{
|
|
auto value_f = value;
|
|
// std::cout << value_f << std::endl;
|
|
// getchar();
|
|
_config.markLine.bOpen = value_f["isOpen"].asBool();
|
|
if (_config.markLine.bOpen)
|
|
{
|
|
|
|
{
|
|
auto crop_roi = value_f["form"]["DetConfig"]["SearchROI"];
|
|
|
|
{
|
|
if (crop_roi["x"])
|
|
{
|
|
_config.markLine.searchRoi.x = crop_roi["x"].asInt();
|
|
}
|
|
if (crop_roi["y"])
|
|
{
|
|
_config.markLine.searchRoi.y = crop_roi["y"].asInt();
|
|
}
|
|
if (crop_roi["width"])
|
|
{
|
|
_config.markLine.searchRoi.width = crop_roi["width"].asInt();
|
|
}
|
|
if (crop_roi["height"])
|
|
{
|
|
_config.markLine.searchRoi.height = crop_roi["height"].asInt();
|
|
}
|
|
}
|
|
// printf(" pointArry1 size %d \n", function.f_ShieldRegion.pointArry1.size());
|
|
}
|
|
if (value_f["form"]["DetConfig"]["x_sheild_width"])
|
|
{
|
|
_config.markLine.x_sheild_width = value_f["form"]["DetConfig"]["x_sheild_width"].asInt();
|
|
}
|
|
if (value_f["form"]["DetConfig"]["y_sheild_width"])
|
|
{
|
|
_config.markLine.y_sheild_width = value_f["form"]["DetConfig"]["y_sheild_width"].asInt();
|
|
}
|
|
if (value_f["form"]["DetConfig"]["Use_sheild"])
|
|
{
|
|
_config.markLine.bUse_Roi_Sheild = value_f["form"]["DetConfig"]["Use_sheild"].asBool();
|
|
}
|
|
if (value_f["form"]["DetConfig"]["Use_QX_sheild"])
|
|
{
|
|
_config.markLine.bUse_qx_Sheild = value_f["form"]["DetConfig"]["Use_QX_sheild"].asBool();
|
|
}
|
|
if (value_f["form"]["DetConfig"]["qx_sheild_IOU"])
|
|
{
|
|
_config.markLine.qx_sheild_iou = value_f["form"]["DetConfig"]["qx_sheild_IOU"].asFloat();
|
|
}
|
|
auto value_qx = value_f["form"]["DetConfig"]["qx_sheild"];
|
|
if (value_qx.isArray())
|
|
{
|
|
for (int idx = 0; idx < value_qx.size(); idx++)
|
|
{
|
|
std::string qx = value_qx[idx].asString();
|
|
_config.markLine.sheil_qx_List.push_back(qx);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_config.markLine.Init();
|
|
}
|
|
}
|
|
if ("Edge_QX_Detect" == strCode)
|
|
{
|
|
auto value_f = value;
|
|
// std::cout << value_f << std::endl;
|
|
// getchar();
|
|
_config.edgeDet.bOpen = value_f["isOpen"].asBool();
|
|
if (_config.edgeDet.bOpen)
|
|
{
|
|
|
|
if (value_f["form"]["Search_Config"]["Search_threshold"])
|
|
{
|
|
_config.edgeDet.Search_threshold = value_f["form"]["Search_Config"]["Search_threshold"].asInt();
|
|
}
|
|
if (value_f["form"]["Detect_Config"]["Det_threshold"])
|
|
{
|
|
_config.edgeDet.Det_threshold = value_f["form"]["Detect_Config"]["Det_threshold"].asInt();
|
|
}
|
|
if (value_f["form"]["Detect_Config"]["Det_Range"])
|
|
{
|
|
_config.edgeDet.Det_Range = value_f["form"]["Detect_Config"]["Det_Range"].asInt();
|
|
}
|
|
|
|
if (value_f["form"]["Detect_Config"]["QX_Widht_min"])
|
|
{
|
|
_config.edgeDet.QX_Widht_min = value_f["form"]["Detect_Config"]["QX_Widht_min"].asInt();
|
|
}
|
|
|
|
if (value_f["form"]["Detect_Config"]["QX_Widht_max"])
|
|
{
|
|
_config.edgeDet.QX_Widht_max = value_f["form"]["Detect_Config"]["QX_Widht_max"].asInt();
|
|
}
|
|
|
|
if (value_f["form"]["Detect_Config"]["QX_Height_min"])
|
|
{
|
|
_config.edgeDet.QX_Height_min = value_f["form"]["Detect_Config"]["QX_Height_min"].asInt();
|
|
}
|
|
|
|
if (value_f["form"]["Detect_Config"]["QX_Height_max"])
|
|
{
|
|
_config.edgeDet.QX_Height_max = value_f["form"]["Detect_Config"]["QX_Height_max"].asInt();
|
|
}
|
|
|
|
///============================================
|
|
|
|
if (value_f["form"]["Jiao_Config"]["LU_Jiao"])
|
|
{
|
|
_config.edgeDet.queJiao_LU_Open = value_f["form"]["Jiao_Config"]["LU_Jiao"].asBool();
|
|
}
|
|
if (value_f["form"]["Jiao_Config"]["RU_Jiao"])
|
|
{
|
|
_config.edgeDet.queJiao_RU_Open = value_f["form"]["Jiao_Config"]["RU_Jiao"].asBool();
|
|
}
|
|
|
|
if (value_f["form"]["Jiao_Config"]["LD_Jiao"])
|
|
{
|
|
_config.edgeDet.queJiao_LD_Open = value_f["form"]["Jiao_Config"]["LD_Jiao"].asBool();
|
|
}
|
|
|
|
if (value_f["form"]["Jiao_Config"]["RD_Jiao"])
|
|
{
|
|
_config.edgeDet.queJiao_RD_Open = value_f["form"]["Jiao_Config"]["RD_Jiao"].asBool();
|
|
}
|
|
|
|
if (value_f["form"]["Jiao_Config"]["Jiao_Width"])
|
|
{
|
|
_config.edgeDet.queJiao_width = value_f["form"]["Jiao_Config"]["Jiao_Width"].asInt();
|
|
}
|
|
|
|
if (value_f["form"]["Jiao_Config"]["Jiao_Height"])
|
|
{
|
|
_config.edgeDet.queJiao_height = value_f["form"]["Jiao_Config"]["Jiao_Height"].asInt();
|
|
}
|
|
|
|
if (value_f["form"]["Draw_Config"]["Open"])
|
|
{
|
|
_config.edgeDet.bDrawRoi = value_f["form"]["Draw_Config"]["Open"].asBool();
|
|
}
|
|
|
|
// 2、读取区域点
|
|
{
|
|
auto value_region = value_f["form"]["Draw_Config"]["Edge_ROI"];
|
|
if (value_region.isArray())
|
|
{
|
|
for (int idx = 0; idx < value_region.size(); idx++)
|
|
{
|
|
cv::Point p;
|
|
p.x = value_region[idx][0].asInt();
|
|
p.y = value_region[idx][1].asInt();
|
|
|
|
_config.edgeDet.region.emplace_back(p);
|
|
}
|
|
if (_config.edgeDet.region.size() > 0)
|
|
{
|
|
_config.edgeDet.draw_ROI = boundingRect(_config.edgeDet.region);
|
|
}
|
|
}
|
|
}
|
|
if (value_f["form"]["otherConfig"]["bDrawResult"])
|
|
{
|
|
_config.edgeDet.bDrawResult = value_f["form"]["otherConfig"]["bDrawResult"].asBool();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_config.edgeDet.Init();
|
|
}
|
|
// _config.edgeDet.print("edgeDet");
|
|
// getchar();
|
|
}
|
|
if ("Det_Image_Save" == strCode)
|
|
{
|
|
auto value_f = value;
|
|
// std::cout << value_f << std::endl;
|
|
// getchar();
|
|
_config.saveImg.bOpen = value_f["isOpen"].asBool();
|
|
if (_config.saveImg.bOpen)
|
|
{
|
|
|
|
if (value_f["form"]["SaveImg_Config"]["Mark_Save"])
|
|
{
|
|
_config.saveImg.bSaveMarkImg = value_f["form"]["SaveImg_Config"]["Mark_Save"].asBool();
|
|
}
|
|
if (value_f["form"]["SaveImg_Config"]["Cls_Save"])
|
|
{
|
|
_config.saveImg.bSaveClsImg = value_f["form"]["SaveImg_Config"]["Cls_Save"].asBool();
|
|
}
|
|
if (value_f["form"]["SaveImg_Config"]["Align_Big_Save"])
|
|
{
|
|
_config.saveImg.bSaveAlginImg = value_f["form"]["SaveImg_Config"]["Align_Big_Save"].asBool();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_config.saveImg.Init();
|
|
}
|
|
// _config.edgeDet.print("edgeDet");
|
|
// getchar();
|
|
}
|
|
// 边缘通道配置参数
|
|
if ("Edge_Channel" == strCode)
|
|
{
|
|
auto value_f = value;
|
|
// std::cout << value_f << std::endl;
|
|
// getchar();
|
|
_config.edgeChannel.bOpen = value_f["isOpen"].asBool();
|
|
if (_config.edgeChannel.bOpen)
|
|
{
|
|
|
|
if (value_f["form"]["Channel_Config"]["Channel_Name"])
|
|
{
|
|
_config.edgeChannel.strChannel = value_f["form"]["Channel_Config"]["Channel_Name"].asString();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_config.edgeChannel.Init();
|
|
}
|
|
// _config.edgeDet.print("edgeDet");
|
|
// getchar();
|
|
}
|
|
// 边缘通道配置参数
|
|
if ("AD_Analysis" == strCode)
|
|
{
|
|
|
|
auto value_f = value;
|
|
// std::cout << value_f << std::endl;
|
|
_config.ad_check.bOpen = value_f["isOpen"].asBool();
|
|
if (_config.ad_check.bOpen)
|
|
{
|
|
if (value_f["form"]["AD_S_Standard"]["AD_3S_Area"])
|
|
{
|
|
_config.ad_check.S_standard_3s.area = value_f["form"]["AD_S_Standard"]["AD_3S_Area"].asFloat();
|
|
}
|
|
if (value_f["form"]["AD_S_Standard"]["AD_3S_Len"])
|
|
{
|
|
_config.ad_check.S_standard_3s.len = value_f["form"]["AD_S_Standard"]["AD_3S_Len"].asFloat();
|
|
}
|
|
|
|
if (value_f["form"]["AD_S_Standard"]["AD_2S_Area"])
|
|
{
|
|
_config.ad_check.S_standard_2s.area = value_f["form"]["AD_S_Standard"]["AD_2S_Area"].asFloat();
|
|
}
|
|
if (value_f["form"]["AD_S_Standard"]["AD_2S_Len"])
|
|
{
|
|
_config.ad_check.S_standard_2s.len = value_f["form"]["AD_S_Standard"]["AD_2S_Len"].asFloat();
|
|
}
|
|
|
|
if (value_f["form"]["AD_S_Standard"]["AD_1S_Area"])
|
|
{
|
|
_config.ad_check.S_standard_1s.area = value_f["form"]["AD_S_Standard"]["AD_1S_Area"].asFloat();
|
|
}
|
|
if (value_f["form"]["AD_S_Standard"]["AD_1S_Len"])
|
|
{
|
|
_config.ad_check.S_standard_1s.len = value_f["form"]["AD_S_Standard"]["AD_1S_Len"].asFloat();
|
|
}
|
|
|
|
if (value_f["form"]["AD_Check_Num"]["Open"])
|
|
{
|
|
_config.ad_check.analysis_num.bOpen = value_f["form"]["AD_Check_Num"]["Open"].asBool();
|
|
}
|
|
if (value_f["form"]["AD_Check_Num"]["Num"])
|
|
{
|
|
_config.ad_check.analysis_num.numT = value_f["form"]["AD_Check_Num"]["Num"].asInt();
|
|
}
|
|
|
|
if (value_f["form"]["AD_Check_Dis"]["Open"])
|
|
{
|
|
_config.ad_check.analysis_dis.bOpen = value_f["form"]["AD_Check_Dis"]["Open"].asBool();
|
|
}
|
|
if (value_f["form"]["AD_Check_Dis"]["Dis"])
|
|
{
|
|
_config.ad_check.analysis_dis.disT = value_f["form"]["AD_Check_Dis"]["Dis"].asFloat();
|
|
}
|
|
|
|
if (value_f["form"]["AD_Check_S"]["Open"])
|
|
{
|
|
_config.ad_check.analysis_s.bOpen = value_f["form"]["AD_Check_S"]["Open"].asBool();
|
|
}
|
|
|
|
if (value_f["form"]["AD_Check_S"]["S_value"])
|
|
{
|
|
_config.ad_check.analysis_s.Check_s_Value = value_f["form"]["AD_Check_S"]["S_value"].asInt();
|
|
}
|
|
if (value_f["form"]["AD_Check_S"]["NG_3s"])
|
|
{
|
|
_config.ad_check.analysis_s.NG_3s = value_f["form"]["AD_Check_S"]["NG_3s"].asBool();
|
|
}
|
|
if (value_f["form"]["AD_Check_S"]["Num"])
|
|
{
|
|
_config.ad_check.analysis_s.Check_s_Num = value_f["form"]["AD_Check_S"]["Num"].asInt();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_config.ad_check.Init();
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|