496 lines
12 KiB
C++
496 lines
12 KiB
C++
//
|
||
// Created by nvidia on 24-9-12.
|
||
//
|
||
|
||
#ifndef TRAIN_COMMONSTRUCT_H
|
||
#define TRAIN_COMMONSTRUCT_H
|
||
|
||
//模型参数
|
||
typedef struct _YoloV5ModelParam{
|
||
unsigned int uiClassNum;
|
||
unsigned int uiDetSize;
|
||
float fScoreThreshold;
|
||
float fNmsThreshold;
|
||
}YoloV5ModelParam;
|
||
|
||
typedef struct _YoloV5ClearityModelParam{
|
||
unsigned int uiClassNum;
|
||
unsigned int uiClearNum;
|
||
unsigned int uiDetSize;
|
||
float fScoreThreshold;
|
||
float fNmsThreshold;
|
||
}YoloV5ClearityModelParam;
|
||
|
||
typedef struct _ModelCommonInfo{
|
||
unsigned int uiModelWidth;
|
||
unsigned int uiModelHeight;
|
||
unsigned int uiInputSize;
|
||
unsigned int uiOutputSize;
|
||
unsigned int uiChannel;
|
||
unsigned int uiBatchSize;
|
||
std::string strInputBlobName;
|
||
std::string strOutputBlobName;
|
||
}ModelCommonInfo;
|
||
|
||
typedef struct _YoloV5ModelInfo{
|
||
YoloV5ModelParam yolov5ModelParam;
|
||
ModelCommonInfo modelCommonInfo;
|
||
}YoloV5ModelInfo;
|
||
|
||
typedef struct _YoloV5ClearityModelInfo{
|
||
YoloV5ClearityModelParam yolov5ClearityModelParam;
|
||
ModelCommonInfo modelCommonInfo;
|
||
}YoloV5ClearityModelInfo;
|
||
|
||
struct ModelConfig
|
||
{
|
||
std::string strAnchorPath; //锚框文件路径
|
||
std::string strClassPath; //类别名称集合
|
||
std::string strOmPath; //om文件路径
|
||
int iModelWidth; //模型输入宽度
|
||
int iModelHeight; //模型输入高度
|
||
float fScoreThreshold; //得分阈值
|
||
float fNMSTreshold; //nms阈值
|
||
int iClassNum; //类别个数
|
||
int iLineNum; //字段代号
|
||
};
|
||
|
||
typedef struct
|
||
{
|
||
float fLTX = 0; //左上X坐标
|
||
float fLTY = 0; //左上y坐标
|
||
float fRBX = 0; //右下y坐标
|
||
float fRBY = 0; //右下y坐标
|
||
}Location;
|
||
|
||
|
||
// 定义日期结构体
|
||
typedef struct Date
|
||
{
|
||
int year;
|
||
int month;
|
||
int day;
|
||
} Date;
|
||
|
||
//数据源基本信息
|
||
typedef struct
|
||
{
|
||
uint32_t iWidth = 0;
|
||
uint32_t iHeight = 0;
|
||
int iRate = 0; //帧率
|
||
} DataSourceInfo;
|
||
|
||
// 原始帧信息
|
||
typedef struct {
|
||
// 帧画面
|
||
std::shared_ptr<void> pData = nullptr;
|
||
// Size of memory, bytes
|
||
uint32_t iSize = 0;
|
||
// 帧数据时间戳
|
||
uint64_t i64TimeStamp = 0;
|
||
} SourceFrameData;
|
||
|
||
//识别处理数据
|
||
typedef struct
|
||
{
|
||
// 数据来源标识
|
||
int iDataSource = 0;
|
||
// 数据源信息
|
||
DataSourceInfo dataSourceInfo;
|
||
// 原始帧数据
|
||
SourceFrameData sourceFrameData;
|
||
// 解码参数
|
||
AVCodecParameters *pCodecParameters_ = nullptr;
|
||
// 列车结束标识
|
||
bool bIsTrainEnd = false;
|
||
} ProcessData;
|
||
|
||
typedef struct
|
||
{
|
||
// 帧数据时间戳
|
||
uint64_t i64TimeStamp = 0;
|
||
// Size of memory, bytes
|
||
uint32_t iSize = 0;
|
||
// Width of image
|
||
uint32_t iWidth = 0;
|
||
// Height of image
|
||
uint32_t iHeight = 0;
|
||
// 帧率
|
||
int iRate = 0;
|
||
// 原始数据
|
||
std::shared_ptr<void> pData = nullptr;
|
||
AVCodecID avCodecID;
|
||
|
||
} VFrameData;
|
||
|
||
// 识别区域坐标
|
||
typedef struct {
|
||
// 字段代号(仅第二步使用)
|
||
int iLine = -1;
|
||
// 大小框的类别
|
||
int iClassId = -1;
|
||
// 框的名称
|
||
std::string strClassName;
|
||
// 分数
|
||
float fScore = 0;
|
||
// 清晰度
|
||
float fClear = 0;
|
||
// 左上X坐标 Left Top x
|
||
float fLTX = 0;
|
||
// 左上y坐标 Left Top y
|
||
float fLTY = 0;
|
||
// 右下y坐标 Right Bottom x
|
||
float fRBX = 0;
|
||
// 右下y坐标 Right Bottom y
|
||
float fRBY = 0;
|
||
} VCoordinate;
|
||
|
||
// 集装箱信息
|
||
typedef struct {
|
||
// 集装箱号
|
||
std::string strContainerNo;
|
||
// 集装箱最优图
|
||
std::string strImg;
|
||
// 集装箱编号坐标
|
||
VCoordinate coordinate;
|
||
} VContainer;
|
||
|
||
typedef struct {
|
||
// 数据来源标识
|
||
int iDataSource = 0;
|
||
// 过车日期(格式:YYYY-MM-DD)
|
||
std::string strTrainDate;
|
||
// 过车时间(格式:HH:MM:SS)
|
||
std::string strTrainTime;
|
||
// 存储结果的名称(暂定格式:HH-MM-SS)
|
||
std::string strTrainName;
|
||
// 股道编号
|
||
std::string strTrackName = "0";
|
||
// 列车来车方向 (0:未知 1:左 2:右)
|
||
uint16_t iTDirection = 0;
|
||
// 车厢编号
|
||
uint16_t iCarOrder = 0;
|
||
// 车厢种类
|
||
int iCategory = -1;
|
||
// 车型
|
||
std::string strTType;
|
||
// 车厢编号
|
||
std::string strTNum;
|
||
// 车厢载重
|
||
std::string strTLoadWeight;
|
||
// 车厢自重(皮重)
|
||
std::string strTTareWeight;
|
||
// 车厢容积
|
||
std::string strTVolume;
|
||
// 车厢换长
|
||
std::string strTChangeLen;
|
||
// 车厢编号图片
|
||
std::string strTNum_image;
|
||
// 车厢属性图片
|
||
std::string strTPro_image;
|
||
// 车厢开始帧号
|
||
uint32_t iStartFrame = 0;
|
||
// 车厢结束帧号
|
||
uint32_t iEndFrame = 0;
|
||
// 车厢开始时间
|
||
std::string strStartTime;
|
||
// 车厢结束时间
|
||
std::string strEndTime;
|
||
// 是否最后一节车厢
|
||
bool bIsTheLast = false;
|
||
// 车厢编号大框坐标
|
||
VCoordinate numCoordinate;
|
||
// 车厢属性大框坐标
|
||
VCoordinate proCoordinate;
|
||
// 集装箱信息
|
||
std::vector<VContainer> vecContainer;
|
||
} VTrainInfo;
|
||
|
||
typedef struct {
|
||
// 模型地址
|
||
std::string strModelPath;
|
||
// 图片地址
|
||
std::string strImagePath;
|
||
// 模型类型[0:检测 detect 1:分类 classify]
|
||
uint8_t iModel = 0;
|
||
// 模型版本["v5","v8"]
|
||
std::string strModelVersion;
|
||
// 类别模板地址
|
||
std::string strClassModelPath;
|
||
} VYoloTestInfo;
|
||
|
||
//动态检测结果
|
||
typedef struct
|
||
{
|
||
// 数据来源标识
|
||
int iDataSource = 0;
|
||
// 文件存储目录
|
||
std::string strFilePath;
|
||
// 文件名字
|
||
std::string strFileName;
|
||
// 帧号
|
||
uint32_t iFrameId = 0;
|
||
// 帧数据时间戳
|
||
uint64_t i64TimeStamp = 0;
|
||
// 列车结束标识
|
||
bool bIsEnd = false;
|
||
// 过车日期(格式:YYYY-MM-DD)
|
||
std::string strTrainDate;
|
||
// 过车时间(格式:HH:MM:SS)
|
||
std::string strTrainTime;
|
||
// 存储结果的名称(暂定格式:HH-MM-SS)
|
||
std::string strTrainName;
|
||
// 火车位置阶段(车头-车头车身之间-车身-车尾)
|
||
int iTrainStage = MONITOR_MODEL_INIT_STATE;
|
||
} VMoveInfo;
|
||
|
||
// 存图数据
|
||
typedef struct
|
||
{
|
||
// 数据来源标识
|
||
int iDataSource = 0;
|
||
// 车厢位置状态
|
||
std::string strTrainStage;
|
||
// 行车方向
|
||
std::string strDirection;
|
||
// 车厢运动状态
|
||
std::string strTrainStatus;
|
||
// 帧图像数据
|
||
VFrameData frameData;
|
||
// 文件存储目录
|
||
std::string strFilePath;
|
||
// 文件名字
|
||
std::string strFileName;
|
||
// 图片需要标记的框坐标
|
||
std::vector<VCoordinate> vecCoordinate;
|
||
// 火车结束标志
|
||
bool bIsEnd;
|
||
} SaveImgData;
|
||
|
||
typedef struct
|
||
{
|
||
// 数据来源标识
|
||
int iDataSource = 0;
|
||
// 火车结束标志
|
||
bool bIsEnd;
|
||
// 图片所在目录
|
||
std::string strImagePath;
|
||
// 图片名字
|
||
std::string strImageName;
|
||
} VToStep1Data;
|
||
|
||
typedef struct
|
||
{
|
||
// 数据来源标识
|
||
int iDataSource = 0;
|
||
// 帧号
|
||
uint32_t iFrameId = 0;
|
||
// 过车日期(格式:YYYY-MM-DD)
|
||
std::string strTrainDate;
|
||
// 过车时间(格式:HH:MM:SS)
|
||
std::string strTrainTime;
|
||
// 存储结果的名称(暂定格式:HH-MM-SS)
|
||
std::string strTrainName;
|
||
// 火车位置阶段(车头-车头车身之间-车身-车尾)
|
||
int iTrainStage = MONITOR_MODEL_INIT_STATE;
|
||
// 图片
|
||
cv::Mat cvImage;
|
||
// // 原始数据
|
||
// std::shared_ptr<void> pData = nullptr;
|
||
// // Size of memory, bytes
|
||
// uint32_t iSize = 0;
|
||
// 火车结束标志
|
||
bool bIsEnd;
|
||
} VTrainStep1Data;
|
||
|
||
// 模型具体结果
|
||
typedef struct
|
||
{
|
||
// 目标类别 (0:车号; 1:属性; 2:车头; 3:定检期; 4:集装箱; 5:公共间隔; 6:车厢大间隔)
|
||
int iTargetType = -1;
|
||
// 字段代号(仅第二步使用)
|
||
int iLine = -1;
|
||
// 大小框的类别
|
||
int iClassId = -1;
|
||
// 分数
|
||
float fScore = 0;
|
||
// 左上X坐标
|
||
float fLTX = 0;
|
||
// 左上y坐标
|
||
float fLTY = 0;
|
||
// 右下y坐标
|
||
float fRBX = 0;
|
||
// 右下y坐标
|
||
float fRBY = 0;
|
||
// 清晰度
|
||
float fClear = 0;
|
||
// 所属车厢(第二步用)
|
||
int iTrainIndex = 0;
|
||
} SingleData;
|
||
|
||
//后处理数据
|
||
typedef struct
|
||
{
|
||
// 数据来源标识
|
||
int iDataSource = 0;
|
||
// 帧号
|
||
uint32_t iFrameId = 0;
|
||
// 过车日期(格式:YYYY-MM-DD)
|
||
std::string strTrainDate;
|
||
// 过车时间(格式:HH:MM:SS)
|
||
std::string strTrainTime;
|
||
// 存储结果的名称(暂定格式:HH-MM-SS)
|
||
std::string strTrainName;
|
||
// 火车结束标志
|
||
bool bIsEnd;
|
||
// 当前大框所属车厢
|
||
int iCarXH = 0;
|
||
// 火车车辆状态(0-无车; 1-有车行驶; 2-有车停止)
|
||
int iTrainStatus = 0;
|
||
// 行车方向
|
||
int iDirection = 0;
|
||
// 模型具体结果
|
||
std::vector<SingleData> vecSingleData;
|
||
} InferenceResultData;
|
||
|
||
// 倒车数据集
|
||
typedef struct
|
||
{
|
||
// 后处理数据
|
||
std::shared_ptr<InferenceResultData> pInferenceResultData;
|
||
// 当前帧识别的全部内容
|
||
std::string strAllClassType;
|
||
}TrainBackInfo;
|
||
|
||
// 用于方向计算
|
||
typedef struct
|
||
{
|
||
// 帧号
|
||
uint32_t iFrameId = 0;
|
||
// 大框id (给第二步用 1-属性 23456-编号)
|
||
int iBigClassId = -1;
|
||
// 第一步识别目标中心点X坐标
|
||
float fCenterX;
|
||
// 第一步识别目标X坐标宽度
|
||
float fTargetWidth;
|
||
} CalculateInfo;
|
||
|
||
//车厢划分信息结构体
|
||
typedef struct
|
||
{
|
||
// 数据来源标识
|
||
int iDataSource = 0;
|
||
std::string strTrainDate;
|
||
std::string strTrainTime;
|
||
// 存储结果的名称(暂定格式:HH-MM-SS)
|
||
std::string strTrainName;
|
||
int iTrainIndex = 0;
|
||
// 当节车厢出现的开始帧帧号
|
||
int iStartframe;
|
||
// 当节车厢出现的结束帧帧号
|
||
int iEndframe;
|
||
// 间隔框的帧号
|
||
int iSpaceFrame;
|
||
// 大框中线
|
||
int iCenterX;
|
||
// 是否最后一节
|
||
bool bIsEnd = false;
|
||
// 切分方式
|
||
bool bSpaceDivide = true;
|
||
|
||
void reset() {
|
||
iDataSource = 0;
|
||
strTrainDate = "";
|
||
strTrainTime = "";
|
||
iTrainIndex = 0;
|
||
iStartframe = 0;
|
||
iEndframe = 0;
|
||
iSpaceFrame = 0;
|
||
iCenterX = 0;
|
||
bIsEnd = false;
|
||
bSpaceDivide = true;
|
||
};
|
||
}PartionInfo;
|
||
|
||
//转换具体内容
|
||
typedef struct
|
||
{
|
||
// 字段代号
|
||
int iLine = -1;
|
||
// 是否符合基本数据校验
|
||
bool IsChkFlag = false;
|
||
// 转换后的每个字符内容
|
||
std::vector<std::string> vecValue;
|
||
// 每个字符对应的分数
|
||
std::vector<float> vecScore;
|
||
// 本框的识别结果
|
||
std::string strTmpResult;
|
||
} TransInfo;
|
||
|
||
typedef struct
|
||
{
|
||
// 数据来源标识
|
||
int iDataSource = 0;
|
||
std::string strTrainDate;
|
||
std::string strTrainTime;
|
||
// 存储结果的名称(暂定格式:HH-MM-SS)
|
||
std::string strTrainName;
|
||
// 帧序号
|
||
int iFrameId;
|
||
// 图片
|
||
cv::Mat cvImage;
|
||
// 大框集合
|
||
std::vector<SingleData> vecSingleData;
|
||
// 是否最后一节
|
||
bool bIsEnd = false;
|
||
} VStep2InputData;
|
||
|
||
typedef struct
|
||
{
|
||
// 所属车厢(第二步用)
|
||
int iTrainIndex = 0;
|
||
// 大小框的类别
|
||
int iClassId = -1;
|
||
// 分数
|
||
float fScore = 0;
|
||
// 左上X坐标
|
||
float fLTX = 0;
|
||
// 左上y坐标
|
||
float fLTY = 0;
|
||
// 右下y坐标
|
||
float fRBX = 0;
|
||
// 右下y坐标
|
||
float fRBY = 0;
|
||
// 子框得分总和
|
||
float fSubScoreSum = 0;
|
||
// 子框信息集合
|
||
std::vector<SingleData> vecSingleData;
|
||
// 子框的转换结果
|
||
std::vector<TransInfo > vecTransInfo;
|
||
} Step2ResultData;
|
||
|
||
typedef struct
|
||
{
|
||
// 数据来源标识
|
||
int iDataSource = 0;
|
||
std::string strTrainDate;
|
||
std::string strTrainTime;
|
||
// 存储结果的名称(暂定格式:HH-MM-SS)
|
||
std::string strTrainName;
|
||
// 帧序号
|
||
int iFrameId;
|
||
// 大框以及对应小框的集合
|
||
std::vector<Step2ResultData> vecStep2ResultData;
|
||
// 是否最后一节
|
||
bool bIsEnd = false;
|
||
} VStep2OutputData;
|
||
|
||
typedef struct
|
||
{
|
||
int iCarOrder;
|
||
bool bIsTheLast = false;
|
||
} MergeSecondaryData;
|
||
|
||
|
||
#endif //TRAIN_COMMONSTRUCT_H
|