4a273a4a
Hu Chunming
添加hcp和hp
|
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
|
#include "HumanCarAnalysis.h"
HumanCarAnalysis::HumanCarAnalysis(/* args */)
{
}
HumanCarAnalysis::~HumanCarAnalysis()
{
release();
}
int HumanCarAnalysis::init(int devId){
ACL_CALL(aclrtCreateContext(&ctx, devId), SY_SUCCESS, SY_FAILED);
ACL_CALL(aclrtSetCurrentContext(ctx), SY_SUCCESS, SY_FAILED);
hcp_param param;
param.modelNames = "./models/hcp/hcp211008_310p.om";
param.devId = devId;
cout << "hcp_init start " << endl;
int ret = hcp_init(&m_handle, param);
if (ret != 0) {
return -1;
}
cout << "hcp_init success " << endl;
return SY_SUCCESS;
}
|
81e8a405
Hu Chunming
初步完成SDK
|
31
|
std::vector<HumanCarResult> HumanCarAnalysis::detect(vector<sy_img> vec_img){
|
4a273a4a
Hu Chunming
添加hcp和hp
|
32
|
|
81e8a405
Hu Chunming
初步完成SDK
|
33
|
std::vector<HumanCarResult> vec_result;
|
4a273a4a
Hu Chunming
添加hcp和hp
|
34
35
36
37
38
39
40
41
|
const int batchsize = vec_img.size();
hcp_analysis_result * results = new hcp_analysis_result[batchsize];
int ret = SY_FAILED;
do
{
|
81e8a405
Hu Chunming
初步完成SDK
|
42
43
44
45
46
47
|
ret = aclrtSetCurrentContext(ctx);
if (SY_SUCCESS != ret) {
printf("aclrtSetCurrentContext failed!");
break;
}
|
4a273a4a
Hu Chunming
添加hcp和hp
|
48
49
|
ret = hcp_batch(m_handle, vec_img.data(), batchsize, results);
if (SY_SUCCESS != ret) {
|
f171c20a
Hu Chunming
添加moter_rainshed ...
|
50
|
printf("hcp_batch failed!");
|
4a273a4a
Hu Chunming
添加hcp和hp
|
51
52
53
54
55
|
break;
}
for(int batchIdx = 0;batchIdx<batchsize;batchIdx++){
for (int i = 0; i < HCP_ATTRI_INDEX_SIZE; i++) {
|
81e8a405
Hu Chunming
初步完成SDK
|
56
57
58
59
|
HumanCarResult one_result;
one_result.type = results[batchIdx].res_objs[i].res_index;
one_result.prob = results[batchIdx].res_objs[i].res_prob;
vec_result.push_back(one_result);
|
4a273a4a
Hu Chunming
添加hcp和hp
|
60
61
62
63
64
65
66
67
|
}
}
} while (0);
if (results) {
delete [] results;
}
|
81e8a405
Hu Chunming
初步完成SDK
|
68
|
return vec_result;
|
4a273a4a
Hu Chunming
添加hcp和hp
|
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
}
int HumanCarAnalysis::release() {
ACL_CALL(aclrtSetCurrentContext(ctx), SY_SUCCESS, SY_FAILED);
if (m_handle) {
hcp_release(&m_handle);
}
if(ctx){
aclrtDestroyContext(ctx);
ctx = nullptr;
}
return SY_SUCCESS;
}
|