f171c20a
Hu Chunming
添加moter_rainshed ...
|
1
2
3
4
5
6
7
8
9
10
11
12
|
#include "MotorRainshedAnalysis.h"
#include "motor_rainshed_cls.h"
MotorRainshedAnalysis::MotorRainshedAnalysis(/* args */)
{
}
MotorRainshedAnalysis::~MotorRainshedAnalysis()
{
release();
}
|
581a68a4
Hu Chunming
修正parse_road无返回值导...
|
13
|
int MotorRainshedAnalysis::init(int devId, std::string sdk_root){
|
f171c20a
Hu Chunming
添加moter_rainshed ...
|
14
15
|
ACL_CALL(aclrtCreateContext(&ctx, devId), SY_SUCCESS, SY_FAILED);
|
581a68a4
Hu Chunming
修正parse_road无返回值导...
|
16
17
|
std::string model_path = sdk_root + "/models/rainshed/motor_rainshed_231123_310p.om";
|
f171c20a
Hu Chunming
添加moter_rainshed ...
|
18
|
mrc_param param;
|
581a68a4
Hu Chunming
修正parse_road无返回值导...
|
19
|
param.modelNames = (char*)model_path.data();
|
f171c20a
Hu Chunming
添加moter_rainshed ...
|
20
21
22
|
param.thresld = 0.0;
param.devId = devId;
|
e3062370
Hu Chunming
优化日志
|
23
|
LOG_INFO("mrc_init start");
|
f171c20a
Hu Chunming
添加moter_rainshed ...
|
24
25
26
27
28
|
int ret = mrc_init(&m_handle, param);
if (ret != 0) {
return -1;
}
|
e3062370
Hu Chunming
优化日志
|
29
|
LOG_INFO("mrc_init success");
|
f171c20a
Hu Chunming
添加moter_rainshed ...
|
30
31
32
33
|
return SY_SUCCESS;
}
|
6f9dffde
Hu Chunming
返回prob
|
34
|
vector<MotorRainshedResult> MotorRainshedAnalysis::detect(vector<sy_img> vec_img){
|
f171c20a
Hu Chunming
添加moter_rainshed ...
|
35
|
|
6f9dffde
Hu Chunming
返回prob
|
36
|
vector<MotorRainshedResult> vec_result;
|
f171c20a
Hu Chunming
添加moter_rainshed ...
|
37
38
|
const int batchsize = vec_img.size();
|
667e7a90
Hu Chunming
雨棚和打电话初步代码
|
39
40
41
|
vector<mrc_result> results;
results.resize(batchsize);
|
f171c20a
Hu Chunming
添加moter_rainshed ...
|
42
43
44
45
46
|
int ret = SY_FAILED;
do
{
|
667e7a90
Hu Chunming
雨棚和打电话初步代码
|
47
48
49
50
51
52
53
|
ret = aclrtSetCurrentContext(ctx);
if (SY_SUCCESS != ret) {
printf("aclrtSetCurrentContext failed!");
break;
}
ret = mrc_batch(m_handle, vec_img.data(), batchsize, results.data());
|
f171c20a
Hu Chunming
添加moter_rainshed ...
|
54
55
56
57
58
|
if (SY_SUCCESS != ret) {
printf("mrc_batch failed!");
break;
}
|
667e7a90
Hu Chunming
雨棚和打电话初步代码
|
59
|
for(int batchIdx = 0;batchIdx<batchsize;batchIdx++){
|
6f9dffde
Hu Chunming
返回prob
|
60
61
62
63
64
65
|
// printf("index:%d,confidence:%f\n",results[batchIdx].index,results[batchIdx].score);
MotorRainshedResult one_result;
one_result.rainshed = results[batchIdx].index;
one_result.prob = results[batchIdx].score;
vec_result.push_back(one_result);
|
f171c20a
Hu Chunming
添加moter_rainshed ...
|
66
67
68
|
}
} while (0);
|
667e7a90
Hu Chunming
雨棚和打电话初步代码
|
69
|
return vec_result;
|
f171c20a
Hu Chunming
添加moter_rainshed ...
|
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
}
int MotorRainshedAnalysis::release() {
ACL_CALL(aclrtSetCurrentContext(ctx), SY_SUCCESS, SY_FAILED);
if (m_handle) {
mrc_release(&m_handle);
}
if(ctx){
aclrtDestroyContext(ctx);
ctx = nullptr;
}
return SY_SUCCESS;
}
|