更新测试模式下的图像标注细节

This commit is contained in:
Mr.V 2024-11-25 19:01:44 +08:00
parent a977d702ca
commit c1cb59eba9
4 changed files with 19 additions and 8 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -65,7 +65,6 @@ APP_ERROR SaveDebugImageEngine::Process()
+ "_" + "_"
+ std::to_string(pVStep2OutputData->iDataSource) + ".jpg"; + std::to_string(pVStep2OutputData->iDataSource) + ".jpg";
LogInfo << "strJsonPath:" << strJsonPath << " strImagePath:" << strImagePath;
Json::Value jvFrameInfo; Json::Value jvFrameInfo;
if (!FileUtil::getins()->readJsonInfo(jvFrameInfo, strJsonPath)) if (!FileUtil::getins()->readJsonInfo(jvFrameInfo, strJsonPath))
{ {
@ -74,6 +73,12 @@ APP_ERROR SaveDebugImageEngine::Process()
cv::Mat image = cv::imread(strImagePath); cv::Mat image = cv::imread(strImagePath);
if (image.empty())
{
LogWarn << "图像未找到:" << strImagePath;
continue;
}
std::stringstream ss; std::stringstream ss;
std::vector<std::string> vecTitle; std::vector<std::string> vecTitle;
vecTitle.emplace_back("FrameID:" + to_string(pVStep2OutputData->iFrameId)); vecTitle.emplace_back("FrameID:" + to_string(pVStep2OutputData->iFrameId));
@ -81,12 +86,12 @@ APP_ERROR SaveDebugImageEngine::Process()
int base_line = 0; int base_line = 0;
cv::Point text_org(15, 45); // 文本起始点 cv::Point text_org(15, 45); // 文本起始点
for (int i = 0; i < vecTitle.size(); ++i) for (const auto & i : vecTitle)
{ {
cv::Size text_size = cv::getTextSize(vecTitle.at(i), cv::FONT_HERSHEY_SIMPLEX, 1, 2, 0); cv::Size text_size = cv::getTextSize(i, cv::FONT_HERSHEY_SIMPLEX, 1, 2, 0);
cv::Point baseline_loc(text_org); cv::Point baseline_loc(text_org);
baseline_loc.y += base_line + text_size.height; baseline_loc.y += base_line + text_size.height;
cv::putText(image, vecTitle.at(i), baseline_loc, cv::FONT_HERSHEY_SIMPLEX, 1, cv::Scalar(0, 255, 0, 255), 2); cv::putText(image, i, baseline_loc, cv::FONT_HERSHEY_SIMPLEX, 1, cv::Scalar(0, 255, 0, 255), 2);
// 手动调整x位置为下一个单词留出空间 // 手动调整x位置为下一个单词留出空间
text_org.x += text_size.width + 10; text_org.x += text_size.width + 10;
text_org.x = text_org.x > IMAGE_WIDTH ? 15 : text_org.x; text_org.x = text_org.x > IMAGE_WIDTH ? 15 : text_org.x;
@ -106,13 +111,14 @@ APP_ERROR SaveDebugImageEngine::Process()
cv::Point(centerX, pVStep2OutputData->step2ResultData.fLTY-30), cv::Point(centerX, pVStep2OutputData->step2ResultData.fRBY+30), cv::Point(centerX, pVStep2OutputData->step2ResultData.fLTY-30), cv::Point(centerX, pVStep2OutputData->step2ResultData.fRBY+30),
cvScalar, 1); cvScalar, 1);
cv::Point linePoint(pVStep2OutputData->step2ResultData.fLTX + 10, pVStep2OutputData->step2ResultData.fRBY + 10); cv::Size text_size = cv::getTextSize(pVStep2OutputData->step2ResultData.transInfo.strTmpResult, cv::FONT_HERSHEY_SIMPLEX, 1, 2, 0);
cv::Point linePoint(pVStep2OutputData->step2ResultData.fLTX, pVStep2OutputData->step2ResultData.fRBY + text_size.height + 5);
cv::putText(image, cv::putText(image,
pVStep2OutputData->step2ResultData.transInfo.strTmpResult, pVStep2OutputData->step2ResultData.transInfo.strTmpResult,
linePoint, linePoint,
cv::FONT_HERSHEY_SIMPLEX, 1, cv::Scalar(0, 255, 0, 180), 2); cv::FONT_HERSHEY_SIMPLEX, 1, cv::Scalar(0, 255, 0, 180), 2);
for (auto &step2ResultData : pVStep2OutputData->vecCornerResultData) for (const auto &step2ResultData : pVStep2OutputData->vecCornerResultData)
{ {
cvScalar = {0, 255, 255, 255}; cvScalar = {0, 255, 255, 255};
float centerX_corner = step2ResultData.fLTX + (step2ResultData.fRBX - step2ResultData.fLTX)/2; float centerX_corner = step2ResultData.fLTX + (step2ResultData.fRBX - step2ResultData.fLTX)/2;
@ -129,6 +135,10 @@ APP_ERROR SaveDebugImageEngine::Process()
{ {
LogError << "图片存储失败:" << strImagePath; LogError << "图片存储失败:" << strImagePath;
} }
// else
// {
// LogInfo << "图片存储成功:" << strImagePath;
// }
} }
return APP_ERR_OK; return APP_ERR_OK;
} }

View File

@ -66,6 +66,7 @@ APP_ERROR SaveMoveImageEngine::Process()
// pToStep1Data->strImageName = pSaveImgData->strFileName; // pToStep1Data->strImageName = pSaveImgData->strFileName;
// //
// outputQueMap_[strPort0_]->push(std::static_pointer_cast<void>(pToStep1Data), true); // outputQueMap_[strPort0_]->push(std::static_pointer_cast<void>(pToStep1Data), true);
// LogInfo << "存储:" << strImgFilePath;
} }
else else
{ {