/******************************************************************************************* * Version: CD_V0.0.0 * CopyRight: 中科院自动化研究所模式识别实验室图像视频组 * UpdateDate: 20180920 * Content: 人车物监测跟踪 ********************************************************************************************/ #ifndef CD_H_ #define CD_H_ #ifdef _MSC_VER #ifdef CD_EXPORTS #define CD_API __declspec(dllexport) #else #define CD_API __declspec(dllimport) #endif #else #define CD_API __attribute__ ((visibility ("default"))) #endif #include #include "header.h" //回调函数定义头文件 #include using namespace std; typedef struct CD_ObjInfo //检测物体结果结构体 { int left; //检测结果左坐标 int top; //检测结果上坐标 int right; //检测结果右坐标 int bottom; //检测结果下坐标 int center_x; //检测结果中心位置X坐标 int center_y; //检测结果中心位置Y坐标 int index; //行人/车辆类别,支持9类 long id; //目标唯一ID,同一ID为同一目标 double confidence; //置信度 }CD_ObjInfo; typedef struct CD_Result //检测结果结构体 { int objCount; //检测到物体总数 CD_ObjInfo *obj; //各个物体的结果信息 }CD_Result; //规定9个检测种类的最小检测框 //行人 自行车 摩托车 三轮车 小型车 大车 卡车 拖拉机 中巴 const int DETECTTYPE = 80; const int EDGES = 4; typedef struct MRECT //检测框 { int width; //检测框宽度 int height; //检测框高度 MRECT(){ width = 0; height = 0; } //构造函数 MRECT(int w, int h){ width = w; height = h; } //构造函数 }MRECT; typedef struct SNAPSHOT_PARAMETER { bool selectFromMinbox; //选取快照时,是否需要剔除掉小于Minbox的快照 bool selectFromMindistance; //选取快照时,是否需要剔除掉距边框的距离小于minDistance的快照 MRECT minBoxsize[DETECTTYPE]; //自定义的minBoxsize大小 int minDistance[EDGES]; //自定义的minDistance大小 SNAPSHOT_PARAMETER(){ selectFromMinbox = true; selectFromMindistance = true; } //构造函数 }SNAPSHOT_PARAMETER; typedef struct CD_PARAM //CD设置参数结构体 { int gpuid; //显卡ID号 int maxResultCount; //最大检测前景个数 SNAPSHOT_PARAMETER *SnaoshotParameter; //快照保存参数设置 CD_PARAM(){ SnaoshotParameter = NULL; } }CD_PARAM; /************************************************************************* * FUNCTION: CD_Init * PURPOSE: 初始化 * PARAM: [in] handle - 句柄 [in] vparam - 参数 [in] resDir - 快照保存路径 [in] VideoObjSnapshotCallBack - 结果返回回调函数 * RETURN: 成功(0)或错误代码(< 0) * NOTES: *************************************************************************/ CD_API int CD_Init(void *&handle, CD_PARAM vparam, char* resDir, VIDEO_OBJECT_SNAPSHOT_CALLBACK VideoObjSnapshotCallBack = NULL); /************************************************************************* * FUNCTION: CD_ResetTracker * PURPOSE: 重置跟踪器 * PARAM: [in] handle - 操作句柄 * RETURN: NULL * NOTES: *************************************************************************/ CD_API void CD_ResetTracker(void * handle); /************************************************************************* * FUNCTION: CD_Process * PURPOSE: 猫狗检测跟踪 * PARAM: [in] handle - 处理句柄 [in] rgb - 图片数据(3通道BGR数据 cv::Mat格式) [in] width - 图片宽度 [in] height - 图片高度 [in] channels - 图片通道数 [in] frameCount - 视频当前的帧数 [in] result - 目标检测结果 [in] showTrack - 是否显示轨迹 * RETURN: 成功(0)或错误代码(< 0) * NOTES: *************************************************************************/ CD_API int CD_Process(void * handle, unsigned char *bgr, int width, int height, int channels, int frameCount, CD_Result *result, bool showTrack); /************************************************************************* * FUNCTION: CD_Release * PURPOSE: 资源释放 * PARAM: [in] handle - 处理句柄 * RETURN: NULL * NOTES: *************************************************************************/ CD_API void CD_Release(void *&handle); #endif