generated from zhangwei/Matrixai
董家口项目更新
This commit is contained in:
parent
c31a201a78
commit
6382a980eb
|
@ -1,3 +1,8 @@
|
|||
# Train_Identify
|
||||
|
||||
支持单摄像头识别,支持集装箱号识别
|
||||
支持单摄像头识别,支持集装箱号识别
|
||||
|
||||
董家口项目代码
|
||||
接口采用自动装车同类项目接口,图片用nginx映射静态文件服务器,识别车厢和集装箱号,每节上传HTTP接口。
|
||||
|
||||
因为现场为装车时识别车号,故车厢行进速度慢,识别时间长。可能会大量占用内存。需要将小站提升性能和交换内存。
|
||||
|
|
|
@ -42,6 +42,7 @@ namespace ai_matrix
|
|||
this->baseConfig_.strResultPath = config_["base"]["result_path"].as<std::string>();
|
||||
this->baseConfig_.strDebugResultPath = config_["base"]["debug_result_path"].as<std::string>();
|
||||
this->baseConfig_.iResultSaveDays = config_["base"]["result_save_days"].as<int>();
|
||||
this->baseConfig_.strNginxUrl = config_["base"]["nginx_url"].as<std::string>();
|
||||
|
||||
// 日志参数
|
||||
this->logConfig_.strOutLevel = config_["log"]["out_level"].as<std::string>();
|
||||
|
@ -85,7 +86,7 @@ namespace ai_matrix
|
|||
this->httpServerConfig_.strUserName = config_["http_server"]["username"].as<std::string>();
|
||||
this->httpServerConfig_.strPassword = config_["http_server"]["password"].as<std::string>();
|
||||
|
||||
// http服务器参数
|
||||
// minio服务器参数
|
||||
this->minioConfig_.bIsUse = config_["minio"]["is_use"].as<bool>();
|
||||
this->minioConfig_.strUrl = config_["minio"]["url"].as<std::string>();
|
||||
this->minioConfig_.strAccessKey = config_["minio"]["accesskey"].as<std::string>();
|
||||
|
|
|
@ -44,6 +44,8 @@ namespace ai_matrix
|
|||
std::string strDebugResultPath;
|
||||
// 日志存储天数
|
||||
int iResultSaveDays;
|
||||
// nginx 地址
|
||||
std::string strNginxUrl;
|
||||
};
|
||||
|
||||
// 日志参数
|
||||
|
|
|
@ -25,7 +25,6 @@ namespace ai_matrix
|
|||
|
||||
while (queue_.size() >= max_size_ && isWait && !is_stoped_)
|
||||
{
|
||||
printf("myqueue full");
|
||||
cond_not_full_.wait(lk);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace MatrixAILog
|
|||
const int TIME_SIZE = 32;
|
||||
const int TIME_DIFF = 28800; // 8 hour
|
||||
const int BYTES6 = 6;
|
||||
const int FILE_SIZE = 52428800; // 50M
|
||||
const int FILE_SIZE = 52428800 * 2; // 50M
|
||||
uint32_t Log::logLevel = LOG_LEVEL_INFO;
|
||||
std::vector<std::string> Log::levelString{"[Debug]", "[Info ]", "[Warn ]", "[Error]", "[Fatal]"};
|
||||
std::mutex Log::mutex;
|
||||
|
|
|
@ -167,7 +167,7 @@ typedef struct {
|
|||
// 车厢编号
|
||||
uint16_t iCarOrder = 0;
|
||||
// 车厢种类
|
||||
uint16_t iCategory = 0;
|
||||
uint16_t iCategory = -1;
|
||||
// 车型
|
||||
std::string strTType;
|
||||
// 车厢编号
|
||||
|
|
|
@ -14,6 +14,8 @@ base:
|
|||
debug_result_path: "./debug_result"
|
||||
# 结果存储天数
|
||||
result_save_days: 10
|
||||
# nginx 地址
|
||||
nginx_url: "http://10.10.203.10:9010"
|
||||
|
||||
# 日志参数
|
||||
log:
|
||||
|
|
|
@ -477,7 +477,7 @@ void TrainCharacterConversionEngine::transNum(Step2ResultData &step2ResultData,
|
|||
|
||||
//校验车型是否符合验证
|
||||
typeInfo.IsChkFlag = this->authTransNum(step2ResultData.iClassId, strTemp);
|
||||
LogDebug << "--->>> 符合正则吗?" << typeInfo.IsChkFlag << " --- " << strTemp;
|
||||
// LogDebug << "--->>> 符合正则吗?" << typeInfo.IsChkFlag << " --- " << strTemp;
|
||||
|
||||
typeInfo.strTmpResult = strTemp;
|
||||
step2ResultData.vecTransInfo.emplace_back(typeInfo);
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
#include "ToHttpSrvEngine.h"
ToHttpSrvEngine::ToHttpSrvEngine() {}
ToHttpSrvEngine::~ToHttpSrvEngine() {}
APP_ERROR ToHttpSrvEngine::Init()
{
strPort0_ = engineName_ + "_" + std::to_string(engineId_) + "_0";
this->httpServerConfig_ = Config::getins()->getHttpServerConfig();
LogInfo << "ToHttpSrvEngine Init ok";
return APP_ERR_OK;
}
APP_ERROR ToHttpSrvEngine::DeInit()
{
LogInfo << "ToHttpSrvEngine DeInit ok";
return APP_ERR_OK;
}
APP_ERROR ToHttpSrvEngine::Process()
{
int iRet = APP_ERR_OK;
while (!isStop_)
{
std::shared_ptr<void> pVoidData0 = nullptr;
inputQueMap_[strPort0_]->pop(pVoidData0);
if (nullptr == pVoidData0)
{
usleep(1000); //1ms
continue;
}
if (!this->httpServerConfig_.bIsUse)
{
usleep(1000); //1ms
continue;
}
std::shared_ptr<VTrainInfo> pTrain = std::static_pointer_cast<VTrainInfo>(pVoidData0);
int iCategory = 0;
if (pTrain->iCategory == 3)
{
iCategory = 0;
}
else if(pTrain->iCategory == 2)
{
iCategory = 1;
}
else if (pTrain->iCategory == 6)
{
iCategory = 2;
}
else if (pTrain->iCategory == 0)
{
iCategory = 3;
}
//组装post信息
Json::Value jvRequest;
}
return APP_ERR_OK;
jvRequest["cameraNumber"] = 0;// 摄像头编号
jvRequest["comeTime"] = pTrain->strTrainDate + " " + pTrain->strTrainTime;// 来车时间
jvRequest["direction"] = pTrain->iTDirection;// 来车方向
jvRequest["carriageOrder"] = pTrain->iCarOrder;// 车节号
jvRequest["carriageCategory"] = iCategory;// 车厢类别:0敞车,1:漏洞矿车,2:平车,3:车头
jvRequest["carriageType"] = pTrain->strTType;// 车型
jvRequest["carriageNumber"] = pTrain->strTNum;// 车厢号
jvRequest["carriageTareweight"] = pTrain->strTTareWeight;// 皮重
jvRequest["carriageLoad"] = pTrain->strTLoadWeight;// 载重
jvRequest["carriageChange"] = pTrain->strTChangeLen;// 换长
jvRequest["numImageName"] = pTrain->strTNum_image; // 车号图片
jvRequest["proImageName"] = pTrain->strTPro_image; // 属性图片
for (const auto & it : pTrain->vecContainer)
{
jvRequest["containerNumber"].append(it.strContainerNo);// 集装箱
jvRequest["containerImageName"].append(it.strImg); // 集装箱图片
}
jvRequest["isTheLast"] = pTrain->bIsTheLast ? 1 : 0;// 是否最后一节: 0:否,1:是
jvRequest["identifyTime"] = pTrain->strEndTime;//车厢切分的时间
if (!ToWeb::getins()->upWeb(jvRequest, 1))
{
}
}
return APP_ERR_OK;
}
|
||||
#include "ToHttpSrvEngine.h"
ToHttpSrvEngine::ToHttpSrvEngine() {}
ToHttpSrvEngine::~ToHttpSrvEngine() {}
APP_ERROR ToHttpSrvEngine::Init()
{
strPort0_ = engineName_ + "_" + std::to_string(engineId_) + "_0";
this->httpServerConfig_ = Config::getins()->getHttpServerConfig();
this->baseConfig_ = Config::getins()->getBaseConfig();
APP_ERROR ToHttpSrvEngine::DeInit()
LogInfo << "ToHttpSrvEngine Init ok";
return APP_ERR_OK;
}
APP_ERROR ToHttpSrvEngine::DeInit()
{
LogInfo << "ToHttpSrvEngine DeInit ok";
return APP_ERR_OK;
}
APP_ERROR ToHttpSrvEngine::Process()
{
int iRet = APP_ERR_OK;
while (!isStop_)
{
std::shared_ptr<void> pVoidData0 = nullptr;
inputQueMap_[strPort0_]->pop(pVoidData0);
if (nullptr == pVoidData0)
{
usleep(1000); //1ms
continue;
}
if (!this->httpServerConfig_.bIsUse)
{
usleep(1000); //1ms
continue;
}
std::shared_ptr<VTrainInfo> pTrain = std::static_pointer_cast<VTrainInfo>(pVoidData0);
int iCategory = 0;
if (pTrain->iCategory == 3)
{
iCategory = 0;
}
else if(pTrain->iCategory == 2)
{
iCategory = 1;
}
else if (pTrain->iCategory == 6)
{
iCategory = 2;
}
else if (pTrain->iCategory == 0)
{
iCategory = 3;
}
std::string strDes = this->baseConfig_.strNginxUrl + "/" + pTrain->strTrainDate + "/" + StringUtil::getins()->replace_all_distinct(pTrain->strTrainTime, ":", "-") + "/";
//组装post信息
Json::Value jvRequest;
APP_ERROR ToHttpSrvEngine::DeInit()
}
jvSubObj["poundNo"] = pTrain->strTrackName; // 股道号
jvRequest["trainParams"] = jvSubObj; //
jvRequest["trackName"] = pTrain->strTrackName; // 股道号/名称
jvRequest["cameraNumber"] = 0;// 摄像头编号
jvRequest["comeTime"] = pTrain->strTrainDate + " " + pTrain->strTrainTime;// 来车时间
jvRequest["direction"] = pTrain->iTDirection;// 来车方向
jvRequest["carriageOrder"] = pTrain->iCarOrder;// 车节号
jvRequest["carriageCategory"] = iCategory;// 车厢类别:0敞车,1:漏洞矿车,2:平车,3:车头
jvRequest["carriageType"] = pTrain->strTType;// 车型
jvRequest["carriageNumber"] = pTrain->strTNum;// 车厢号
jvRequest["carriageTareweight"] = pTrain->strTTareWeight;// 皮重
jvRequest["carriageLoad"] = pTrain->strTLoadWeight;// 载重
jvRequest["carriageChange"] = pTrain->strTChangeLen;// 换长
jvRequest["numImageName"] = strDes + pTrain->strTNum_image; // 车号图片
jvRequest["proImageName"] = strDes + pTrain->strTPro_image; // 属性图片
int i = 1;
for (const auto & it : pTrain->vecContainer)
{
jvRequest["containerNo" + std::to_string(i)] = it.strContainerNo;// 集装箱
jvRequest["containerImageName" + std::to_string(i)] = strDes + it.strImg; // 集装箱图片
++i;
}
jvRequest["isTheLast"] = pTrain->bIsTheLast ? 1 : 0;// 是否最后一节: 0:否,1:是
jvRequest["identifyTime"] = pTrain->strEndTime;//车厢切分的时间
if (!ToWeb::getins()->upWeb(jvRequest, 1))
{
}
}
return APP_ERR_OK;
}
|
|
@ -32,6 +32,7 @@ private:
|
|||
std::string strPort0_;
|
||||
|
||||
ai_matrix::HttpServerConfig httpServerConfig_;
|
||||
ai_matrix::BaseConfig baseConfig_;
|
||||
|
||||
int iNoDataCnt_ = 0;
|
||||
|
||||
|
|
|
@ -122,6 +122,12 @@ APP_ERROR SaveDebugImageEngine::Process()
|
|||
|
||||
cv::Mat image = cv::imread(strImagePath);
|
||||
|
||||
if (image.empty())
|
||||
{
|
||||
LogWarn << "未能读取到需要标注的图像:" << strImagePath;
|
||||
continue;
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
std::vector<std::string> vecTitle;
|
||||
vecTitle.emplace_back("FrameID:" + to_string(pVStep2OutputData->iFrameId));
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -203,12 +203,12 @@ void TrainStep1InferenceEngine::filterInvalidInfo(std::vector<stDetection> &vecI
|
|||
it->bbox[2] <= this->dataSourceConfig_.vecIdentifyAreas[2] &&
|
||||
it->bbox[3] <= this->dataSourceConfig_.vecIdentifyAreas[3]))
|
||||
{
|
||||
LogDebug << "frameId:" << pVTrainStep1Data->iFrameId
|
||||
<< " 类别:" << it->class_id << " 超出识别区域-识别区域:("
|
||||
<< this->dataSourceConfig_.vecIdentifyAreas[0] << ","
|
||||
<< this->dataSourceConfig_.vecIdentifyAreas[1] << "),("
|
||||
<< this->dataSourceConfig_.vecIdentifyAreas[2] << ","
|
||||
<< this->dataSourceConfig_.vecIdentifyAreas[2] << ")";
|
||||
// LogDebug << "frameId:" << pVTrainStep1Data->iFrameId
|
||||
// << " 类别:" << it->class_id << " 超出识别区域-识别区域:("
|
||||
// << this->dataSourceConfig_.vecIdentifyAreas[0] << ","
|
||||
// << this->dataSourceConfig_.vecIdentifyAreas[1] << "),("
|
||||
// << this->dataSourceConfig_.vecIdentifyAreas[2] << ","
|
||||
// << this->dataSourceConfig_.vecIdentifyAreas[2] << ")";
|
||||
it = vecInferenceResult.erase(it);
|
||||
continue;
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ void TrainStep1InferenceEngine::filterInvalidInfo(std::vector<stDetection> &vecI
|
|||
// }
|
||||
|
||||
//主摄像头1帧如果只识别2个大框,如果非平车的车号和属性场景,则必有间隔框
|
||||
if (vecInferenceResult.size() >= 2)
|
||||
if (vecInferenceResult.size() > 2)
|
||||
{
|
||||
int iHeight0 = vecInferenceResult[0].bbox[1] / 2 + vecInferenceResult[0].bbox[3] / 2;
|
||||
int iHeight1 = vecInferenceResult[1].bbox[1] / 2 + vecInferenceResult[1].bbox[3] / 2;
|
||||
|
|
|
@ -168,7 +168,6 @@ APP_ERROR TrainStep2DataReadEngine::Process()
|
|||
pVStep2InputData->bIsEnd = !jvFrameInfo.isMember("isEnd") || jvFrameInfo["isEnd"].asBool();
|
||||
|
||||
outputQueMap_[strPort0_]->push(std::static_pointer_cast<void>(pVStep2InputData), true);
|
||||
// outputQueMap_[strPort1_]->push(std::static_pointer_cast<void>(pVStep2InputData), true);
|
||||
}
|
||||
}
|
||||
return APP_ERR_OK;
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -132,7 +132,7 @@ void Inference::doInferenceV3(IExecutionContext& context, cudaStream_t& stream,
|
|||
//执行推理4
|
||||
void Inference::doInferenceV4(IExecutionContext& context, cudaStream_t& stream, void **buffers, unsigned int outputIndex, float* output, int outputSize, int batchSize)
|
||||
{
|
||||
context.enqueueV2(buffers, stream, nullptr);
|
||||
context.enqueueV2(buffers, stream, nullptr);
|
||||
CUDA_CHECK(cudaMemcpyAsync(output, buffers[outputIndex], batchSize * outputSize * sizeof(float), cudaMemcpyDeviceToHost, stream));
|
||||
cudaStreamSynchronize(stream);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue