增加侧边右向行车摄像头使用箱角进行切分
This commit is contained in:
parent
a582dfb23b
commit
bdaaf2eca4
|
|
@ -56,6 +56,7 @@ namespace ai_matrix
|
|||
dataSourceConfig.iSkipInterval = it["skip_interval"].as<int>();
|
||||
dataSourceConfig.vecIdentifyAreas = it["identify_areas"].as<std::vector<int>>();
|
||||
dataSourceConfig.strDivideModel = it["divide_mode"].as<std::string>();
|
||||
dataSourceConfig.strRunDirection = it["run_direction"].as<std::string>();
|
||||
this->vecDataSourceConfig_.emplace_back(dataSourceConfig);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ namespace ai_matrix
|
|||
std::vector<int> vecIdentifyAreas;
|
||||
// 切箱方式
|
||||
std::string strDivideModel;
|
||||
// 汽车行进方向
|
||||
std::string strRunDirection;
|
||||
};
|
||||
|
||||
// 识别参数
|
||||
|
|
|
|||
|
|
@ -137,8 +137,8 @@ using namespace nvcaffeparser1;
|
|||
#define STEP1_CLASS_NUM 19 //step1 7分类
|
||||
#define STEP1_CLEAR_NUM 21 //step1 21个清晰度
|
||||
|
||||
#define STEP1_INPUT_H 960 //step1 输入图像高
|
||||
#define STEP1_INPUT_W 960 //step1 输入图像宽
|
||||
#define STEP1_INPUT_H 640 //step1 输入图像高
|
||||
#define STEP1_INPUT_W 640 //step1 输入图像宽
|
||||
#define STEP1_BATCH_SIZE 1
|
||||
#define STEP1_OUTPUT_HISTOGRAM_N 5 //不能超过139167
|
||||
|
||||
|
|
|
|||
|
|
@ -330,6 +330,8 @@ typedef struct
|
|||
Step2ResultData step2ResultData;
|
||||
// 箱角大框
|
||||
std::vector<Step2ResultData> vecCornerResultData;
|
||||
// 图片
|
||||
cv::Mat cvImage;
|
||||
// 是否最后一节
|
||||
bool bIsEnd = false;
|
||||
} VStep2OutputData;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ data_source:
|
|||
identify_areas: [120, 0, 1800, 1080]
|
||||
# 切箱方式
|
||||
divide_mode: "corner" #[corner, pixel]
|
||||
# 汽车行进方向
|
||||
run_direction: "down" #[up, down, left, right]
|
||||
- # 侧部摄像头
|
||||
url: "./videos/buertai2.mp4"
|
||||
# 跳帧数
|
||||
|
|
@ -40,6 +42,8 @@ data_source:
|
|||
identify_areas: [ 120, 0, 1800, 1080 ]
|
||||
# 切箱方式
|
||||
divide_mode: "pixel" #[corner, pixel]
|
||||
# 汽车行进方向
|
||||
run_direction: "right" #[up, down, left, right]
|
||||
- # 侧边摄像头
|
||||
url: "./videos/buertai2.mp4"
|
||||
# 跳帧数
|
||||
|
|
@ -48,6 +52,8 @@ data_source:
|
|||
identify_areas: [ 120, 0, 1800, 1080 ]
|
||||
# 切箱方式
|
||||
divide_mode: "pixel" #[corner, pixel]
|
||||
# 汽车行进方向
|
||||
run_direction: "left" #[up, down, left, right]
|
||||
|
||||
# 识别参数
|
||||
identify:
|
||||
|
|
|
|||
|
|
@ -245,12 +245,12 @@ APP_ERROR ControlEngine::Process()
|
|||
outputQueMap_[strPort3_]->push(std::static_pointer_cast<void>(pVDetectInfo), true);
|
||||
|
||||
// 存图
|
||||
std::shared_ptr<SaveImgData> pSaveImgData = std::make_shared<SaveImgData>();
|
||||
pSaveImgData->strFilePath = strFilePath;
|
||||
pSaveImgData->strFileName = std::to_string(this->mapDetectNO_[pProcessData->iDataSource]) + "_" + std::to_string(pProcessData->iDataSource) + ".jpg";
|
||||
pSaveImgData->cvImage = image;
|
||||
pSaveImgData->bIsEnd = pProcessData->bIsEnd;
|
||||
outputQueMap_[strPort4_]->push(std::static_pointer_cast<void>(pSaveImgData), true);
|
||||
// std::shared_ptr<SaveImgData> pSaveImgData = std::make_shared<SaveImgData>();
|
||||
// pSaveImgData->strFilePath = strFilePath;
|
||||
// pSaveImgData->strFileName = std::to_string(this->mapDetectNO_[pProcessData->iDataSource]) + "_" + std::to_string(pProcessData->iDataSource) + ".jpg";
|
||||
// pSaveImgData->cvImage = image;
|
||||
// pSaveImgData->bIsEnd = pProcessData->bIsEnd;
|
||||
// outputQueMap_[strPort4_]->push(std::static_pointer_cast<void>(pSaveImgData), true);
|
||||
|
||||
this->mapDetectNO_[pProcessData->iDataSource]++;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -25,7 +25,7 @@ private:
|
|||
void divideInfo(std::shared_ptr<VStep2OutputData> pVStep2OutputData);
|
||||
void divideByPixelInfo(std::shared_ptr<VStep2OutputData> pVStep2OutputData);
|
||||
void divideByCornerInfo(std::shared_ptr<VStep2OutputData> pVStep2OutputData);
|
||||
void setectBestByCorner();
|
||||
bool setectBestByCorner();
|
||||
void sendBestData(const VSelectBestData& selectBestData);
|
||||
void makeResult(const std::shared_ptr<VStep2OutputData>& pVStep2OutputData,
|
||||
VSelectBestData & selectBestData) const;
|
||||
|
|
|
|||
|
|
@ -42,16 +42,8 @@ APP_ERROR SaveDebugImageEngine::Process()
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!this->baseConfig_.bTestModel)
|
||||
{
|
||||
usleep(1000);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<VStep2OutputData> pVStep2OutputData = std::static_pointer_cast<VStep2OutputData>(pvoidd);
|
||||
|
||||
|
||||
std::string strDataDir = this->baseConfig_.strDebugResultPath + "/"
|
||||
+ pVStep2OutputData->strDetectDate + "/"
|
||||
+ StringUtil::getins()->replace_all_distinct(pVStep2OutputData->strDetectTime, ":", "-")
|
||||
|
|
@ -72,15 +64,17 @@ APP_ERROR SaveDebugImageEngine::Process()
|
|||
continue;
|
||||
}
|
||||
|
||||
cv::Mat image = cv::imread(strImagePath);
|
||||
// cv::Mat image = cv::imread(strImagePath);
|
||||
|
||||
if (image.empty())
|
||||
if (pVStep2OutputData->cvImage.empty())
|
||||
{
|
||||
LogWarn << "图像未找到:" << strImagePath;
|
||||
LogWarn << " 帧:" << pVStep2OutputData->iFrameId << " 数据源:" << pVStep2OutputData->iDataSource << " debug图像未找到";
|
||||
continue;
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
if (this->baseConfig_.bTestModel)
|
||||
{
|
||||
// std::stringstream ss;
|
||||
std::vector<std::string> vecTitle;
|
||||
vecTitle.emplace_back("FrameID:" + to_string(pVStep2OutputData->iFrameId));
|
||||
vecTitle.emplace_back("TimeStamp:" + jvFrameInfo["timeStamp"].asString());
|
||||
|
|
@ -92,7 +86,7 @@ APP_ERROR SaveDebugImageEngine::Process()
|
|||
cv::Size text_size = cv::getTextSize(i, cv::FONT_HERSHEY_SIMPLEX, 1, 2, 0);
|
||||
cv::Point baseline_loc(text_org);
|
||||
baseline_loc.y += base_line + text_size.height;
|
||||
cv::putText(image, i, baseline_loc, cv::FONT_HERSHEY_SIMPLEX, 1, cv::Scalar(0, 255, 0, 255), 2);
|
||||
cv::putText(pVStep2OutputData->cvImage, i, baseline_loc, cv::FONT_HERSHEY_SIMPLEX, 1, cv::Scalar(0, 255, 0, 255), 2);
|
||||
// 手动调整x位置,为下一个单词留出空间
|
||||
text_org.x += text_size.width + 10;
|
||||
text_org.x = text_org.x > IMAGE_WIDTH ? 15 : text_org.x;
|
||||
|
|
@ -104,17 +98,17 @@ APP_ERROR SaveDebugImageEngine::Process()
|
|||
float centerX = pVStep2OutputData->step2ResultData.fLTX + (pVStep2OutputData->step2ResultData.fRBX - pVStep2OutputData->step2ResultData.fLTX)/2;
|
||||
float centerY = pVStep2OutputData->step2ResultData.fLTY + (pVStep2OutputData->step2ResultData.fRBY - pVStep2OutputData->step2ResultData.fLTY)/2;
|
||||
// auto start = std::chrono::system_clock::now(); //计时开始
|
||||
cv::rectangle(image,
|
||||
cv::rectangle(pVStep2OutputData->cvImage,
|
||||
cv::Point(pVStep2OutputData->step2ResultData.fLTX, pVStep2OutputData->step2ResultData.fLTY),
|
||||
cv::Point(pVStep2OutputData->step2ResultData.fRBX, pVStep2OutputData->step2ResultData.fRBY),
|
||||
cvScalar, 2);
|
||||
cv::line(image,
|
||||
cv::line(pVStep2OutputData->cvImage,
|
||||
cv::Point(centerX, pVStep2OutputData->step2ResultData.fLTY-30), cv::Point(centerX, pVStep2OutputData->step2ResultData.fRBY+30),
|
||||
cvScalar, 1);
|
||||
|
||||
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(pVStep2OutputData->cvImage,
|
||||
pVStep2OutputData->step2ResultData.transInfo.strTmpResult,
|
||||
linePoint,
|
||||
cv::FONT_HERSHEY_SIMPLEX, 1, cv::Scalar(0, 255, 0, 180), 2);
|
||||
|
|
@ -124,18 +118,20 @@ APP_ERROR SaveDebugImageEngine::Process()
|
|||
{
|
||||
cvScalar = {0, 255, 255, 255};
|
||||
float centerX_corner = step2ResultData.fLTX + (step2ResultData.fRBX - step2ResultData.fLTX)/2;
|
||||
cv::rectangle(image,
|
||||
cv::rectangle(pVStep2OutputData->cvImage,
|
||||
cv::Point(step2ResultData.fLTX, step2ResultData.fLTY),
|
||||
cv::Point(step2ResultData.fRBX, step2ResultData.fRBY),
|
||||
cvScalar, 2);
|
||||
cv::line(image,
|
||||
cv::line(pVStep2OutputData->cvImage,
|
||||
cv::Point(centerX_corner, step2ResultData.fLTY-30), cv::Point(centerX_corner, step2ResultData.fRBY+30),
|
||||
cvScalar, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// auto end = std::chrono::system_clock::now();
|
||||
// LogDebug << "图片存储用时: " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms " << strImagePath;
|
||||
|
||||
if (!cv::imwrite(strImagePath, image, this->vecCompressionParams_))
|
||||
if (!cv::imwrite(strImagePath, pVStep2OutputData->cvImage, this->vecCompressionParams_))
|
||||
{
|
||||
LogError << "图片存储失败:" << strImagePath;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ private:
|
|||
ai_matrix::BaseConfig baseConfig_;
|
||||
|
||||
std::string strPort0_;
|
||||
int iPicQuality_ = 80;
|
||||
int iPicQuality_ = 100;
|
||||
std::vector<int> vecCompressionParams_;
|
||||
|
||||
};
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue