header.h 5.45 KB
#ifndef __AI_PLATFORM_HEADER__
#define __AI_PLATFORM_HEADER__

#ifdef _MSC_VER
#include <windows.h>
#else

#include <cstddef>

#endif


#include <map>
#include <vector>
#include <string>


#define HUMANREID_FEATURE_SIZE 384
#define HP_ATTRI_SIZE 16


using namespace std;


static std::string hair[] = { "长发", "短发", "其他" };
static std::string hair_color[] = { "黑", "白", "其他" };
static std::string eye_glass[] = { "未戴眼镜", "戴眼镜" };
static std::string mask[] = { "未戴口罩", "戴口罩" };
static std::string up_cloth[] = { "T恤/背心", "衬衫",  "毛衣", "外套", "连衣裙", "其他" };
static std::string up_cloth_color[] = { "黑", "白", "灰", "红", "蓝", "黄", "绿", "多色", "其他" };
static std::string clothing_text[] = { "纯色", "碎花", "条纹/格子", "其他" };
static std::string down_cloth[] = { "长裤", "短裤", "长裙", "短裙", "连衣裙", "其他" };
static std::string down_cloth_color[] = { "黑", "白", "灰", "红", "蓝", "黄", "绿", "多色", "其他" };
static std::string bag[] = { "无包", "有包" };
static std::string sex[] = { "男", "女", "不明" };
static std::string age[] = { "小孩", "成人", "不明" };
static std::string viewpoint[] = { "正面","背面", "侧面" };
static std::string umbrella[] = { "未打伞", "打伞" };
static std::string hold_baby[] = { "未抱小孩", "抱小孩" };
static std::string personstate[] = { "行走", "奔跑", "蹲坐", "推车", "其他" };

typedef struct hp_cls_info         //分类结果结构体
{
    int res_index;                      //分类结果
    float res_prob;                     //分类结构体
    hp_cls_info() : res_index(0), res_prob(0) {};
} hp_cls_info;


static string vechicle_pendant[] = {"车头", "车尾", "车窗", "司机", "人脸", "安全带", "遮阳板", "年检标", "挂件", "纸巾盒", "转经筒", "打电话", "天窗", "行李架", "吸烟", "车前脸", "车后脸", "后视镜", "临时车牌", "车标", "三角标志", "三角危险", "长方形危险"};
typedef struct VPDInfo
{
	int left_;
	int top_;
	int width_;
	int height_;

	int index;		                     //类型
	float confidence;	                 //置信度
}VPDInfo;

struct PlateNum
{
    char character[4];
    float maxprob;
    int index;
};

static string plate_type[] = {"单排蓝色 ", "单排黄色 ", "单排白色 ", "单排黑色", " 双排黄色 ", "双排白色 ", "新能源黄绿色 ", "新能源白绿色"};
static string plate_state[] = {"无车牌", " 正常车牌", " 遮挡车牌"};
struct VehiclePlateResult {
    int left_;
	int top_;
	int width_;
	int height_;
    float detect_score;

    PlateNum recg[8];
    float num_score;
    int type;	//车牌类型。只做车牌检测,车牌类型为:0-单层车牌,1-双层车牌;做车牌检测识别,0-单排蓝色 1-单排黄色 2-单排白色 3-单排黑色 4-双排黄色 5-双排白色 6-新能源黄绿色 7-新能源白绿色

    int state; //车牌状态:0-无车牌,1-车牌,2-遮挡车牌
    float state_score;//车牌状态置信度
};

// 0-black 1-blue 2-brown 3-green 4-grey 5-orange 6-pink 7-purple 8-red 9-silver 10-white 11-yellow
static string vehicle_color[] = {"black", "blue", "brown", "green", "grey", "orange", "pink", "purple", "red", "silver", "white", "yellow"};
typedef struct ObjectData {
    string task_id;              //该物体属于的任务ID号
    int task_frame_count;     //该物体当前出现的帧号
    int object_id;            //该物体的ID号
    int left;                 //该物体位置的左坐标
    int top;                  //该物体位置的上坐标
    int right;                //该物体位置的右坐标
    int bottom;               //该物体位置的下坐标
    int index;                //该物体所属类别的编号
    double confidence;        //该物体的置信度
    std::string str_ts_ms;   //时间

    string ori_pic_path;
    string obj_pic_path;

    hp_cls_info hp_cls[HP_ATTRI_SIZE]; 
    float hp_feature[HUMANREID_FEATURE_SIZE];

    int vehicle_color_index;
    float vehicle_color_prob;
    vector<VPDInfo> vec_vpd_cls;
    VehiclePlateResult vehicle_plate;
} ObjectData;



// TASK初始化参数
typedef struct task_param {
    string ipc_url;                      //rtsp流地址
    string task_id;                      //外部传入任务id
    int skip_frame{0};

    string result_folder_little;         //目标快照抠图保存地址
	string result_folder;                //目标快照大图保存地址
} task_param;


enum ai_log_level {
    AI_LOG_LEVEL_CLOSE = -1,  // 关闭日志
    AI_LOG_LEVEL_TRACE = 0,   // 跟踪变量
    AI_LOG_LEVEL_DEBUG = 1,       // 调试日志
    AI_LOG_LEVEL_INFO = 2,        // 普通日志信息 (如:无关紧要的信息输出)
    AI_LOG_LEVEL_WARNING = 3,     // 警告日志通知,模块一切正常(如:重要流程通知)
    AI_LOG_LEVEL_ERROR = 4,       // 重要日志,如结果和严重错误
};


typedef void(*ResultData_CALLBACK)(ObjectData obj);

//VPT初始化参数
typedef struct tsl_aiplatform_param {
    int gpuid;                                                     //指定显卡id
    string models_dir;              // 模型文件目录

    ai_log_level log_level;
    char *log_path;             //日志文件路径
    int log_days;               //日志保存周期
    double log_mem;                //每个日志最大大小

    ResultData_CALLBACK result_cbk;
} tsl_aiplatform_param;

#endif      // __AI_PLATFORM_HEADER__