HumanFea.cpp
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "HumanFea.h"
#include "sy_common.h"
#include <iostream>
#include "../../FFNvDecoder/logger.hpp"
HumanFea::HumanFea(/* args */)
{
}
HumanFea::~HumanFea()
{
LOG_INFO("~HumanFea");
}
int HumanFea::init(int gpuid, char* auth_license)
{
human_fea_param fea_param;
fea_param.mode = DEVICE_GPU;
fea_param.gpuid = gpuid;
fea_param.thres = 0.6;
fea_param.engine = ENGINE_TENSORRT;
fea_param.max_batch = 20;
fea_param.serialize_file = "./serialize_file/HF";
fea_param.auth_license = auth_license;
int ret = human_fea_init(&handle, fea_param);
if (ret != SUCCESS)
{
LOG_ERROR("human_fea_init failed:{}", ret);
return FAILED;
}
LOG_INFO("human_fea_init success! gpu_id: {}", gpuid);
return SUCCESS;
}
int HumanFea::process(sy_img * batch_img, int batch_size, human_fea_result*& result)
{
for (int i = 0; i < batch_size; i++) {
if (batch_img[i].data_ == NULL) {
LOG_ERROR("data null!");
return FAILED;
}
}
return human_fea_batch(handle, batch_img, batch_size, result);
}
int HumanFea::release()
{
if(handle) {
human_fea_release(&handle);
handle = nullptr;
}
LOG_INFO("human_fea_release");
return SUCCESS;
}