4a273a4a
Hu Chunming
添加hcp和hp
|
1
2
|
#include "HumanAnalysis.h"
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
3
4
|
static std::string body_colors[] = { "黑", "白", "灰", "红", "蓝", "黄", "绿", "多色", "其他" };
|
4a273a4a
Hu Chunming
添加hcp和hp
|
5
6
7
8
9
10
11
12
13
|
HumanAnalysis::HumanAnalysis(/* args */)
{
}
HumanAnalysis::~HumanAnalysis()
{
release();
}
|
581a68a4
Hu Chunming
修正parse_road无返回值导...
|
14
|
int HumanAnalysis::init(int devId, std::string sdk_root){
|
4a273a4a
Hu Chunming
添加hcp和hp
|
15
16
17
|
ACL_CALL(aclrtCreateContext(&ctx, devId), SY_SUCCESS, SY_FAILED);
ACL_CALL(aclrtSetCurrentContext(ctx), SY_SUCCESS, SY_FAILED);
|
581a68a4
Hu Chunming
修正parse_road无返回值导...
|
18
19
|
std::string model_path = sdk_root + "/models/hp/hp220908_310p.om";
|
4a273a4a
Hu Chunming
添加hcp和hp
|
20
|
hp_param param;
|
581a68a4
Hu Chunming
修正parse_road无返回值导...
|
21
|
param.modelNames = (char*)model_path.data();
|
4a273a4a
Hu Chunming
添加hcp和hp
|
22
23
|
param.devId = devId;
|
e3062370
Hu Chunming
优化日志
|
24
|
LOG_INFO("hp_init start");
|
4a273a4a
Hu Chunming
添加hcp和hp
|
25
26
27
28
29
|
int ret = hp_init(&m_handle, param);
if (ret != 0) {
return -1;
}
|
e3062370
Hu Chunming
优化日志
|
30
|
LOG_INFO("hp_init success");
|
4a273a4a
Hu Chunming
添加hcp和hp
|
31
32
33
34
|
return SY_SUCCESS;
}
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
35
|
vector<BodyColorInfo> HumanAnalysis::detect(vector<sy_img> vec_img){
|
4a273a4a
Hu Chunming
添加hcp和hp
|
36
37
38
39
40
|
const int batchsize = vec_img.size();
hp_analysis_res * results = new hp_analysis_res[batchsize];
int ret = SY_FAILED;
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
41
|
vector<BodyColorInfo> vec_body_color;
|
4a273a4a
Hu Chunming
添加hcp和hp
|
42
43
44
|
do
{
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
45
46
47
48
49
50
|
ret = aclrtSetCurrentContext(ctx);
if (SY_SUCCESS != ret) {
printf("aclrtSetCurrentContext failed!");
break;
}
|
4a273a4a
Hu Chunming
添加hcp和hp
|
51
52
|
ret = hp_batch(m_handle, vec_img.data(), batchsize, results);
if (SY_SUCCESS != ret) {
|
f171c20a
Hu Chunming
添加moter_rainshed ...
|
53
|
printf("hp_batch failed!");
|
4a273a4a
Hu Chunming
添加hcp和hp
|
54
55
56
|
break;
}
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
57
58
59
60
61
62
63
|
for(int batchIdx = 0;batchIdx<batchsize;batchIdx++) {
BodyColorInfo info;
info.upper_body_color = results[batchIdx].res_objs[5].res_index;
info.lower_body_color = results[batchIdx].res_objs[8].res_index;
printf("upper color:%s, lower color:%s\n",body_colors[info.upper_body_color], body_colors[info.lower_body_color]);
vec_body_color.push_back(info);
|
4a273a4a
Hu Chunming
添加hcp和hp
|
64
65
66
67
68
69
70
|
}
} while (0);
if (results) {
delete [] results;
}
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
71
|
return vec_body_color;
|
4a273a4a
Hu Chunming
添加hcp和hp
|
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
}
int HumanAnalysis::release() {
ACL_CALL(aclrtSetCurrentContext(ctx), SY_SUCCESS, SY_FAILED);
if (m_handle) {
hp_release(&m_handle);
}
if(ctx){
aclrtDestroyContext(ctx);
ctx = nullptr;
}
return 0;
}
|