完善测试模式的图像标记和识别结果的记录
This commit is contained in:
parent
6a82b056b4
commit
9cf88aa078
File diff suppressed because one or more lines are too long
|
|
@ -56,6 +56,8 @@ void ControlEngine::endIdentify(int iDataSource)
|
||||||
std::shared_ptr<VDetectInfo> pVDetectInfo = std::make_shared<VDetectInfo>();
|
std::shared_ptr<VDetectInfo> pVDetectInfo = std::make_shared<VDetectInfo>();
|
||||||
pVDetectInfo->bIsEnd = true;
|
pVDetectInfo->bIsEnd = true;
|
||||||
pVDetectInfo->iDataSource = iDataSource;
|
pVDetectInfo->iDataSource = iDataSource;
|
||||||
|
pVDetectInfo->strDetectDate = this->strDetectDate_;
|
||||||
|
pVDetectInfo->strDetectTime = this->strDetectTime_;
|
||||||
// 传给推理引擎
|
// 传给推理引擎
|
||||||
outputQueMap_[strPort1_]->push(std::static_pointer_cast<void>(pVDetectInfo), true);
|
outputQueMap_[strPort1_]->push(std::static_pointer_cast<void>(pVDetectInfo), true);
|
||||||
outputQueMap_[strPort2_]->push(std::static_pointer_cast<void>(pVDetectInfo), true);
|
outputQueMap_[strPort2_]->push(std::static_pointer_cast<void>(pVDetectInfo), true);
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,8 @@ APP_ERROR CornerInferenceEngine::Process()
|
||||||
std::shared_ptr<InferenceResultData> pInferenceResultData = std::make_shared<InferenceResultData>();
|
std::shared_ptr<InferenceResultData> pInferenceResultData = std::make_shared<InferenceResultData>();
|
||||||
pInferenceResultData->iDataSource = pVDetectInfo->iDataSource;
|
pInferenceResultData->iDataSource = pVDetectInfo->iDataSource;
|
||||||
pInferenceResultData->bIsEnd = pVDetectInfo->bIsEnd;
|
pInferenceResultData->bIsEnd = pVDetectInfo->bIsEnd;
|
||||||
|
pInferenceResultData->strDetectDate = pVDetectInfo->strDetectDate;
|
||||||
|
pInferenceResultData->strDetectTime = pVDetectInfo->strDetectTime;
|
||||||
if (pVDetectInfo->bIsEnd)
|
if (pVDetectInfo->bIsEnd)
|
||||||
{
|
{
|
||||||
outputQueMap_[strPort0_]->push(std::static_pointer_cast<void>(pInferenceResultData), true);
|
outputQueMap_[strPort0_]->push(std::static_pointer_cast<void>(pInferenceResultData), true);
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -48,6 +48,7 @@ APP_ERROR SaveDebugImageEngine::Process()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<VStep2OutputData> pVStep2OutputData = std::static_pointer_cast<VStep2OutputData>(pvoidd);
|
std::shared_ptr<VStep2OutputData> pVStep2OutputData = std::static_pointer_cast<VStep2OutputData>(pvoidd);
|
||||||
|
|
||||||
std::string strDataDir = this->baseConfig_.strDebugResultPath + "/"
|
std::string strDataDir = this->baseConfig_.strDebugResultPath + "/"
|
||||||
|
|
@ -64,6 +65,7 @@ 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))
|
||||||
{
|
{
|
||||||
|
|
@ -104,14 +106,22 @@ 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::putText(image,
|
||||||
|
pVStep2OutputData->step2ResultData.transInfo.strTmpResult,
|
||||||
|
linePoint,
|
||||||
|
cv::FONT_HERSHEY_SIMPLEX, 1, cv::Scalar(0, 255, 0, 180), 2);
|
||||||
|
|
||||||
for (auto &step2ResultData : pVStep2OutputData->vecCornerResultData)
|
for (auto &step2ResultData : pVStep2OutputData->vecCornerResultData)
|
||||||
{
|
{
|
||||||
|
cvScalar = {0, 255, 255, 255};
|
||||||
|
float centerX_corner = step2ResultData.fLTX + (step2ResultData.fRBX - step2ResultData.fLTX)/2;
|
||||||
cv::rectangle(image,
|
cv::rectangle(image,
|
||||||
cv::Point(step2ResultData.fLTX, step2ResultData.fLTY),
|
cv::Point(step2ResultData.fLTX, step2ResultData.fLTY),
|
||||||
cv::Point(step2ResultData.fRBX, step2ResultData.fRBY),
|
cv::Point(step2ResultData.fRBX, step2ResultData.fRBY),
|
||||||
cvScalar, 2);
|
cvScalar, 2);
|
||||||
cv::line(image,
|
cv::line(image,
|
||||||
cv::Point(centerX, step2ResultData.fLTY-30), cv::Point(centerX, step2ResultData.fRBY+30),
|
cv::Point(centerX_corner, step2ResultData.fLTY-30), cv::Point(centerX_corner, step2ResultData.fRBY+30),
|
||||||
cvScalar, 1);
|
cvScalar, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
#include "SaveResultCSVEngine.h"
using namespace ai_matrix;
SaveResultCSVEngine::SaveResultCSVEngine() {}
SaveResultCSVEngine::~SaveResultCSVEngine() {}
APP_ERROR SaveResultCSVEngine::Init()
{
strPort0_ = engineName_ + "_" + std::to_string(engineId_) + "_0";
strPort1_ = engineName_ + "_" + std::to_string(engineId_) + "_1";
this->baseConfig_ = Config::getins()->getBaseConfig();
LogInfo << "SaveResultCSVEngine Init ok";
return APP_ERR_OK;
}
APP_ERROR SaveResultCSVEngine::DeInit()
{
LogInfo << "SaveResultCSVEngine DeInit ok";
return APP_ERR_OK;
}
/**
* 保存车厢的最优结果到CSV中
* inParam : std::shared_ptr<Train> pTrain :列车信息
* outParam:
* return : true/false
*/
bool SaveResultCSVEngine::saveTrainCsv(std::shared_ptr<DetectResultData> pDetectResultData)
{
//1. 创建保存路径 (固定路径/YYYY-MM-DD/hh-mm-ss/)
if (!FileUtil::getins()->createDirPath(this->baseConfig_.strResultPath))
{
LogError << "日期:" << pDetectResultData->strDetectDate << " csv save err";
return false;
}
//2. 保存csv
std::string strCsvName = pDetectResultData->strDetectDate + ".csv";
std::string strCsvPath = this->baseConfig_.strResultPath + "/" + strCsvName;
bool bIsExsit = false;
if (access(strCsvPath.c_str(), F_OK) != -1)
{
bIsExsit = true;
}
try
{
// 写文件
std::ofstream outFile;
outFile.open(strCsvPath, std::ios::app);
if (!bIsExsit)
{
outFile << "Time" << ','
<< "Container" << ','
<< "Image"
<< std::endl;
}
std::string strContainerNo;
+ strCsvName;
bool bIsExsit = false;
+ strCsvName;
bool bIsExsit = false;
if (access(strCsvPath.c_str(), F_OK) != -1)
}
}
bIsExsit = true;
<< strContainerNo << ','
<< ""
<< std::endl;
outFile.close();
}
catch (const std::exception &)
{
LogError << "strCsvPath:" << strCsvPath << " train savecsv fail!";
return false;
}
return true;
}
APP_ERROR SaveResultCSVEngine::Process()
{
int iRet = APP_ERR_OK;
while (!isStop_)
{
//pop端口0 车厢信息
std::shared_ptr<void> pVoidData0 = nullptr;
iRet = inputQueMap_[strPort0_]->pop(pVoidData0);
if (nullptr == pVoidData0)
{
usleep(1000);
continue;
}
std::shared_ptr<DetectResultData> pDetectResultData = std::static_pointer_cast<DetectResultData>(pVoidData0);
this->saveTrainCsv(pDetectResultData);
}
return APP_ERR_OK;
}
|
#include "SaveResultCSVEngine.h"
using namespace ai_matrix;
SaveResultCSVEngine::SaveResultCSVEngine() {}
SaveResultCSVEngine::~SaveResultCSVEngine() {}
APP_ERROR SaveResultCSVEngine::Init()
{
strPort0_ = engineName_ + "_" + std::to_string(engineId_) + "_0";
strPort1_ = engineName_ + "_" + std::to_string(engineId_) + "_1";
this->baseConfig_ = Config::getins()->getBaseConfig();
LogInfo << "SaveResultCSVEngine Init ok";
return APP_ERR_OK;
}
APP_ERROR SaveResultCSVEngine::DeInit()
{
LogInfo << "SaveResultCSVEngine DeInit ok";
return APP_ERR_OK;
}
/**
* 保存车厢的最优结果到CSV中
* inParam : std::shared_ptr<Train> pTrain :列车信息
* outParam:
* return : true/false
*/
bool SaveResultCSVEngine::saveTrainCsv(std::shared_ptr<DetectResultData> pDetectResultData)
{
//1. 创建保存路径 (固定路径/YYYY-MM-DD/hh-mm-ss/)
if (!FileUtil::getins()->createDirPath(this->baseConfig_.strResultPath))
{
LogError << "日期:" << pDetectResultData->strDetectDate << " csv save err";
return false;
}
//2. 保存csv
std::string strCsvName = pDetectResultData->strDetectDate + ".csv";
std::string strCsvPath = this->baseConfig_.strResultPath + "/"
bool bIsExsit = false;
+ strCsvName;
+ strCsvName;
LogInfo << strCsvPath;
bool bIsExsit = false;
if (access(strCsvPath.c_str(), F_OK) != -1)
{
bIsExsit = true;
}
try
{
// 写文件
std::ofstream outFile;
outFile.open(strCsvPath, std::ios::app);
if (!bIsExsit)
{
outFile << "Time" << ','
<< "Container" << ','
<< "Image"
<< std::endl;
}
std::string strContainerNo;
for (const auto & containerNo_it : pDetectResultData->vecContainerNO)
{
strContainerNo += "[";
strContainerNo += containerNo_it;
strContainerNo += "]";
}
std::string strImage;
for (const auto & image_it : pDetectResultData->vecImage)
{
strContainerNo += "[";
if (access(strCsvPath.c_str(), F_OK) != -1)
bool bIsExsit = false;
}
if (access(strCsvPath.c_str(), F_OK) != -1)
+ strCsvName;
if (access(strCsvPath.c_str(), F_OK) != -1)
+ StringUtil::getins()->replace_all_distinct(pDetectResultData->strDetectTime, ":", "-")
+ "/" + image_it;
std::string strResultImage = this->baseConfig_.strResultPath + "/"
if (access(strCsvPath.c_str(), F_OK) != -1)
if (access(strCsvPath.c_str(), F_OK) != -1)
bool bIsExsit = false;
if (access(strCsvPath.c_str(), F_OK) != -1)
if (access(strCsvPath.c_str(), F_OK) != -1)
FileUtil::getins()->copyFile(strDebugImage, strResultImage);
}
bIsExsit = true;
<< strContainerNo << ','
<< strImage << ','
<< std::endl;
outFile.close();
}
catch (const std::exception &)
{
LogError << "strCsvPath:" << strCsvPath << " train savecsv fail!";
return false;
}
return true;
}
APP_ERROR SaveResultCSVEngine::Process()
{
int iRet = APP_ERR_OK;
while (!isStop_)
{
//pop端口0 车厢信息
std::shared_ptr<void> pVoidData0 = nullptr;
iRet = inputQueMap_[strPort0_]->pop(pVoidData0);
if (nullptr == pVoidData0)
{
usleep(1000);
continue;
}
std::shared_ptr<DetectResultData> pDetectResultData = std::static_pointer_cast<DetectResultData>(pVoidData0);
this->saveTrainCsv(pDetectResultData);
}
return APP_ERR_OK;
}
|
||||||
|
|
@ -10,9 +10,11 @@ APP_ERROR SelectBestEngine::Init()
|
||||||
{
|
{
|
||||||
strPort0_ = engineName_ + "_" + std::to_string(engineId_) + "_0";
|
strPort0_ = engineName_ + "_" + std::to_string(engineId_) + "_0";
|
||||||
strPort1_ = engineName_ + "_" + std::to_string(engineId_) + "_1";
|
strPort1_ = engineName_ + "_" + std::to_string(engineId_) + "_1";
|
||||||
|
strPort2_ = engineName_ + "_" + std::to_string(engineId_) + "_2";
|
||||||
|
|
||||||
this->baseConfig_ = Config::getins()->getBaseConfig();
|
this->baseConfig_ = Config::getins()->getBaseConfig();
|
||||||
this->minioConfig_ = Config::getins()->getMinioConfig();
|
this->minioConfig_ = Config::getins()->getMinioConfig();
|
||||||
|
this->vecDataSourceConfig_ = Config::getins()->getAllDataSourceConfig();
|
||||||
|
|
||||||
this->initParam();
|
this->initParam();
|
||||||
|
|
||||||
|
|
@ -86,7 +88,7 @@ void SelectBestEngine::sendSaveCSV(DetectResultData &detectResultData)
|
||||||
{
|
{
|
||||||
std::shared_ptr<DetectResultData> pDetectResultData = std::make_shared<DetectResultData>();
|
std::shared_ptr<DetectResultData> pDetectResultData = std::make_shared<DetectResultData>();
|
||||||
*pDetectResultData = detectResultData;
|
*pDetectResultData = detectResultData;
|
||||||
outputQueMap_[strPort1_]->push(std::static_pointer_cast<void>(pDetectResultData));
|
outputQueMap_[strPort2_]->push(std::static_pointer_cast<void>(pDetectResultData));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -174,7 +176,7 @@ APP_ERROR SelectBestEngine::Process()
|
||||||
if (pVSelectBestData->bIsEnd)
|
if (pVSelectBestData->bIsEnd)
|
||||||
{
|
{
|
||||||
this->iEndCount_++;
|
this->iEndCount_++;
|
||||||
if (!(this->iEndCount_ % 3))
|
if (!(this->iEndCount_ % this->vecDataSourceConfig_.size()))
|
||||||
{
|
{
|
||||||
this->selectBest();
|
this->selectBest();
|
||||||
this->initParam();
|
this->initParam();
|
||||||
|
|
@ -182,7 +184,7 @@ APP_ERROR SelectBestEngine::Process()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->strImagePath_.empty())
|
if (this->strImagePath_.empty())
|
||||||
{
|
{
|
||||||
this->strDetectDate_ = pVSelectBestData->strDetectDate;
|
this->strDetectDate_ = pVSelectBestData->strDetectDate;
|
||||||
this->strDetectTime_ = pVSelectBestData->strDetectTime;
|
this->strDetectTime_ = pVSelectBestData->strDetectTime;
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,11 @@ private:
|
||||||
|
|
||||||
std::string strPort0_;
|
std::string strPort0_;
|
||||||
std::string strPort1_;
|
std::string strPort1_;
|
||||||
|
std::string strPort2_;
|
||||||
|
|
||||||
ai_matrix::BaseConfig baseConfig_;
|
ai_matrix::BaseConfig baseConfig_;
|
||||||
ai_matrix::MinioConfig minioConfig_;
|
ai_matrix::MinioConfig minioConfig_;
|
||||||
|
std::vector<ai_matrix::DataSourceConfig> vecDataSourceConfig_;
|
||||||
|
|
||||||
std::string strImagePath_;
|
std::string strImagePath_;
|
||||||
std::string strDetectDate_;
|
std::string strDetectDate_;
|
||||||
|
|
|
||||||
|
|
@ -258,6 +258,8 @@ APP_ERROR ContainerStep1InferenceEngine::Process()
|
||||||
std::shared_ptr<InferenceResultData> pInferenceResultData = std::make_shared<InferenceResultData>();
|
std::shared_ptr<InferenceResultData> pInferenceResultData = std::make_shared<InferenceResultData>();
|
||||||
pInferenceResultData->iDataSource = pVDetectInfo->iDataSource;
|
pInferenceResultData->iDataSource = pVDetectInfo->iDataSource;
|
||||||
pInferenceResultData->bIsEnd = pVDetectInfo->bIsEnd;
|
pInferenceResultData->bIsEnd = pVDetectInfo->bIsEnd;
|
||||||
|
pInferenceResultData->strDetectDate = pVDetectInfo->strDetectDate;
|
||||||
|
pInferenceResultData->strDetectTime = pVDetectInfo->strDetectTime;
|
||||||
if (pVDetectInfo->bIsEnd)
|
if (pVDetectInfo->bIsEnd)
|
||||||
{
|
{
|
||||||
outputQueMap_[strPort0_]->push(std::static_pointer_cast<void>(pInferenceResultData), true);
|
outputQueMap_[strPort0_]->push(std::static_pointer_cast<void>(pInferenceResultData), true);
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -143,7 +143,7 @@ void WSServerEngine::stop()
|
||||||
std::string WSServerEngine::onCMD(CMDConnData &conn, int argc, const char **argv)
|
std::string WSServerEngine::onCMD(CMDConnData &conn, int argc, const char **argv)
|
||||||
{
|
{
|
||||||
std::string msg = argv[0];
|
std::string msg = argv[0];
|
||||||
std::string strShow = "WebSocket收到 " + conn.ip + " 的信息:" + msg;
|
std::string strShow = "VCarContainer 收到 " + conn.ip + " 的信息:" + msg;
|
||||||
LogInfo << strShow;
|
LogInfo << strShow;
|
||||||
outputQueMap_[strPort0_]->push(std::static_pointer_cast<std::string>(std::make_shared<std::string>(msg)), true);
|
outputQueMap_[strPort0_]->push(std::static_pointer_cast<std::string>(std::make_shared<std::string>(msg)), true);
|
||||||
this->sendAllClient(strShow);
|
this->sendAllClient(strShow);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue