feat 添加检测开关

dev_lsy
liusiyang 3 weeks ago
parent 53eb1362ed
commit 9f5ea55415

@ -837,11 +837,21 @@ int ImgCheckAnalysisy::CheckRun()
{ {
m_pImageAllResult->detImg = image(m_CutRoi).clone(); m_pImageAllResult->detImg = image(m_CutRoi).clone();
} }
// 多线程开启 传统/AI 推理检测
// bDetect为true才进行推理输出残点图否则直接输出全黑残点图
long time_AI_s = CheckUtil::getcurTime(); long time_AI_s = CheckUtil::getcurTime();
m_AItask = std::make_shared<TaskInfo>(); if(m_pBasicConfig->bDetect)
m_AItask->taskname = Task_AI; {
m_task.sendTask(m_AItask); // 多线程开启 传统/AI 推理检测
m_AItask = std::make_shared<TaskInfo>();
m_AItask->taskname = Task_AI;
m_task.sendTask(m_AItask);
}
else
{
// 不推理:直接输出全黑残点图
m_pImageAllResult->AIMaskImg = cv::Mat::zeros(m_pImageAllResult->detImg.size(), CV_8UC1);
}
ImgPreDet(); ImgPreDet();
// 更新检测区域 // 更新检测区域
@ -1465,6 +1475,13 @@ int ImgCheckAnalysisy::AIMaskDet()
m_ImgBlobHFlagData = new unsigned char[m_pImageAllResult->detImg.rows]; m_ImgBlobHFlagData = new unsigned char[m_pImageAllResult->detImg.rows];
memset(m_ImgBlobHFlagData, 0, sizeof(unsigned char) * m_pImageAllResult->detImg.rows); memset(m_ImgBlobHFlagData, 0, sizeof(unsigned char) * m_pImageAllResult->detImg.rows);
// bDetect为false时不进行推理直接输出全黑残点图
if(!m_pBasicConfig->bDetect)
{
m_CheckResult_shareP->resultMaskImg = m_pImageAllResult->AIMaskImg;
return 0;
}
// 传统检测路径等待异步任务完成后计算HFlag // 传统检测路径等待异步任务完成后计算HFlag
if(m_pbaseCheckFunction->traditionDet.bOpen) if(m_pbaseCheckFunction->traditionDet.bOpen)
{ {

@ -407,6 +407,7 @@ struct BasicConfig
float Product_Size_Height_mm; // 产品尺寸 高度 mm float Product_Size_Height_mm; // 产品尺寸 高度 mm
float fImage_Scale_x; // 成像精度 float fImage_Scale_x; // 成像精度
float fImage_Scale_y; // 成像精度 float fImage_Scale_y; // 成像精度
bool bDetect; // 是否检测
std::string strCamName; // std::string strCamName; //
std::string strConfigVersion; // 配置版本 std::string strConfigVersion; // 配置版本
@ -428,6 +429,7 @@ struct BasicConfig
Product_Size_Height_mm = 1000; Product_Size_Height_mm = 1000;
fImage_Scale_x = 0.03; fImage_Scale_x = 0.03;
fImage_Scale_y = 0.03; fImage_Scale_y = 0.03;
bDetect = true;
density_R_mm = 5; density_R_mm = 5;
strCamName = ""; strCamName = "";
strConfigVersion = "1.0"; strConfigVersion = "1.0";
@ -452,6 +454,7 @@ struct BasicConfig
this->Product_Size_Height_mm = tem.Product_Size_Height_mm; this->Product_Size_Height_mm = tem.Product_Size_Height_mm;
this->fImage_Scale_x = tem.fImage_Scale_x; this->fImage_Scale_x = tem.fImage_Scale_x;
this->fImage_Scale_y = tem.fImage_Scale_y; this->fImage_Scale_y = tem.fImage_Scale_y;
this->bDetect = tem.bDetect;
this->density_R_mm = tem.density_R_mm; this->density_R_mm = tem.density_R_mm;
this->strCamearName = tem.strCamearName; this->strCamearName = tem.strCamearName;
this->strConfigVersion = tem.strConfigVersion; this->strConfigVersion = tem.strConfigVersion;
@ -463,6 +466,7 @@ struct BasicConfig
printf("bCal_ImageScale %d Product_Size_Width =%f Product_Size_Height =%f \n", bCal_ImageScale, Product_Size_Width_mm, Product_Size_Height_mm); printf("bCal_ImageScale %d Product_Size_Width =%f Product_Size_Height =%f \n", bCal_ImageScale, Product_Size_Width_mm, Product_Size_Height_mm);
printf("fImage_Scale_x =%f fImage_Scale_y=%f \n", fImage_Scale_x, fImage_Scale_y); printf("fImage_Scale_x =%f fImage_Scale_y=%f \n", fImage_Scale_x, fImage_Scale_y);
printf("density_R_mm=%f \n", density_R_mm); printf("density_R_mm=%f \n", density_R_mm);
printf("bDetect=%d \n", bDetect);
// printf("height_min =%d height_max=%d \n", height_min, height_max); // printf("height_min =%d height_max=%d \n", height_min, height_max);
printf("bDrawShieldRoi %d bShield_ZF %d DrawPreRoi %d fUP_IOU %f density_R_mm %f\n", bDrawShieldRoi, bShield_ZF, bDrawPreRoi, fUP_IOU, density_R_mm); printf("bDrawShieldRoi %d bShield_ZF %d DrawPreRoi %d fUP_IOU %f density_R_mm %f\n", bDrawShieldRoi, bShield_ZF, bDrawPreRoi, fUP_IOU, density_R_mm);
printf("============================↑↑↑↑↑↑%s↑↑↑↑↑↑=========================\n", str.c_str()); printf("============================↑↑↑↑↑↑%s↑↑↑↑↑↑=========================\n", str.c_str());

@ -62,6 +62,7 @@ void CommonParamToCheckConfigJson::toObjectFromValue(Json::Value root)
_config.baseConfig.Product_Size_Height_mm = value["Product_Size_H"].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_x = value["Image_Scale_X"].asFloat();
_config.baseConfig.fImage_Scale_y = value["Image_Scale_Y"].asFloat(); _config.baseConfig.fImage_Scale_y = value["Image_Scale_Y"].asFloat();
_config.baseConfig.bDetect = value["bDetect"].asFloat();
if (value["Density_R"]) if (value["Density_R"])
{ {
_config.baseConfig.density_R_mm = value["Density_R"].asFloat(); _config.baseConfig.density_R_mm = value["Density_R"].asFloat();

Loading…
Cancel
Save