#include "detector.h" #include "ItsVehicleTypeRec.h" #include #include #include "csdk_struct.h" namespace csdk_wrap { static void* pITSInstance; int init_vehicle_its_detector(int sceneMode, int modelMode, char *keyPath, char *modelPath) { // 初始化授权 int iInitFlag = ITS_ThreadInit(keyPath); if(iInitFlag != OK) { return iInitFlag; } // 初始化配置 ::ITS_Rec_Param itsParam; itsParam.iSceneMode = sceneMode; itsParam.iModelMode = modelMode; // 初始化SDK pITSInstance = ITS_VehicleRecInit(modelPath, iInitFlag, itsParam); return pITSInstance == NULL ? 1 : 0; } cVehicleITSResult* vehicle_its_detect(int *plateIDCount, const cIMAGE *img, const cRECT *rect) { if (!img) { return NULL; } cVehicleITSResult *ppos = NULL; ::V_Image* pImage = new(V_Image); pImage->pImageData = (BYTE*)(img->data); pImage->iImageHeight = img->height; pImage->iImageWidth = img->width; pImage->eType = E_BGR; ::ITS_Vehicle_Result result; memset(&result, 0, sizeof(ITS_Vehicle_Result)); // 设置识别区域 ::S_Rect rcDetect = {rect->left, rect->top, rect->right, rect->bottom}; int iVehicleNum = ITS_VehicleTypeRec(pITSInstance, pImage, &rcDetect, &result); if (iVehicleNum > 0){ ppos = (cVehicleITSResult*)malloc(iVehicleNum * sizeof(cVehicleITSResult)); *plateIDCount = iVehicleNum; memcpy(ppos, result.tempResult, sizeof(ITS_Vehicle_Result_Single) * iVehicleNum); } return ppos; } void uninit_vehicle_its_detector() { ITS_VehicleRecRelease(pITSInstance); } } // csdk_wrap