// // Created by Scheaven on 2020/4/26. // #include "h_interface.h" #include "utils/config.h" #include #include #include using namespace std; int m_staticStruct::times = 10; // 创建 YOLOTRACK_API void* create(const char *conf, int *max_chan) { CLog::Initialize("config/log4cplus.properties"); AriManager *handle = new AriManager(); ReadJsonFromFile(conf); return handle; } // 原查找结果接口 YOLOTRACK_API void* get_result(void *handle, const void *img, const int chan) { AriManager *h = (AriManager*)handle; TResult *t_result = (TResult*)malloc(sizeof(TResult)); init_TResult(t_result); // h->doInfer(*t_result); return t_result; } // 传递人脸结果并查找信息 YOLOTRACK_API void* get_result_face(void *handle, const void *img, const char* arg_json, const int arg_len, void *face_info, const int face_info_size) { Json::Reader reader; Json::Value root; AriManager *h = (AriManager*)handle; // TResult *t_result = new TResult(); TResult *t_result = (TResult*)malloc(sizeof(TResult)); init_TResult(t_result); h->doInfer("", img, t_result, face_info, face_info_size); return t_result; } YOLOTRACK_API void release_result(void *res) { if (!res) return; TResult *cres = (TResult*)res; // delete cres; for (int i = 0; i < cres->count; i++){ Target t = cres->targets[i]; if (t.feature) free(t.feature); if (t.attribute) free(t.attribute); } free(cres->targets); free(cres); } YOLOTRACK_API void release(void* handle) { AriManager *h = (AriManager*)handle; delete h; h = NULL; } // 读取Json文件 void ReadJsonFromFile(const char* filename) { Json::Reader reader; Json::Value root; int max_cam_num; int wander_time; float mv_velocity; float fall_rate; ifstream in(filename, ios::binary); if( !in.is_open() ) { cout << "Error opening json config file\n"; return; } if(reader.parse(in,root)) { int times = root["param"]["model_path"].asInt(); m_staticStruct::times = times; } in.close(); } void init_TResult(TResult *t) { t->count = 0; t->targets = nullptr; }