|
|
|
|
@ -147,6 +147,14 @@ int ImageResultJudge::ResultJudge(std::shared_ptr<ImageAllResult> pImageResult)
|
|
|
|
|
std::shared_ptr<CheckResult> m_CheckResult_shareP = pImageResult->result; // 返回结果
|
|
|
|
|
int qxNum = pDetResult->pQx_ErrorList->size();
|
|
|
|
|
|
|
|
|
|
// 图像模糊: 检测阶段已在 AI 检测之前判定, 这里保证结果保持 NG(复测 ReJson 读取 json 后同样生效)
|
|
|
|
|
if (pDetResult->bBlurNG)
|
|
|
|
|
{
|
|
|
|
|
m_CheckResult_shareP->nresult = 1;
|
|
|
|
|
pImageLog->AddCheckstr(PrintLevel_0, "Blur Check",
|
|
|
|
|
"image blurred -> NG (variance %.2f)", pDetResult->fBlurScore);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// map<string, vector<iregionQxZoningInfo>> allQxZoning;
|
|
|
|
|
|
|
|
|
|
map<string, vector<singleQxZoningInfo>> allQxZoning;
|
|
|
|
|
@ -173,9 +181,9 @@ int ImageResultJudge::ResultJudge(std::shared_ptr<ImageAllResult> pImageResult)
|
|
|
|
|
std::string qx_wb = WHITE_BLCAK_Names[QX_whiteBLACK];
|
|
|
|
|
|
|
|
|
|
pQxLog->AddCheckstr(PrintLevel_1,
|
|
|
|
|
"", "qxidx: %d roi[%d %d %d %d] qx %d %s %s JudgArea %f hj %f len %f breadth %f energy %d region num %ld",
|
|
|
|
|
"", "qxidx: %d roi[%d %d %d %d] qx %d %s %s JudgArea %f hj %f len %f breadth %f energy %d region num %ld detModel: %s",
|
|
|
|
|
qxidx, roi.x, roi.y, roi.width, roi.height, config_qx_type, qx_name.c_str(), qx_wb.c_str(),
|
|
|
|
|
JudgArea, grayDis, flen, fbreadth, energy, QX_info->detRegionidxList.size());
|
|
|
|
|
JudgArea, grayDis, flen, fbreadth, energy, QX_info->detRegionidxList.size(), QX_info->strModelName.c_str());
|
|
|
|
|
|
|
|
|
|
cv::Point pCenter;
|
|
|
|
|
pCenter.x = roi.x + roi.width * 0.5;
|
|
|
|
|
@ -271,36 +279,17 @@ int ImageResultJudge::ResultJudge(std::shared_ptr<ImageAllResult> pImageResult)
|
|
|
|
|
allQxZoning[qx_name].push_back(singleQxZoningInfoTemp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 黑缺陷
|
|
|
|
|
if (QX_whiteBLACK == CONFIG_QX_WHITE)
|
|
|
|
|
{
|
|
|
|
|
// pQxLog->AddCheckstr(PrintLevel_3, DET_LOG_LEVEL_3, "param---", "qx :white");
|
|
|
|
|
if (hj >= 0 || Et >= 0)
|
|
|
|
|
{
|
|
|
|
|
pQxLog->AddCheckstr(PrintLevel_4, DET_LOG_LEVEL_3, "param ", "Error param idx %d / %d qx white hj %f and energ %f >0",
|
|
|
|
|
j + 1, pParam->useNum, hj, Et);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
Et = std::abs(Et);
|
|
|
|
|
hj = std::abs(hj);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// pQxLog->AddCheckstr(PrintLevel_3, DET_LOG_LEVEL_3, "param---", "qx :blcak");
|
|
|
|
|
if (hj < 0 || Et < 0)
|
|
|
|
|
{
|
|
|
|
|
pQxLog->AddCheckstr(PrintLevel_4, DET_LOG_LEVEL_3, "param ", "Error param idx %d / %d qx blcak hj %f and energ %f < 0",
|
|
|
|
|
j + 1, pParam->useNum, hj, Et);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 不区分亮暗缺陷: 参数(阈值)按正数配置; 实测灰阶/能量可能为负, 取绝对值后参与比较
|
|
|
|
|
int energyAbs = std::abs(energy);
|
|
|
|
|
float grayDisAbs = std::abs(grayDis);
|
|
|
|
|
|
|
|
|
|
Judge_Status = true;
|
|
|
|
|
|
|
|
|
|
float detArea = JudgArea;
|
|
|
|
|
|
|
|
|
|
if (energy >= Et &&
|
|
|
|
|
if (energyAbs >= Et &&
|
|
|
|
|
detArea >= At &&
|
|
|
|
|
grayDis >= hj &&
|
|
|
|
|
grayDisAbs >= hj &&
|
|
|
|
|
flen >= Len &&
|
|
|
|
|
fbreadth >= Breadth)
|
|
|
|
|
{
|
|
|
|
|
@ -330,15 +319,15 @@ int ImageResultJudge::ResultJudge(std::shared_ptr<ImageAllResult> pImageResult)
|
|
|
|
|
pQxLog->AddCheckstr(PrintLevel_4, DET_LOG_LEVEL_3, "Area", "%s -> %f %s %f ",
|
|
|
|
|
BOOL_TO_STR(detArea >= At), detArea, BOOL_TO_ThanLess(detArea >= At), At);
|
|
|
|
|
}
|
|
|
|
|
if (energy < Et)
|
|
|
|
|
if (energyAbs < Et)
|
|
|
|
|
{
|
|
|
|
|
pQxLog->AddCheckstr(PrintLevel_4, DET_LOG_LEVEL_3, "Energy", "%s -> %d %s %f ",
|
|
|
|
|
BOOL_TO_STR(energy >= Et), energy, BOOL_TO_ThanLess(energy >= Et), Et);
|
|
|
|
|
BOOL_TO_STR(energyAbs >= Et), energyAbs, BOOL_TO_ThanLess(energyAbs >= Et), Et);
|
|
|
|
|
}
|
|
|
|
|
if (grayDis < hj)
|
|
|
|
|
if (grayDisAbs < hj)
|
|
|
|
|
{
|
|
|
|
|
pQxLog->AddCheckstr(PrintLevel_4, DET_LOG_LEVEL_3, "HJ", "%s -> %f %s %f ",
|
|
|
|
|
BOOL_TO_STR(grayDis >= hj), grayDis, BOOL_TO_ThanLess(grayDis > hj), hj);
|
|
|
|
|
BOOL_TO_STR(grayDisAbs >= hj), grayDisAbs, BOOL_TO_ThanLess(grayDisAbs > hj), hj);
|
|
|
|
|
}
|
|
|
|
|
if (flen < Len)
|
|
|
|
|
{
|
|
|
|
|
@ -381,6 +370,14 @@ int ImageResultJudge::ResultJudge(std::shared_ptr<ImageAllResult> pImageResult)
|
|
|
|
|
|
|
|
|
|
std::string resultType = "OK";
|
|
|
|
|
|
|
|
|
|
// PIN_PianYi, 不受区域参数控制;
|
|
|
|
|
if (!Judge_Status && config_qx_type == CONFIG_QX_NAME_PIN_PianYi)
|
|
|
|
|
{
|
|
|
|
|
pQxLog->AddCheckstr(PrintLevel_3, "qx info", " PIN_PianYi: region param not used -> report NG by base judge");
|
|
|
|
|
Judge_Status = true;
|
|
|
|
|
bNG_Status = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Judge_Status)
|
|
|
|
|
{
|
|
|
|
|
QX_info->result = QX_RESULT_TYPE_NoJduge;
|
|
|
|
|
@ -503,13 +500,20 @@ int ImageResultJudge::ResultJudge(std::shared_ptr<ImageAllResult> pImageResult)
|
|
|
|
|
// CheckUtil::printROI(CutRoi, "CutRoi");
|
|
|
|
|
cv::Size sz = cv::Size(QX_SAMLLIMG_WIDTH, QX_SAMLLIMG_HEIGHT);
|
|
|
|
|
|
|
|
|
|
if (pImageResult->detImg.channels() == 1)
|
|
|
|
|
{
|
|
|
|
|
cv::cvtColor(pImageResult->detImg(CutRoi), tem.srcImg, cv::COLOR_GRAY2BGR);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
// 缺陷小图直接取自原图裁剪区(保持原图通道 -> 真实彩色),ReJson/异常时退回检测图
|
|
|
|
|
{
|
|
|
|
|
tem.srcImg = pImageResult->detImg(CutRoi).clone();
|
|
|
|
|
const cv::Mat &srcImg = pImageResult->result->in_shareImage->img;
|
|
|
|
|
int nOffsetX = (pImageResult->result->in_shareImage->Det_Mode != DET_MODE_ReJson) ? pDetResult->CutRoi.x : 0;
|
|
|
|
|
int nOffsetY = (pImageResult->result->in_shareImage->Det_Mode != DET_MODE_ReJson) ? pDetResult->CutRoi.y : 0;
|
|
|
|
|
cv::Rect srcCanvasRoi(CutRoi.x + nOffsetX, CutRoi.y + nOffsetY, CutRoi.width, CutRoi.height);
|
|
|
|
|
if (!srcImg.empty() && CheckUtil::RoiInImg(srcCanvasRoi, srcImg))
|
|
|
|
|
{
|
|
|
|
|
tem.srcImg = srcImg(srcCanvasRoi).clone();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tem.srcImg = pImageResult->detImg(CutRoi).clone();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cv::resize(tem.srcImg, tem.resizeImg, sz);
|
|
|
|
|
|
|
|
|
|
@ -559,9 +563,7 @@ int ImageResultJudge::ResultJudge(std::shared_ptr<ImageAllResult> pImageResult)
|
|
|
|
|
|
|
|
|
|
GetAIDetImg(pImageResult, pCenter, tem.AI_in_Img, tem.AI_out_img);
|
|
|
|
|
m_CheckResult_shareP->qxImageResult.push_back(tem);
|
|
|
|
|
pQxLog->bPrintStr = true;
|
|
|
|
|
pQxLog->AddCheckstr(PrintLevel_4, DET_LOG_LEVEL_3, " result ", " ---name: %s ---code: %s ---srcImgroi.x: %d ---srcImgroi.y: %d\n", tem.strTypeName.c_str(), tem.qx_Code.c_str(), tem.srcImgroi.x, tem.srcImgroi.y);
|
|
|
|
|
pQxLog->bPrintStr = false;
|
|
|
|
|
pQxLog->AddCheckstr(PrintLevel_4, DET_LOG_LEVEL_3, " result ", " ---name: %s ---code: %s ---detModel: %s ---srcImgroi.x: %d ---srcImgroi.y: %d\n", tem.strTypeName.c_str(), tem.qx_Code.c_str(), QX_info->strModelName.c_str(), tem.srcImgroi.x, tem.srcImgroi.y);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
@ -574,6 +576,8 @@ int ImageResultJudge::ResultJudge(std::shared_ptr<ImageAllResult> pImageResult)
|
|
|
|
|
GetAIDetImg(pImageResult, pCenter, tem.AI_in_Img, tem.AI_out_img);
|
|
|
|
|
|
|
|
|
|
m_CheckResult_shareP->YS_ImageResult.push_back(tem);
|
|
|
|
|
// 疑似小图 也需要能追溯 是哪个模型检出的残点
|
|
|
|
|
pQxLog->AddCheckstr(PrintLevel_4, DET_LOG_LEVEL_3, " YS result ", " ---name: %s ---code: %s ---detModel: %s ---srcImgroi.x: %d ---srcImgroi.y: %d\n", tem.strTypeName.c_str(), tem.qx_Code.c_str(), QX_info->strModelName.c_str(), tem.srcImgroi.x, tem.srcImgroi.y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -622,13 +626,20 @@ int ImageResultJudge::ResultJudge(std::shared_ptr<ImageAllResult> pImageResult)
|
|
|
|
|
// CheckUtil::printROI(CutRoi, "CutRoi");
|
|
|
|
|
cv::Size sz = cv::Size(QX_SAMLLIMG_WIDTH, QX_SAMLLIMG_HEIGHT);
|
|
|
|
|
|
|
|
|
|
if (pImageResult->detImg.channels() == 1)
|
|
|
|
|
// 缺陷小图直接取自原图裁剪区(保持原图通道 -> 真实彩色),ReJson/异常时退回检测图
|
|
|
|
|
{
|
|
|
|
|
cv::cvtColor(pImageResult->detImg(CutRoi), tem.srcImg, cv::COLOR_GRAY2BGR);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tem.srcImg = pImageResult->detImg(CutRoi).clone();
|
|
|
|
|
const cv::Mat &srcImg = pImageResult->result->in_shareImage->img;
|
|
|
|
|
int nOffsetX = (pImageResult->result->in_shareImage->Det_Mode != DET_MODE_ReJson) ? pDetResult->CutRoi.x : 0;
|
|
|
|
|
int nOffsetY = (pImageResult->result->in_shareImage->Det_Mode != DET_MODE_ReJson) ? pDetResult->CutRoi.y : 0;
|
|
|
|
|
cv::Rect srcCanvasRoi(CutRoi.x + nOffsetX, CutRoi.y + nOffsetY, CutRoi.width, CutRoi.height);
|
|
|
|
|
if (!srcImg.empty() && CheckUtil::RoiInImg(srcCanvasRoi, srcImg))
|
|
|
|
|
{
|
|
|
|
|
tem.srcImg = srcImg(srcCanvasRoi).clone();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tem.srcImg = pImageResult->detImg(CutRoi).clone();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cv::resize(tem.srcImg, tem.resizeImg, sz);
|
|
|
|
|
|
|
|
|
|
@ -675,6 +686,8 @@ int ImageResultJudge::ResultJudge(std::shared_ptr<ImageAllResult> pImageResult)
|
|
|
|
|
|
|
|
|
|
GetAIDetImg(pImageResult, pCenter, tem.AI_in_Img, tem.AI_out_img);
|
|
|
|
|
m_CheckResult_shareP->qxImageResult.push_back(tem);
|
|
|
|
|
// YS 转 NG 的残点也需要能追溯 是哪个模型检出的
|
|
|
|
|
pQxLog->AddCheckstr(PrintLevel_3, DET_LOG_LEVEL_3, " YS to NG img ", " ---name: %s ---code: %s ---detModel: %s ---srcImgroi.x: %d ---srcImgroi.y: %d\n", tem.strTypeName.c_str(), tem.qx_Code.c_str(), QX_info->strModelName.c_str(), tem.srcImgroi.x, tem.srcImgroi.y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -781,32 +794,9 @@ int ImageResultJudge::DrawResult(std::shared_ptr<ImageAllResult> pImageResult)
|
|
|
|
|
draw_str->txtP = cv::Point(draw_qx->cp.x + r, draw_qx->cp.y - r);
|
|
|
|
|
draw_str->txtsize = 0.5;
|
|
|
|
|
draw_str->txtbackgroundk = txtbackgroundk;
|
|
|
|
|
cv::Rect srcroi = pqx->srcImgroi;
|
|
|
|
|
cv::Point srccp = cv::Point(srcroi.x + srcroi.width * .5, srcroi.y + srcroi.height * 0.5);
|
|
|
|
|
|
|
|
|
|
char buffer[128];
|
|
|
|
|
{
|
|
|
|
|
std::string text = std::to_string(pqx->idx) + ":" + pqx->strTypeName;
|
|
|
|
|
draw_str->strlist.push_back(text);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
sprintf(buffer, " center:%d %d", srccp.x, srccp.y);
|
|
|
|
|
std::string text = buffer;
|
|
|
|
|
draw_str->strlist.push_back(text);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
sprintf(buffer, " len %0.2f A: %0.2f ", pqx->len, pqx->area);
|
|
|
|
|
std::string text = buffer;
|
|
|
|
|
draw_str->strlist.push_back(text);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
sprintf(buffer, " breadth %0.2f A: %0.2f ", pqx->breadth, pqx->area);
|
|
|
|
|
std::string text = buffer;
|
|
|
|
|
draw_str->strlist.push_back(text);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
sprintf(buffer, " E:%0.2f hj %0.2f", pqx->energy, pqx->hj);
|
|
|
|
|
std::string text = buffer;
|
|
|
|
|
// 只绘制 id:缺陷code (缺陷名可能中文乱码, 用code替代)
|
|
|
|
|
std::string text = std::to_string(pqx->idx) + ":" + pqx->qx_Code;
|
|
|
|
|
draw_str->strlist.push_back(text);
|
|
|
|
|
}
|
|
|
|
|
sendTask(draw_str);
|
|
|
|
|
@ -1044,41 +1034,32 @@ int ImageResultJudge::ConfigTypeToResultType(int nconfigType)
|
|
|
|
|
{
|
|
|
|
|
switch (nconfigType)
|
|
|
|
|
{
|
|
|
|
|
case CONFIG_QX_NAME_cell_aotudian:
|
|
|
|
|
resultError_type = ERROR_TYPE_aotudian;
|
|
|
|
|
break;
|
|
|
|
|
case CONFIG_QX_NAME_cell_other:
|
|
|
|
|
resultError_type = ERROR_TYPE_other;
|
|
|
|
|
break;
|
|
|
|
|
case CONFIG_QX_NAME_cell_line:
|
|
|
|
|
resultError_type = ERROR_TYPE_line;
|
|
|
|
|
break;
|
|
|
|
|
case CONFIG_QX_NAME_cell_zangwu:
|
|
|
|
|
resultError_type = ERROR_TYPE_zangwu;
|
|
|
|
|
case CONFIG_QX_NAME_PIN_PoSun:
|
|
|
|
|
resultError_type = ERROR_TYPE_PIN_PoSun;
|
|
|
|
|
break;
|
|
|
|
|
case CONFIG_QX_NAME_cell_edge:
|
|
|
|
|
resultError_type = ERROR_TYPE_edge;
|
|
|
|
|
case CONFIG_QX_NAME_PIN_QueShi:
|
|
|
|
|
resultError_type = ERROR_TYPE_PIN_QueShi;
|
|
|
|
|
break;
|
|
|
|
|
case CONFIG_QX_NAME_cell_ymhs:
|
|
|
|
|
resultError_type = ERROR_TYPE_ymhs;
|
|
|
|
|
case CONFIG_QX_NAME_BTB_DuanLie:
|
|
|
|
|
resultError_type = ERROR_TYPE_BTB_DuanLie;
|
|
|
|
|
break;
|
|
|
|
|
case CONFIG_QX_NAME_cell_dianzhuang:
|
|
|
|
|
resultError_type = ERROR_TYPE_dianzhuang;
|
|
|
|
|
case CONFIG_QX_NAME_LianXi:
|
|
|
|
|
resultError_type = ERROR_TYPE_LianXi;
|
|
|
|
|
break;
|
|
|
|
|
case CONFIG_QX_NAME_cell_posun:
|
|
|
|
|
resultError_type = ERROR_TYPE_posun;
|
|
|
|
|
case CONFIG_QX_NAME_QueXi:
|
|
|
|
|
resultError_type = ERROR_TYPE_QueXi;
|
|
|
|
|
break;
|
|
|
|
|
case CONFIG_QX_NAME_cell_xianwei:
|
|
|
|
|
resultError_type = ERROR_TYPE_xianwei;
|
|
|
|
|
case CONFIG_QX_NAME_YiWu:
|
|
|
|
|
resultError_type = ERROR_TYPE_YiWu;
|
|
|
|
|
break;
|
|
|
|
|
case CONFIG_QX_NAME_cell_shuizi:
|
|
|
|
|
resultError_type = ERROR_TYPE_shuizi;
|
|
|
|
|
case CONFIG_QX_NAME_C_BianXing:
|
|
|
|
|
resultError_type = ERROR_TYPE_C_BianXing;
|
|
|
|
|
break;
|
|
|
|
|
case CONFIG_QX_NAME_cell_danban:
|
|
|
|
|
resultError_type = ERROR_TYPE_danban;
|
|
|
|
|
case CONFIG_QX_NAME_PIN_PianYi:
|
|
|
|
|
resultError_type = ERROR_TYPE_PIN_PianYi;
|
|
|
|
|
break;
|
|
|
|
|
case CONFIG_QX_NAME_cell_fuchen:
|
|
|
|
|
resultError_type = ERROR_TYPE_fuchen;
|
|
|
|
|
case CONFIG_QX_NAME_Panel:
|
|
|
|
|
resultError_type = ERROR_TYPE_Panel;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
@ -1119,11 +1100,27 @@ void ImageResultJudge::ThreadDraw()
|
|
|
|
|
while (!m_bExit)
|
|
|
|
|
{
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(0));
|
|
|
|
|
// 等待是否有任务
|
|
|
|
|
std::shared_ptr<ImageResultJudge::DrawInfo> draw = GetTask();
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<ImageResultJudge::DrawInfo> draw;
|
|
|
|
|
// 取任务与 计数+1 必须在同一把锁内完成,
|
|
|
|
|
// 否则 WaiteDrawComplate 可能在任务已出队但尚未计数的间隙提前返回。
|
|
|
|
|
{
|
|
|
|
|
std::unique_lock<std::mutex> lock(m_task_mutex_);
|
|
|
|
|
m_task_cv_.wait(lock, [this]()
|
|
|
|
|
{ return !m_DrawInfoList.empty(); });
|
|
|
|
|
|
|
|
|
|
draw = std::move(m_DrawInfoList.front());
|
|
|
|
|
m_DrawInfoList.pop();
|
|
|
|
|
m_nDrawProcessingNum++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 把任务发送给对应的任务处理函数进行处理
|
|
|
|
|
DrawResultTask(draw);
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
std::lock_guard<std::mutex> lock(m_task_mutex_);
|
|
|
|
|
m_nDrawProcessingNum--;
|
|
|
|
|
}
|
|
|
|
|
m_drawComplate_cv_.notify_all();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -1133,7 +1130,7 @@ int ImageResultJudge::DrawResultTask(std::shared_ptr<ImageResultJudge::DrawInfo>
|
|
|
|
|
|
|
|
|
|
if (task->type == Draw_circle)
|
|
|
|
|
{
|
|
|
|
|
cv::circle(task->drawImg, task->cp, task->dr, task->color);
|
|
|
|
|
cv::circle(task->drawImg, task->cp, task->dr, CheckUtil::GetDrawColor(task->drawImg, task->color));
|
|
|
|
|
if (task->txtbackgroundk)
|
|
|
|
|
{
|
|
|
|
|
task->txtbackgroundk->txtDrawRoi.push_back(task->roi);
|
|
|
|
|
@ -1141,7 +1138,7 @@ int ImageResultJudge::DrawResultTask(std::shared_ptr<ImageResultJudge::DrawInfo>
|
|
|
|
|
}
|
|
|
|
|
if (task->type == Draw_rect)
|
|
|
|
|
{
|
|
|
|
|
cv::rectangle(task->drawImg, task->roi, task->color);
|
|
|
|
|
cv::rectangle(task->drawImg, task->roi, CheckUtil::GetDrawColor(task->drawImg, task->color));
|
|
|
|
|
if (task->txtbackgroundk)
|
|
|
|
|
{
|
|
|
|
|
task->txtbackgroundk->txtDrawRoi.push_back(task->roi);
|
|
|
|
|
@ -1205,7 +1202,7 @@ int ImageResultJudge::DrawResultTask(std::shared_ptr<ImageResultJudge::DrawInfo>
|
|
|
|
|
|
|
|
|
|
// 画文字
|
|
|
|
|
cv::putText(task->drawImg, txt, cv::Point(r.x, r.y + height),
|
|
|
|
|
fontFace, fontScale, task->color, thickness);
|
|
|
|
|
fontFace, fontScale, CheckUtil::GetDrawColor(task->drawImg, task->color), thickness);
|
|
|
|
|
height += lineHeight; // 下一行
|
|
|
|
|
}
|
|
|
|
|
// cv::rectangle(task->drawImg, rtxt, cv::Scalar(255, 0, 0));
|
|
|
|
|
@ -1213,7 +1210,7 @@ int ImageResultJudge::DrawResultTask(std::shared_ptr<ImageResultJudge::DrawInfo>
|
|
|
|
|
cv::Point p(r.x, r.y);
|
|
|
|
|
if (task->cp.x - r.x > 30 || task->cp.y - r.y > 30)
|
|
|
|
|
{
|
|
|
|
|
cv::line(task->drawImg, p, task->cp, cv::Scalar(80, 0, 200));
|
|
|
|
|
cv::line(task->drawImg, p, task->cp, CheckUtil::GetDrawColor(task->drawImg, cv::Scalar(80, 0, 200)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// cv::circle(task->drawImg, task->cp, 3, task->color);
|
|
|
|
|
@ -1224,10 +1221,13 @@ int ImageResultJudge::DrawResultTask(std::shared_ptr<ImageResultJudge::DrawInfo>
|
|
|
|
|
|
|
|
|
|
int ImageResultJudge::WaiteDrawComplate()
|
|
|
|
|
{
|
|
|
|
|
// 等待 所有绘制任务真正执行完成。
|
|
|
|
|
// 旧实现只等待队列为空,而任务在取出时即已出队,绘制仍在后台线程进行,
|
|
|
|
|
// 调用方(结果存图/拷贝)可能与绘制线程并发读写同一张图片。
|
|
|
|
|
{
|
|
|
|
|
std::unique_lock<std::mutex> lock(m_task_mutex_);
|
|
|
|
|
m_drawComplate_cv_.wait(lock, [this]()
|
|
|
|
|
{ return m_DrawInfoList.empty(); });
|
|
|
|
|
{ return m_DrawInfoList.empty() && m_nDrawProcessingNum == 0; });
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|