20396d5c
Hu Chunming
添加车头车尾算法
|
1
2
3
|
#include "PicAnalysis.h"
#include "./utils/logger.hpp"
|
52516fb9
Hu Chunming
添加授权代码;
|
4
5
|
#define AUTHORIZATION
#define productSN "C7C1FF4EDEF1452F8BBEC8B36EAECEC0" //linux 农村一体机图片版 产品序列号
|
20396d5c
Hu Chunming
添加车头车尾算法
|
6
7
8
9
10
11
12
13
|
PicAnalysis::PicAnalysis(/* args */)
{
aclInit(nullptr);
}
PicAnalysis::~PicAnalysis()
{
|
ba6761f1
Hu Chunming
补充日志
|
14
|
LOG_INFO("~PicAnalysis()");
|
4a273a4a
Hu Chunming
添加hcp和hp
|
15
|
release();
|
20396d5c
Hu Chunming
添加车头车尾算法
|
16
17
18
|
aclFinalize();
}
|
e8beee4d
Hu Chunming
实现jni接口
|
19
20
|
int PicAnalysis::init(VillageParam param) {
|
ba6761f1
Hu Chunming
补充日志
|
21
22
23
|
string log_path = param.log_path + "/main.log";
set_default_logger(LogLevel(param.log_level), "PicAnalysis", log_path.c_str(), param.log_mem, param.log_days);
|
e3062370
Hu Chunming
优化日志
|
24
25
26
27
28
29
|
// 输入参数
LOG_INFO("dev_id: {}", param.dev_id);
LOG_INFO("sdk_path: {}", param.sdk_path);
LOG_INFO("log_level: {}", param.log_level);
LOG_INFO("log_days: {}", param.log_days);
|
ba6761f1
Hu Chunming
补充日志
|
30
|
LOG_INFO("log_path: {}", log_path);
|
e3062370
Hu Chunming
优化日志
|
31
|
|
d708ccb3
Hu Chunming
增加日志
|
32
33
34
|
LOG_INFO("编译时间:{} {}", __DATE__, __TIME__);
LOG_INFO("execute dir:{}", helpers::PathUtils::GetCmdDir());
|
e8beee4d
Hu Chunming
实现jni接口
|
35
|
int dev_id = param.dev_id;
|
20396d5c
Hu Chunming
添加车头车尾算法
|
36
|
|
4a273a4a
Hu Chunming
添加hcp和hp
|
37
38
|
int ret = SY_FAILED;
|
52516fb9
Hu Chunming
添加授权代码;
|
39
40
41
42
43
44
45
46
47
48
49
50
|
#ifndef AUTHORIZATION
if (!CheckTime()) { //时间限制
LOG_ERROR("CheckTime failed.");
return -106 ;
}
#else
if (!CheckLabel(dev_id)) { //机器授权
LOG_ERROR("CheckLabel failed.");
return -106 ;
}
#endif
|
d708ccb3
Hu Chunming
增加日志
|
51
52
53
54
|
VehicleAnalysisParam vehicle_analysis_param;
vehicle_analysis_param.devId = dev_id;
vehicle_analysis_param.sdk_root = param.sdk_path;
vehicle_analysis_param.max_batch_size = 16;
|
d708ccb3
Hu Chunming
增加日志
|
55
|
ret = m_vehicle_analysis.init(vehicle_analysis_param);
|
9b88b335
Hu Chunming
恢复代码
|
56
57
58
59
|
if(0 != ret){
return -1;
}
|
10667f7c
Hu Chunming
违法载人判断的优化
|
60
61
62
63
64
65
66
67
|
head_tail_param ht_param;
ht_param.devId = dev_id;
ht_param.max_batch = 16;
ht_param.sdk_root = param.sdk_path;
ret = m_head_tail_algorithm.init(ht_param);
if(0 != ret){
return -1;
}
|
9b88b335
Hu Chunming
恢复代码
|
68
|
|
581a68a4
Hu Chunming
修正parse_road无返回值导...
|
69
|
ret = m_clothes_algorithm.init(dev_id, param.sdk_path);
|
9b88b335
Hu Chunming
恢复代码
|
70
71
72
73
|
if(0 != ret){
return -1;
}
|
581a68a4
Hu Chunming
修正parse_road无返回值导...
|
74
|
ret = m_human_algorithm.init(dev_id, param.sdk_path);
|
9b88b335
Hu Chunming
恢复代码
|
75
76
77
78
|
if(0 != ret){
return -1;
}
|
581a68a4
Hu Chunming
修正parse_road无返回值导...
|
79
|
ret = m_human_car_algorithm.init(dev_id, param.sdk_path);
|
9b88b335
Hu Chunming
恢复代码
|
80
81
82
83
|
if(0 != ret){
return -1;
}
|
581a68a4
Hu Chunming
修正parse_road无返回值导...
|
84
|
ret = m_motor_rainshed_algorithm.init(dev_id, param.sdk_path);
|
9b88b335
Hu Chunming
恢复代码
|
85
86
87
88
|
if(0 != ret){
return -1;
}
|
581a68a4
Hu Chunming
修正parse_road无返回值导...
|
89
|
ret = m_motor_phone_algorithm.init(dev_id, param.sdk_path);
|
9b88b335
Hu Chunming
恢复代码
|
90
91
92
|
if(0 != ret){
return -1;
}
|
2ae58093
Hu Chunming
添加road_seg算法
|
93
|
|
581a68a4
Hu Chunming
修正parse_road无返回值导...
|
94
|
ret = m_road_seg_algorithm.init(dev_id, param.sdk_path);
|
4a273a4a
Hu Chunming
添加hcp和hp
|
95
96
97
98
|
if(0 != ret){
return -1;
}
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
99
100
101
102
103
|
ret = m_crop_util.init(dev_id);
if(0 != ret){
return -1;
}
|
4a273a4a
Hu Chunming
添加hcp和hp
|
104
105
|
ACL_CALL(aclrtCreateContext(&m_ctx, 0), ACL_SUCCESS, SY_FAILED);
ACL_CALL(aclrtSetCurrentContext(m_ctx), ACL_SUCCESS, SY_FAILED);
|
20396d5c
Hu Chunming
添加车头车尾算法
|
106
107
108
109
110
111
112
|
ACL_CALL(aclrtCreateStream(&stream), ACL_SUCCESS, SY_FAILED);
m_dvpp = new DvppProcess();
m_dvpp->InitResource(stream);
return 0;
}
|
427201b2
Hu Chunming
完善结果返回
|
113
114
115
|
vector<AnalysisResult> PicAnalysis::analysis_file(vector<string> vec_file_path){
vector<AnalysisResult> result;
|
20396d5c
Hu Chunming
添加车头车尾算法
|
116
|
|
e8beee4d
Hu Chunming
实现jni接口
|
117
118
119
|
int ret = aclrtSetCurrentContext(m_ctx);
if (SY_SUCCESS != ret) {
printf("aclrtSetCurrentContext failed!");
|
427201b2
Hu Chunming
完善结果返回
|
120
|
return result;
|
e8beee4d
Hu Chunming
实现jni接口
|
121
|
}
|
15756629
Hu Chunming
添加clothes算法
|
122
|
|
20396d5c
Hu Chunming
添加车头车尾算法
|
123
124
125
126
|
const int batch_size = vec_file_path.size();
vector<sy_img> vec_img;
|
20396d5c
Hu Chunming
添加车头车尾算法
|
127
128
129
130
131
132
133
134
135
|
// ImageData 内部是智能指针,分析未处理完成前不得释放
ImageData dvpp_data[batch_size];
for (size_t i = 0; i < vec_file_path.size(); i++)
{
string file_path = vec_file_path[i];
ImageData src;
ret = Utils::ReadImageFile(src, file_path); //将二进制图像读入内存,并读取宽高信息
if(ret != SY_SUCCESS){
LOG_ERROR("ReadImageFile failed!");
|
427201b2
Hu Chunming
完善结果返回
|
136
|
return result;
|
20396d5c
Hu Chunming
添加车头车尾算法
|
137
138
139
140
141
|
}
ret = m_dvpp->CvtJpegToYuv420sp(dvpp_data[i], src); //解码
if(ret != SY_SUCCESS){
LOG_ERROR("CvtJpegToYuv420sp failed!");
|
427201b2
Hu Chunming
完善结果返回
|
142
|
return result;
|
20396d5c
Hu Chunming
添加车头车尾算法
|
143
144
145
146
147
148
149
150
151
|
}
sy_img img;
img.w_ = dvpp_data[i].width;
img.h_ = dvpp_data[i].height;
img.data_ = dvpp_data[i].data.get();
vec_img.push_back(img);
}
|
e8beee4d
Hu Chunming
实现jni接口
|
152
153
154
155
|
return analysis_img(vec_img);
}
|
52516fb9
Hu Chunming
添加授权代码;
|
156
|
vector<AnalysisResult> PicAnalysis::analysis_img(vector<sy_img> vec_img){
|
427201b2
Hu Chunming
完善结果返回
|
157
|
|
52516fb9
Hu Chunming
添加授权代码;
|
158
|
std::lock_guard<std::mutex> l(m_single_mtx);
|
427201b2
Hu Chunming
完善结果返回
|
159
|
|
52516fb9
Hu Chunming
添加授权代码;
|
160
|
vector<AnalysisResult> vec_result;
|
427201b2
Hu Chunming
完善结果返回
|
161
|
|
52516fb9
Hu Chunming
添加授权代码;
|
162
163
164
165
|
#ifndef AUTHORIZATION
if (!CheckTime()) { //时间限制
LOG_FATAL("authority failed!");
return vec_result;
|
427201b2
Hu Chunming
完善结果返回
|
166
|
}
|
52516fb9
Hu Chunming
添加授权代码;
|
167
168
169
170
171
172
173
174
175
176
|
#else
if (check_label == -1) { //机器授权
LOG_FATAL("authority failed!");
return vec_result;
}
if (!UpdateLabel()) {
LOG_FATAL("authority failed!");
return vec_result;
}
#endif
|
427201b2
Hu Chunming
完善结果返回
|
177
|
|
ba6761f1
Hu Chunming
补充日志
|
178
179
|
LOG_INFO("vec_img size:{}", vec_img.size());
|
e8beee4d
Hu Chunming
实现jni接口
|
180
181
182
183
|
const int batch_size = vec_img.size();
int ret = aclrtSetCurrentContext(m_ctx);
if (SY_SUCCESS != ret) {
|
ba6761f1
Hu Chunming
补充日志
|
184
|
LOG_INFO("aclrtSetCurrentContext failed!");
|
427201b2
Hu Chunming
完善结果返回
|
185
|
return vec_result;
|
e8beee4d
Hu Chunming
实现jni接口
|
186
187
|
}
|
52516fb9
Hu Chunming
添加授权代码;
|
188
|
vec_result = m_vehicle_analysis.detect(vec_img);
|
427201b2
Hu Chunming
完善结果返回
|
189
|
|
ba6761f1
Hu Chunming
补充日志
|
190
191
|
LOG_INFO("vec_result size:{}", vec_result.size());
|
81e8a405
Hu Chunming
初步完成SDK
|
192
|
bool bConsistent = false;
|
06e0182f
Hu Chunming
修复src图片alignWidth...
|
193
194
|
std::vector<RoadInfo> vec_road = m_road_seg_algorithm.detect(vec_img);
if (vec_road.size() == batch_size && vec_result.size() == batch_size) {
|
81e8a405
Hu Chunming
初步完成SDK
|
195
|
bConsistent = true;
|
06e0182f
Hu Chunming
修复src图片alignWidth...
|
196
197
198
199
200
|
for (size_t i = 0; i < batch_size; i++) {
vec_result[i].vec_line = vec_road[i].vec_line;
vec_result[i].vec_road = vec_road[i].vec_road;
}
}
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
201
|
|
427201b2
Hu Chunming
完善结果返回
|
202
|
for (int b = 0; b < vec_result.size(); b++)
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
203
|
{
|
427201b2
Hu Chunming
完善结果返回
|
204
205
|
vector<VehicleInfo>& vec_info = vec_result[b].info;
|
81e8a405
Hu Chunming
初步完成SDK
|
206
207
208
209
210
|
RoadInfo road_info;
if (bConsistent) {
road_info = vec_road[b];
}
|
e8beee4d
Hu Chunming
实现jni接口
|
211
|
sy_img img = vec_img[b];
|
06e0182f
Hu Chunming
修复src图片alignWidth...
|
212
|
|
e8beee4d
Hu Chunming
实现jni接口
|
213
214
215
|
ImageData src;
src.width = img.w_;
src.height = img.h_;
|
06e0182f
Hu Chunming
修复src图片alignWidth...
|
216
217
218
|
src.alignWidth = ALIGN_UP16(img.w_);
src.alignHeight = ALIGN_UP2(img.h_);
src.size = YUV420SP_SIZE(src.alignWidth, src.alignHeight);
|
e8beee4d
Hu Chunming
实现jni接口
|
219
|
src.data_naked = img.data_;
|
427201b2
Hu Chunming
完善结果返回
|
220
|
for(int c=0;c<vec_info.size();c++)
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
221
|
{
|
427201b2
Hu Chunming
完善结果返回
|
222
223
|
VehicleInfo& result_info = vec_info[c];
int shot_type=result_info.type;
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
224
|
|
81e8a405
Hu Chunming
初步完成SDK
|
225
226
|
sy_rect vehicle_rect = result_info.vehicle_body_detect_res.rect;
|
5e69f8fc
Hu Chunming
补充字段;
|
227
228
|
if (road_info.vec_direct.size() > 0 && (1 == shot_type || 0 == shot_type)) {
result_info.reverse_driving = m_road_seg_algorithm.check_reverse_driving(road_info.vec_direct, vehicle_rect, src.width, src.height, shot_type);
|
81e8a405
Hu Chunming
初步完成SDK
|
229
230
|
}
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
231
|
// 行人
|
10667f7c
Hu Chunming
违法载人判断的优化
|
232
|
if (0 == result_info.vpt_type)
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
233
|
{
|
81e8a405
Hu Chunming
初步完成SDK
|
234
|
ImageData* human_data = m_crop_util.crop(src, vehicle_rect.left_, vehicle_rect.top_, vehicle_rect.left_ + vehicle_rect.width_, vehicle_rect.top_ + vehicle_rect.height_);
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
235
236
237
238
239
240
241
242
243
|
sy_img img;
img.w_ = human_data->alignWidth;
img.h_ = human_data->alignHeight;
img.data_ = human_data->data_naked;
vector<sy_img> vec_human_img;
vec_human_img.push_back(img);
|
427201b2
Hu Chunming
完善结果返回
|
244
245
246
247
|
vector<BodyColorInfo> vec_body_color = m_human_algorithm.detect(vec_human_img);
result_info.human_upper_color = vec_body_color[0].upper_body_color;
result_info.human_lower_color = vec_body_color[0].lower_body_color;
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
248
249
250
|
delete human_data;
human_data = nullptr;
|
10667f7c
Hu Chunming
违法载人判断的优化
|
251
252
253
254
255
|
} else if(result_info.vpt_type == 1 || result_info.vpt_type == 2 || result_info.vpt_type == 3){
if(result_info.manned_res.hs_count >= 3){
// 摩托车、三轮车载人
result_info.motor_manned = 1;
}
|
667e7a90
Hu Chunming
雨棚和打电话初步代码
|
256
|
} else {
|
10667f7c
Hu Chunming
违法载人判断的优化
|
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
ImageData* vehicle_data = m_crop_util.crop(src, vehicle_rect.left_, vehicle_rect.top_, vehicle_rect.left_ + vehicle_rect.width_, vehicle_rect.top_ + vehicle_rect.height_);
sy_img img;
img.w_ = vehicle_data->alignWidth;
img.h_ = vehicle_data->alignHeight;
img.data_ = vehicle_data->data_naked;
vector<sy_img> vec_vehicle_img;
vec_vehicle_img.push_back(img);
vector<HeadTailResult> head_tail_result;
ret = m_head_tail_algorithm.detect(vec_vehicle_img, head_tail_result);
if (0 != ret) {
LOG_ERROR("m_head_tail_algorithm failed!");
head_tail_result.clear();
} else {
auto one_ht_result = head_tail_result[0];
if(result_info.vpt_type == 6 || result_info.vpt_type == 7){
if (one_ht_result.cls == 0 && result_info.manned_res.hs_count > 0)
{ // 车尾,判断是否 货车尾部货厢载人
result_info.truck_manned = 1;
}
}
|
667e7a90
Hu Chunming
雨棚和打电话初步代码
|
281
|
}
|
98293f20
Hu Chunming
修复显存泄露导致崩溃问题
|
282
283
|
delete vehicle_data;
vehicle_data = nullptr;
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
284
285
286
|
}
// 司乘
|
427201b2
Hu Chunming
完善结果返回
|
287
288
|
auto& pendant_res = result_info.vehicle_pendant_det_res;
int vpd_num = pendant_res.size();
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
289
|
vector<sy_img> vec_human_img;
|
427201b2
Hu Chunming
完善结果返回
|
290
|
vector<ImageData*> vec_data;
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
291
292
|
for(int p=0; p<vpd_num; p++)
{
|
427201b2
Hu Chunming
完善结果返回
|
293
294
295
|
int index = pendant_res[p].index;
if(index == 0){ //driver
sy_rect human_rect = pendant_res[p].rect;
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
296
297
298
299
300
301
302
303
|
ImageData* human_data = m_crop_util.crop(src, human_rect.left_, human_rect.top_, human_rect.left_ + human_rect.width_, human_rect.top_ + human_rect.height_);
sy_img img;
img.w_ = human_data->alignWidth;
img.h_ = human_data->alignHeight;
img.data_ = human_data->data_naked;
vec_human_img.push_back(img);
|
427201b2
Hu Chunming
完善结果返回
|
304
305
|
vec_data.push_back(human_data);
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
306
307
308
|
}
}
|
427201b2
Hu Chunming
完善结果返回
|
309
|
vector<int> vec_color = m_clothes_algorithm.detect(vec_human_img);
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
310
|
|
427201b2
Hu Chunming
完善结果返回
|
311
|
for(int p=0; p<vec_color.size(); p++)
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
312
|
{
|
427201b2
Hu Chunming
完善结果返回
|
313
314
315
316
317
318
319
|
int index = pendant_res[p].index;
if(index == 0) { // 更新司乘衣着颜色
pendant_res[p].iColor = vec_color[p];
ImageData* human_data = vec_data[p];
delete human_data;
human_data = nullptr;
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
320
321
322
323
324
325
|
}
}
// 摩托车
if(shot_type==2)//摩托车
{
|
81e8a405
Hu Chunming
初步完成SDK
|
326
|
ImageData* motor_data = m_crop_util.crop(src, vehicle_rect.left_, vehicle_rect.top_, vehicle_rect.left_ + vehicle_rect.width_, vehicle_rect.top_ + vehicle_rect.height_);
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
327
328
329
330
331
332
333
334
335
|
sy_img img;
img.w_ = motor_data->alignWidth;
img.h_ = motor_data->alignHeight;
img.data_ = motor_data->data_naked;
vector<sy_img> vec_motor_img;
vec_motor_img.push_back(img);
|
6f9dffde
Hu Chunming
返回prob
|
336
337
338
339
|
vector<MotorRainshedResult> vec_rainshed_result = m_motor_rainshed_algorithm.detect(vec_motor_img);
if (vec_rainshed_result.size() > 0) {
result_info.rainshed = vec_rainshed_result[0].rainshed;
result_info.rainshed_prob = vec_rainshed_result[0].prob;
|
667e7a90
Hu Chunming
雨棚和打电话初步代码
|
340
|
}
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
341
|
|
6f9dffde
Hu Chunming
返回prob
|
342
343
344
345
|
vector<MotorPhoneResult> vec_phone_result = m_motor_phone_algorithm.detect(vec_motor_img);
if (vec_phone_result.size() > 0) {
result_info.phoning = vec_phone_result[0].phoning;
result_info.phoning_prob = vec_phone_result[0].prob;
|
81e8a405
Hu Chunming
初步完成SDK
|
346
347
|
}
|
f258e1c8
Hu Chunming
添加非机动车驾乘信息
|
348
|
int iColor = -1;
|
81e8a405
Hu Chunming
初步完成SDK
|
349
|
std::vector<HumanCarResult> vec_hcp_result = m_human_car_algorithm.detect(vec_motor_img);
|
5e69f8fc
Hu Chunming
补充字段;
|
350
|
if (vec_hcp_result.size() > 0 && road_info.vec_direct.size() > 0) {
|
a1a053f2
Hu Chunming
修正人骑车逻辑错误
|
351
|
int head_or_tail = vec_hcp_result[0].orient;
|
5e69f8fc
Hu Chunming
补充字段;
|
352
353
|
if (head_or_tail == 0 || head_or_tail == 1) {
result_info.reverse_driving = m_road_seg_algorithm.check_reverse_driving(road_info.vec_direct, vehicle_rect, src.width, src.height, head_or_tail);
|
81e8a405
Hu Chunming
初步完成SDK
|
354
|
}
|
f258e1c8
Hu Chunming
添加非机动车驾乘信息
|
355
356
357
358
359
360
361
362
363
364
365
366
367
368
|
iColor = vec_hcp_result[0].up_color;
}
int hs_num = result_info.manned_res.hs_count;
for (size_t i = 0; i < hs_num; i++)
{
pendant_info one_pendant;
one_pendant.confidence = result_info.manned_res.hs_rect[i].score;
one_pendant.rect = result_info.manned_res.hs_rect[i].rect;
one_pendant.index = 0;
one_pendant.iColor = iColor;
result_info.vehicle_pendant_det_res.push_back(one_pendant);
|
667e7a90
Hu Chunming
雨棚和打电话初步代码
|
369
370
|
}
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
371
372
373
|
delete motor_data;
motor_data = nullptr;
}
|
81e8a405
Hu Chunming
初步完成SDK
|
374
375
|
//压黄实线
|
581a68a4
Hu Chunming
修正parse_road无返回值导...
|
376
|
result_info.cross_line = m_road_seg_algorithm.check_cross_line(road_info.vec_line, vehicle_rect, src.width, src.height);
|
81e8a405
Hu Chunming
初步完成SDK
|
377
|
// 压导流线
|
581a68a4
Hu Chunming
修正parse_road无返回值导...
|
378
|
result_info.cross_diversion_line = m_road_seg_algorithm.check_cross_region(road_info.vec_road, vehicle_rect, src.width, src.height, 3); //3是导流线区域
|
b3012672
Hu Chunming
天啊及hp,road_seg子sd...
|
379
380
|
}
}
|
20396d5c
Hu Chunming
添加车头车尾算法
|
381
|
|
06e0182f
Hu Chunming
修复src图片alignWidth...
|
382
|
LOG_INFO("analysis finished!");
|
4a273a4a
Hu Chunming
添加hcp和hp
|
383
|
|
427201b2
Hu Chunming
完善结果返回
|
384
|
return vec_result;
|
20396d5c
Hu Chunming
添加车头车尾算法
|
385
386
387
|
}
int PicAnalysis::release() {
|
4a273a4a
Hu Chunming
添加hcp和hp
|
388
389
|
ACL_CALL(aclrtSetCurrentContext(m_ctx), ACL_SUCCESS, SY_FAILED);
|
20396d5c
Hu Chunming
添加车头车尾算法
|
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
|
delete m_dvpp;
m_dvpp = nullptr;
if (stream != nullptr) {
int ret = aclrtDestroyStream(stream);
if (ret != ACL_SUCCESS) {
LOG_ERROR("destroy stream failed");
}
stream = nullptr;
}
aclrtDestroyContext(m_ctx);
return 0;
|
52516fb9
Hu Chunming
添加授权代码;
|
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
|
}
bool PicAnalysis::CheckLabel(int devId) {
const char *token_password = "village_atlas_arm_2023";
std::string guid = std::string("village_atlas_arm")+std::to_string(devId);
atlas_licence_param lic_param;
memset(&lic_param, 0, sizeof(atlas_licence_param));
sprintf(lic_param.product_id, "%s", productSN);
sprintf(lic_param.guid, "%s",guid.c_str());
sprintf(lic_param.token_pwd, "%s", token_password);
lic_param.channel_num = 1;
atlas_licence_token param_token;
memset(¶m_token, 0, sizeof(atlas_licence_token));
int result = atlas_licence_connect(&(skt_handle), lic_param, ¶m_token);
//printf("result:%d,code:%d,msg:%s \n", result, param_token.code, param_token.msg);
//printf("token:%s\n", param_token.token);
std::string recv_token = std::string(param_token.token);
//atlas_licence_check_param check_param;
memset(&(check_param), 0, sizeof(atlas_licence_check_param));
sprintf(check_param.token_pwd, "%s", token_password);
sprintf(check_param.time, "%s", "2023-01-10 20:00:00");
sprintf(check_param.token, "%s", recv_token .c_str());
check_param.consume = 2;
//授权check------------
check_label = -1;//初始值
std::cout << "sy_licence_check start." << std::endl;
atlas_licence_check_result check_result;
memset(&check_result, 0, sizeof(atlas_licence_check_result));
check_result.code = -1;
int res = atlas_licence_check(skt_handle, check_param, &check_result);
if(res!=0) {
std::cout << "sy_licence_check failed." << std::endl;
return false;
}
//std::cout << "code:" << check_result.code << ",msg:" << check_result.msg << std::endl;
if(check_result.code!=0) {
std::cout << "code:" << check_result.code << ",msg:" << check_result.msg << std::endl;
return false;
}
std::cout << "sy_licence_check end." << std::endl;
check_label = 0;//授权成功
return true;
}
bool PicAnalysis::UpdateLabel() {
//获取系统时间,每个月1号check一次授权
struct tm* info;
int nYear, nMonth, nDay;
time_t raw;
time(&raw);
info = localtime(&raw);
nYear = info->tm_year + 1900;
nMonth = info->tm_mon + 1;
nDay = info->tm_mday;
if(nDay==1) {
if(check_label ==0) {
LOG_INFO("atlas_licence_check start.");
atlas_licence_check_result check_result;
memset(&check_result, 0, sizeof(atlas_licence_check_result));
check_result.code = -1;
int res = atlas_licence_check(skt_handle, check_param, &check_result);
if(res!=0) {
LOG_FATAL("sy_licence_check failed.");
return false;
}
if(check_result.code!=0) {
check_label = -1;
LOG_FATAL("atlas_licence_check code:{}, msg:{}",check_result.code, check_result.msg);
return false;
}
LOG_INFO("atlas_licence_check end.");
check_label =1;
}
}
else {
check_label =0;
}
return true;
}
bool PicAnalysis::CheckTime() {
struct tm* info;
int nYear, nMonth, nDay;
time_t raw;
time(&raw);
info = localtime(&raw);
nYear = info->tm_year + 1900;
nMonth = info->tm_mon + 1;
nDay = info->tm_mday;
if (nYear == 2025 && (nMonth <= 11 || (nMonth <= 12 && nDay <= 31))){
return true;
} else {
return false;
}
|
20396d5c
Hu Chunming
添加车头车尾算法
|
506
|
}
|