//
|
// Created by Scheaven on 2020/4/26.
|
//
|
#include "h_interface.h"
|
#include <iostream>
|
#include <fstream>
|
#include <json/json.h>
|
using namespace std;
|
|
string m_staticStruct::model_path = "path";
|
int m_staticStruct::type = 1;
|
|
// 创建
|
API void* create(const char *conf, int *max_chan)
|
{
|
CLog::Initialize("../config/log4cplus.properties");
|
ReadJsonFromFile(conf);
|
AriManager *handle = new AriManager();
|
return handle;
|
}
|
|
// 原查找结果接口
|
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->single_SDK(chan, img, *t_result);
|
return t_result;
|
}
|
|
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);
|
}
|
|
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;
|
string tmp = filename;
|
|
ifstream in(filename, ios::binary);
|
if( !in.is_open() )
|
{
|
cout << "Error opening json config file\n";
|
return;
|
}
|
if(reader.parse(in,root))
|
{
|
std::string model_path = root["param"]["model_path"].asString();
|
int type = root["param"]["type"].asInt();
|
m_staticStruct::model_path = model_path;
|
m_staticStruct::type = type;
|
}
|
in.close();
|
}
|
|
void init_TResult(TResult *t)
|
{
|
t->count = 0;
|
t->targets = nullptr;
|
}
|
|