Commit 27f0a463868bdf975ad25799fc3260c9abc2c847
1 parent
fa818303
玩手机模型升级 货车载人增加关键点辅助
Showing
10 changed files
with
302 additions
and
26 deletions
bin/libvehicle_pose_vdec.so
0 → 100755
No preview for this file type
bin/models/village/motor_phone1013_310p.om
0 → 100644
No preview for this file type
bin/models/village/vpose_310p.om
0 → 100644
No preview for this file type
src/Makefile
... | ... | @@ -38,7 +38,7 @@ lib=-lacl_dvpp -lascendcl -lacl_dvpp_mpi -lruntime -lascendalog -lc_sec -lmsprof |
38 | 38 | -lplatform -lgraph_base -lqos_manager |
39 | 39 | |
40 | 40 | LIBS= -L $(SPDLOG_ROOT)/lib -l:libspdlog.a \ |
41 | - -L $(DEPEND_DIR) -lvpt_det_vdec -lsycheck -lface_det_vdec -lhs_tri_process -lhs_truck_process -lphone_motor_det -lhcp_vdec -lmotor_rainshed_vdec -ltraffic_light_vdec -lhs_motor_process\ | |
41 | + -L $(DEPEND_DIR) -lvpt_det_vdec -lsycheck -lface_det_vdec -lhs_tri_process -lhs_truck_process -lphone_motor_det -lhcp_vdec -lmotor_rainshed_vdec -ltraffic_light_vdec -lvehicle_pose_vdec -lhs_motor_process\ | |
42 | 42 | -L $(OPENCV_ROOT)/lib -lopencv_world\ |
43 | 43 | -L $(JSON_ROOT)/lib -ljsoncpp \ |
44 | 44 | -L $(FFMPEG_ROOT)/lib -lavformat -lavcodec -lswscale -lavutil -lavfilter -lswresample -lavdevice \ | ... | ... |
src/ai_engine_module/motocycle_phone_process.cpp
... | ... | @@ -84,7 +84,8 @@ namespace ai_engine_module |
84 | 84 | { |
85 | 85 | init_ = false; |
86 | 86 | |
87 | - string model_path = models_dir + "/models/village/motor_phone_310p.om" ; | |
87 | + // string model_path = models_dir + "/models/village/motor_phone_310p.om" ; | |
88 | + string model_path = models_dir + "/models/village/motor_phone1013_310p.om" ; | |
88 | 89 | LOG_INFO("motor_phone 版本:{} 模型路径:{}", motor_phone_getversion(), model_path); |
89 | 90 | |
90 | 91 | motor_phone_param param; | ... | ... |
src/ai_engine_module/motocycle_refit_phone_process.cpp
... | ... | @@ -89,7 +89,8 @@ namespace ai_engine_module |
89 | 89 | { |
90 | 90 | init_ = false; |
91 | 91 | |
92 | - string model_phone_path = models_dir + "/models/village/motor_phone_310p.om" ; | |
92 | + // string model_phone_path = models_dir + "/models/village/motor_phone_310p.om" ; | |
93 | + string model_phone_path = models_dir + "/models/village/motor_phone1013_310p.om" ; | |
93 | 94 | string model_hcp_path = models_dir + "/models/village/hcp211008_310p.om" ; |
94 | 95 | LOG_INFO("motor_phone 版本:{} 模型路径:{} hcp 版本:{} 模型路径:{}", motor_phone_getversion(), model_phone_path, hcp_get_version(), model_hcp_path); |
95 | 96 | ... | ... |
src/ai_engine_module/truck_manned_process.cpp
... | ... | @@ -5,6 +5,9 @@ |
5 | 5 | #include "../common/logger.hpp" |
6 | 6 | #include "../ai_platform/mvpt_process_assist.h" |
7 | 7 | |
8 | +#include "opencv2/opencv.hpp" | |
9 | +#include "opencv2/imgcodecs/legacy/constants_c.h" | |
10 | + | |
8 | 11 | |
9 | 12 | namespace ai_engine_module |
10 | 13 | { |
... | ... | @@ -25,15 +28,34 @@ namespace ai_engine_module |
25 | 28 | float area_b = float(right - left) * float(bottom - top); |
26 | 29 | float area_intersection = float(x2_intersection - x1_intersection) * float(y2_intersection - y1_intersection); |
27 | 30 | |
28 | - if (area_a > area_b || area_a <= 0) continue; //暂不考虑非机动车目标比货车大的情况 | |
31 | + if (area_a > area_b || area_a <= 0) continue; //暂不考虑行人及非机动车目标比货车大的情况 | |
29 | 32 | // float iou = area_intersection / (area_a + area_b - area_intersection); |
30 | - float small_overlap_ratio = area_intersection / area_a; //计算非机动车目标相对于自身的重叠程度 | |
33 | + float small_overlap_ratio = area_intersection / area_a; //计算行人及非机动车目标相对于自身的重叠程度 | |
31 | 34 | if (small_overlap_ratio > 0.2) legal_person_motocycle_count ++; |
32 | 35 | } |
33 | 36 | return legal_person_motocycle_count; |
34 | 37 | |
35 | 38 | } |
36 | 39 | |
40 | + void vpose_transform(float pt_x, float pt_y, float center_x, float center_y, float llength, int invert, int *res) { | |
41 | + //Transform pixel location to different reference. | |
42 | + float tmp = float(IMG_RES) / llength; | |
43 | + float t00 = tmp, t11 = tmp; | |
44 | + float t02 = IMG_RES * (-center_x / llength + .5); | |
45 | + float t12 = IMG_RES * (-center_y / llength + .5); | |
46 | + cv::Mat t = (cv::Mat_<float>(3,3) << t00,0,t02,0,t11,t12,0,0,1); | |
47 | + cv::Mat invt = (cv::Mat_<float>(3,3) << 0,0,0,0,0,0,0,0,0); | |
48 | + if (invert) | |
49 | + cv::invert(t, invt); | |
50 | + | |
51 | + cv::Mat new_pt = (cv::Mat_<float>(3,1) << pt_x-1, pt_y-1, 1.); | |
52 | + cv::Mat arr_new = invt * new_pt; | |
53 | + | |
54 | + for (int i = 0; i < 3-1; i++) { | |
55 | + res[i] = int(arr_new.at<float>(i,0)); | |
56 | + } | |
57 | + } | |
58 | + | |
37 | 59 | TruckMannedProcess::TruckMannedProcess() |
38 | 60 | : task_param_manager_(nullptr) |
39 | 61 | { |
... | ... | @@ -42,9 +64,13 @@ namespace ai_engine_module |
42 | 64 | |
43 | 65 | TruckMannedProcess::~TruckMannedProcess() |
44 | 66 | { |
45 | - if (tools_) { | |
46 | - hs_truck_release(&tools_); | |
47 | - tools_ = nullptr; | |
67 | + if (hs_tools_) { | |
68 | + hs_truck_release(&hs_tools_); | |
69 | + hs_tools_ = nullptr; | |
70 | + } | |
71 | + if (vpose_tools_) { | |
72 | + vehicle_pose_release(&vpose_tools_); | |
73 | + vpose_tools_ = nullptr; | |
48 | 74 | } |
49 | 75 | if (m_algorthim_ctx) { |
50 | 76 | aclrtDestroyContext(m_algorthim_ctx); |
... | ... | @@ -57,6 +83,8 @@ namespace ai_engine_module |
57 | 83 | |
58 | 84 | string model_path = models_dir + "/models/hs/hs_truck_310p.om" ; |
59 | 85 | LOG_INFO("hs_truck 版本:{} 模型路径:{}", hs_truck_getversion(), model_path); |
86 | + string model_vpose_path = models_dir + "/models/village/vpose_310p.om" ; | |
87 | + LOG_INFO("vpose 版本:{} 模型路径:{}", vehicle_pose_get_version(), model_vpose_path); | |
60 | 88 | |
61 | 89 | hs_truck_param param; |
62 | 90 | char modelNames[100]; |
... | ... | @@ -64,14 +92,23 @@ namespace ai_engine_module |
64 | 92 | param.modelNames = modelNames; |
65 | 93 | param.thresld = 0.25; |
66 | 94 | param.devId = gpu_id; |
95 | + | |
96 | + vehicle_pose_param vparam; | |
97 | + char vpose_modelNames[100]; | |
98 | + strcpy(vpose_modelNames, model_vpose_path.c_str()); | |
99 | + vparam.modelNames = vpose_modelNames; | |
100 | + vparam.ldmk_thres = 0.0; | |
101 | + vparam.devId = gpu_id; | |
67 | 102 | |
68 | - m_devId = param.devId; | |
103 | + m_devId = gpu_id; | |
69 | 104 | ACL_CALL(aclrtSetDevice(m_devId), ACL_SUCCESS, -1); |
70 | 105 | ACL_CALL(aclrtCreateContext(&m_algorthim_ctx, m_devId), ACL_SUCCESS, -1); |
71 | - | |
106 | + | |
72 | 107 | int status; |
73 | - if (!(init_ = (0 == (status = hs_truck_init(&tools_, param))))) | |
108 | + if (!(init_ = (0 == (status = hs_truck_init(&hs_tools_, param))))) | |
74 | 109 | LOG_ERROR("Init TruckMannedProcessSdk failed error code is {}", status); |
110 | + else if (!(init_ = (0 == (status = vehicle_pose_init(&vpose_tools_, vparam))))) | |
111 | + LOG_ERROR("Init VehiclePoseProcessSdk failed error code is {}", status); | |
75 | 112 | else |
76 | 113 | if (!task_param_manager_) |
77 | 114 | task_param_manager_ = task_param_manager::getInstance(); |
... | ... | @@ -139,6 +176,8 @@ namespace ai_engine_module |
139 | 176 | auto taskId_iter = taskIds.begin(); |
140 | 177 | std::vector<sy_img> flattened_imgs(0); |
141 | 178 | std::vector<vpc_img_info> flattened_vpc_imgs(0); |
179 | + std::vector<sy_img> flattened_vpose_imgs(0); | |
180 | + std::vector<vpc_img_info> flattened_vpc_vpose_imgs(0); | |
142 | 181 | std::vector<input_data_wrap_t> flattened_interest_data(0); // |
143 | 182 | VPCUtil* pVpcUtil = VPCUtil::getInstance(); |
144 | 183 | for (int n = 0; n < n_images; ++n) |
... | ... | @@ -206,27 +245,44 @@ namespace ai_engine_module |
206 | 245 | |
207 | 246 | //统计货车检测框内行人及非机动车的数量 |
208 | 247 | int person_motocycle_inarea = legal_person_motocycle_inarea(person_motocycle_data, left, top, right, bottom); |
209 | - | |
210 | - data.box.top = top; data.box.left = left; | |
211 | - data.box.right = right; data.box.bottom = bottom; | |
248 | + //vpose========================================================================================================= | |
249 | + int x_center = round(float((right + left))/2); | |
250 | + int y_center = round(float((bottom + top))/2); | |
251 | + float llength = std::max(right -left, bottom - top); | |
252 | + | |
253 | + // Crop image according to the supplied bounding box. | |
254 | + int ul[2]={0}; int br[2]={0}; | |
255 | + vpose_transform(1, 1, x_center, y_center, llength, 1, ul); // Upper left point | |
256 | + vpose_transform(IMG_RES+1, IMG_RES+1, x_center, y_center, llength, 1, br); // Bottom right point | |
257 | + | |
258 | + int vpose_left = std::max(-ul[0],0); int vpose_top = std::max(-ul[1],0); | |
259 | + int vpose_right = std::min(br[0], src_img_w) - ul[0]; | |
260 | + int vpose_bottom = std::min(br[1], src_img_h) - ul[1]; | |
261 | + int vpose_width = vpose_right - vpose_left; | |
262 | + int vpose_height = vpose_bottom - vpose_top; | |
263 | + if (vpose_width != vpose_height) continue; // 宽高不相等说明处于边缘位置,不处理 | |
264 | + //============================================================================================================= | |
265 | + | |
266 | + data.box.top = top; data.box.left = left; | |
267 | + data.box.right = right; data.box.bottom = bottom; | |
212 | 268 | data.box.score = box.confidence; |
213 | - data.taskId = taskId; data.objId = box.id; | |
269 | + data.taskId = taskId; data.objId = box.id; | |
214 | 270 | data.id = obj_key_t{ box.id, taskId, algorithm_type_t::TRUCK_MANNED }; |
215 | 271 | data.person_motocycle_cnt = person_motocycle_inarea; |
272 | + data.vpose_box.top = vpose_top; data.vpose_box.left = vpose_left; | |
273 | + data.vpose_box.right = vpose_right; data.vpose_box.bottom = vpose_bottom; | |
274 | + data.x_center = x_center; data.y_center = y_center; data.llength = llength; | |
216 | 275 | |
217 | 276 | // 抠图 |
218 | 277 | video_object_info obj; |
219 | 278 | strcpy(obj.task_id, taskId.c_str()); |
220 | 279 | obj.object_id = box.id; |
221 | - obj.left = left; obj.top = top; | |
222 | - obj.right = right; obj.bottom = bottom; | |
280 | + obj.left = left; obj.top = top; obj.right = right; obj.bottom = bottom; | |
223 | 281 | |
224 | 282 | vpc_img_info img_info = pVpcUtil->crop(src_img, obj); |
225 | 283 | |
226 | 284 | sy_img img; |
227 | - img.w_ = width; | |
228 | - img.h_ = height; | |
229 | - img.c_ = src_img->getChannel(); | |
285 | + img.w_ = width; img.h_ = height; img.c_ = src_img->getChannel(); | |
230 | 286 | |
231 | 287 | if (img_info.pic_desc != nullptr) { |
232 | 288 | void *outputDataDev = acldvppGetPicDescData(img_info.pic_desc); |
... | ... | @@ -237,9 +293,33 @@ namespace ai_engine_module |
237 | 293 | src_img_w, src_img_h, data.box.left, data.box.top, data.box.right, data.box.bottom); |
238 | 294 | continue; |
239 | 295 | } |
296 | + | |
297 | + // vpose抠图 | |
298 | + video_object_info vpose_obj; | |
299 | + strcpy(vpose_obj.task_id, taskId.c_str()); | |
300 | + vpose_obj.object_id = box.id; | |
301 | + vpose_obj.left = vpose_left; vpose_obj.top = vpose_top; vpose_obj.right = vpose_right; vpose_obj.bottom = vpose_bottom; | |
302 | + | |
303 | + vpc_img_info vpose_img_info = pVpcUtil->crop(src_img, vpose_obj); | |
304 | + | |
305 | + sy_img vpose_img; | |
306 | + vpose_img.w_ = vpose_width; vpose_img.h_ = vpose_height; vpose_img.c_ = src_img->getChannel(); | |
307 | + | |
308 | + if (vpose_img_info.pic_desc != nullptr) { | |
309 | + void *outputDataDev = acldvppGetPicDescData(vpose_img_info.pic_desc); | |
310 | + vpose_img.data_ = reinterpret_cast<unsigned char*>(outputDataDev); | |
311 | + } | |
312 | + else { | |
313 | + LOG_ERROR("Crop image NPU failed wh is [{}, {}] ltrb is [{} {} {} {}]", | |
314 | + src_img_w, src_img_h, data.vpose_box.left, data.vpose_box.top, data.vpose_box.right, data.vpose_box.bottom); | |
315 | + VPCUtil::vpc_img_release(img_info); | |
316 | + continue; | |
317 | + } | |
240 | 318 | |
241 | 319 | flattened_imgs.emplace_back(std::move(img)); |
242 | 320 | flattened_vpc_imgs.emplace_back(std::move(img_info)); |
321 | + flattened_vpose_imgs.emplace_back(std::move(vpose_img)); //vpose | |
322 | + flattened_vpc_vpose_imgs.emplace_back(std::move(vpose_img_info)); //vpose | |
243 | 323 | flattened_interest_data.emplace_back(std::move(data)); |
244 | 324 | flattened_idx_to_batch_idx[flattened_idx++] = n; |
245 | 325 | } |
... | ... | @@ -255,13 +335,15 @@ namespace ai_engine_module |
255 | 335 | /* 2. collection result. */ |
256 | 336 | int n_input_image = flattened_imgs.size(); |
257 | 337 | hs_truck_result model_results[n_input_image]; |
338 | + vehicle_pose_result vpose_results[n_input_image]; | |
258 | 339 | { |
259 | 340 | int steps = (n_input_image + MAX_BATCH - 1) / MAX_BATCH; |
260 | 341 | for (int step = 0; step < steps; ++step) |
261 | 342 | { |
262 | 343 | int offset = step * MAX_BATCH; |
263 | 344 | int batch_size = (step == steps - 1) ? n_input_image - offset : MAX_BATCH; |
264 | - hs_truck_process_batch(tools_, flattened_imgs.data() + offset, batch_size, model_results + offset); | |
345 | + hs_truck_process_batch(hs_tools_, flattened_imgs.data() + offset, batch_size, model_results + offset); | |
346 | + vehicle_pose_batch(vpose_tools_, flattened_vpose_imgs.data() + offset, batch_size, vpose_results + offset); | |
265 | 347 | } |
266 | 348 | } |
267 | 349 | |
... | ... | @@ -275,6 +357,8 @@ namespace ai_engine_module |
275 | 357 | { |
276 | 358 | VPCUtil::vpc_img_release(flattened_vpc_imgs[n]); //flattened_imgs[n].data_ |
277 | 359 | flattened_imgs[n].data_ = nullptr; |
360 | + VPCUtil::vpc_img_release(flattened_vpc_vpose_imgs[n]); | |
361 | + flattened_vpose_imgs[n].data_ = nullptr; | |
278 | 362 | continue; |
279 | 363 | } |
280 | 364 | |
... | ... | @@ -286,6 +370,8 @@ namespace ai_engine_module |
286 | 370 | LOG_ERROR("{} nullptr when get algor param from task_param", det_result.taskId.c_str()); |
287 | 371 | VPCUtil::vpc_img_release(flattened_vpc_imgs[n]); //flattened_imgs[n].data_ |
288 | 372 | flattened_imgs[n].data_ = nullptr; |
373 | + VPCUtil::vpc_img_release(flattened_vpc_vpose_imgs[n]); | |
374 | + flattened_vpose_imgs[n].data_ = nullptr; | |
289 | 375 | continue; |
290 | 376 | } |
291 | 377 | |
... | ... | @@ -298,8 +384,38 @@ namespace ai_engine_module |
298 | 384 | auto& e = id_to_mn_[obj_key]; |
299 | 385 | ++e.m_frame; |
300 | 386 | |
387 | + //vpose=========================================================== | |
388 | + auto &vpose_result = vpose_results[n]; // vpose | |
389 | + int ldmk_x1 = src_img->getWidth(), ldmk_y1 = src_img->getHeight(), ldmk_x2 = 0, ldmk_y2 = 0; | |
390 | + for (int p = 0; p < LDMK_COUNT; p++) { | |
391 | + int ul[2]={0}; | |
392 | + // 映射到大图 | |
393 | + vpose_transform(vpose_result.vehicle_ldmk[p].x_-1, vpose_result.vehicle_ldmk[p].y_-1, det_result.x_center, det_result.y_center, det_result.llength, 1, ul); | |
394 | + | |
395 | + ldmk_x1 = std::min(ul[0] + 1, ldmk_x1); | |
396 | + ldmk_y1 = std::min(ul[1] + 1, ldmk_y1); | |
397 | + ldmk_x2 = std::max(ul[0] + 1, ldmk_x2); | |
398 | + ldmk_y2 = std::max(ul[1] + 1, ldmk_y2); | |
399 | + } | |
400 | + // 统计关键点映射出的四边形中的头肩数量 | |
401 | + int hs_inpose_count = 0; | |
402 | + if (ldmk_x2 > ldmk_x1 && ldmk_y2 > ldmk_y1) { | |
403 | + for (int i = 0; i < model_results[n].objcount; i++) { | |
404 | + int x1_intersection = std::max(det_result.box.left + model_results[n].objinfo[i].left, ldmk_x1); | |
405 | + int y1_intersection = std::max(det_result.box.top + model_results[n].objinfo[i].top, ldmk_y1); | |
406 | + int x2_intersection = std::min(det_result.box.left + model_results[n].objinfo[i].right, ldmk_x2); | |
407 | + int y2_intersection = std::min(det_result.box.top + model_results[n].objinfo[i].bottom, ldmk_y2); | |
408 | + if (x2_intersection <= x1_intersection || y2_intersection <= y1_intersection) continue; // 没有交集 | |
409 | + hs_inpose_count ++; | |
410 | + } | |
411 | + | |
412 | + } | |
413 | + //================================================================= | |
414 | + | |
301 | 415 | // if (hs_count >= algor_param->hs_count_threshold) |
302 | - if (hs_count - det_result.person_motocycle_cnt >= algor_param->hs_count_threshold) //头肩数量去除包含的行人和非机动车数量 | |
416 | + LOG_INFO("hs_count:{} hs_inpose_count: {} person_motocycle_cnt:{} threshold: {}", hs_count, hs_inpose_count, det_result.person_motocycle_cnt, algor_param->hs_count_threshold); | |
417 | + // if (hs_count - det_result.person_motocycle_cnt >= algor_param->hs_count_threshold) //头肩数量去除包含的行人和非机动车数量 | |
418 | + if (hs_count - det_result.person_motocycle_cnt >= algor_param->hs_count_threshold || hs_inpose_count >= algor_param->hs_count_threshold) | |
303 | 419 | { |
304 | 420 | if (++e.n_frame == algor_param->n) |
305 | 421 | { |
... | ... | @@ -325,7 +441,7 @@ namespace ai_engine_module |
325 | 441 | VPCUtil::vpc_img_release(flattened_vpc_imgs[n]); //flattened_imgs[n].data_ |
326 | 442 | _continue: |
327 | 443 | { |
328 | - | |
444 | + VPCUtil::vpc_img_release(flattened_vpc_vpose_imgs[n]); | |
329 | 445 | } |
330 | 446 | |
331 | 447 | } | ... | ... |
src/ai_engine_module/truck_manned_process.h
... | ... | @@ -8,6 +8,7 @@ |
8 | 8 | #include "../ai_platform/macro_definition.h" |
9 | 9 | #include "ai_engine_header.h" |
10 | 10 | #include "hs_det_truck.h" |
11 | +#include "vehicle_pose.h" | |
11 | 12 | #include "acl/acl.h" |
12 | 13 | #include "acl/ops/acl_dvpp.h" |
13 | 14 | |
... | ... | @@ -23,6 +24,7 @@ namespace ai_engine_module |
23 | 24 | using id_t = obj_key_t; |
24 | 25 | using task_id_t = std::string; |
25 | 26 | using algor_param_type = algor_config_param_manned_incident*; |
27 | + #define IMG_RES 224 | |
26 | 28 | |
27 | 29 | typedef struct input_data_wrap_t |
28 | 30 | { |
... | ... | @@ -30,7 +32,11 @@ namespace ai_engine_module |
30 | 32 | long objId; |
31 | 33 | int person_motocycle_cnt; |
32 | 34 | std::string taskId; |
33 | - box_t box; | |
35 | + box_t box; // 记录检测框 | |
36 | + box_t vpose_box; // 记录预处理后的检测框 | |
37 | + int x_center; // 外扩前的中心点及长边信息 | |
38 | + int y_center; | |
39 | + float llength; | |
34 | 40 | } input_data_wrap_t; |
35 | 41 | |
36 | 42 | |
... | ... | @@ -91,7 +97,8 @@ namespace ai_engine_module |
91 | 97 | aclrtContext m_algorthim_ctx; |
92 | 98 | |
93 | 99 | bool init_; |
94 | - void* tools_; | |
100 | + void* hs_tools_; | |
101 | + void* vpose_tools_; | |
95 | 102 | task_param_manager* task_param_manager_; |
96 | 103 | std::map<id_t, mn_frame_t> id_to_mn_; |
97 | 104 | std::map<id_t, results_data_t> id_to_result_; | ... | ... |
src/ai_engine_module/vehicle_pose.h
0 → 100644
1 | +/******************************************************************************************* | |
2 | +* Version: car_pose_v0.0.0.20210519 | |
3 | +* CopyRight: 中科视语(北京)科技有限公司 | |
4 | +* UpdateDate: 20210519 | |
5 | +* Content: 车辆姿态估计 | |
6 | +********************************************************************************************/ | |
7 | + | |
8 | +#ifndef _VEHICLE_POSE_H_ | |
9 | +#define _VEHICLE_POSE_H_ | |
10 | + | |
11 | +#ifdef _MSC_VER | |
12 | +#ifdef VEHICLE_POSE_EXPORTS | |
13 | +#define VEHICLE_POSE_API __declspec(dllexport) | |
14 | +#else | |
15 | +#define VEHICLE_POSE_API __declspec(dllimport) | |
16 | +#endif | |
17 | +#else | |
18 | +#define VEHICLE_POSE_API __attribute__ ((visibility ("default"))) //? | |
19 | +#endif | |
20 | + | |
21 | +#include "sy_common.h" | |
22 | + | |
23 | +#define MAX_OBJ_COUNT 200 | |
24 | + | |
25 | +//#define _VEHICLE_DET_ | |
26 | + | |
27 | +#ifdef __cplusplus | |
28 | +extern "C" | |
29 | +{ | |
30 | +#endif | |
31 | + | |
32 | +#define POSE_COUNT 9 | |
33 | +// #define LDMK_COUNT 20 | |
34 | +#define LDMK_COUNT 32 //221104版本有32个关键点 | |
35 | + | |
36 | +#ifndef __VEHICLE_POSE_RESULT__ | |
37 | +#define __VEHICLE_POSE_RESULT__ | |
38 | + typedef struct vehicle_pose_result | |
39 | + { | |
40 | + sy_point vehicle_ldmk[LDMK_COUNT]; | |
41 | + float vehicle_ldmk_score[LDMK_COUNT]; | |
42 | + float vehicle_pose[POSE_COUNT]; | |
43 | + | |
44 | + double phi; | |
45 | + double gamma; | |
46 | + double theta; | |
47 | + }vehicle_pose_result; | |
48 | +#endif | |
49 | + | |
50 | +#ifndef __VEHICLE_POSE_PARAM__ | |
51 | +#define __VEHICLE_POSE_PARAM__ | |
52 | + typedef struct vehicle_pose_param | |
53 | + { | |
54 | + // int mode; /运行模式(DEVICE_GPU / DEVICE_CPU) | |
55 | + int devId; //运行卡号 | |
56 | + char* modelNames; | |
57 | + float ldmk_thres; //ldmk点的阈值 | |
58 | + // int engine; //指定运行引擎(ENGINE_MCAFFE2 / ENGINE_TENSORRT) | |
59 | + // int max_batch; //指定trt批处理数量上限 | |
60 | + // char* serialize_file; //指定trt缓存文件完整路径 | |
61 | + // char* auth_license; | |
62 | + // vehicle_pose_param() :mode(DEVICE_GPU), gpuid(0), engine(ENGINE_TENSORRT), max_batch(20), auth_license("sy") {}; | |
63 | + }vehicle_pose_param; | |
64 | +#endif | |
65 | + | |
66 | + | |
67 | +#ifndef __VEHICLE_POSE_DRAW_PARAM__ | |
68 | +#define __VEHICLE_POSE_DRAW_PARAM__ | |
69 | +#define PIXEL_COUNT 3 | |
70 | + typedef struct vehicle_pose_draw_param | |
71 | + { | |
72 | + int ldmk[PIXEL_COUNT]; //绘制ldmk点 像素值 | |
73 | + int pose[PIXEL_COUNT]; //绘制点云 像素值 | |
74 | + | |
75 | + char* result_image_path; //图片保存路径,如"./result/car1.jpg" | |
76 | + char* car_vertice_path; //car_vertice路径 | |
77 | + | |
78 | + }vehicle_pose_draw_param; | |
79 | +#endif | |
80 | + | |
81 | + | |
82 | + /************************************************************************* | |
83 | + * FUNCTION: car_pose_recg_init | |
84 | + * PURPOSE: 车辆姿态估计初始化 | |
85 | + * PARAM: | |
86 | + [in] handle - 句柄 | |
87 | + [in] param - 初始化参数 | |
88 | + * RETURN: 成功(0)或错误(<0) | |
89 | + * NOTES: | |
90 | + *************************************************************************/ | |
91 | + VEHICLE_POSE_API int vehicle_pose_init(void ** handle, vehicle_pose_param param); | |
92 | + | |
93 | + | |
94 | + /************************************************************************* | |
95 | + * FUNCTION: car_pose_recg_process | |
96 | + * PURPOSE: 车辆姿态估计 | |
97 | + * PARAM: | |
98 | + [in] tools - 句柄 | |
99 | + [in] img_data - 检测图像数据 | |
100 | + [out] result - 检测结果 | |
101 | + * RETURN: 成功(0)或错误(<0) | |
102 | + * NOTES: | |
103 | + *************************************************************************/ | |
104 | + VEHICLE_POSE_API int vehicle_pose_process(void * handle, sy_img * img_data, vehicle_pose_result * result); | |
105 | + | |
106 | + | |
107 | + /************************************************************************* | |
108 | + * FUNCTION: car_pose_recg_batch | |
109 | + * PURPOSE: 车辆姿态估计批处理 | |
110 | + * PARAM: | |
111 | + [in] tools - 句柄 | |
112 | + [in] img_data_array - 检测图像数据数组 | |
113 | + [in] batch_size - 检测图像批处理个数 | |
114 | + [out] result - 检测结果数组 | |
115 | + * RETURN: 成功(0)或错误(<0) | |
116 | + * NOTES: | |
117 | + *************************************************************************/ | |
118 | + VEHICLE_POSE_API int vehicle_pose_batch(void * handle, sy_img *img_data_array, int batch_size, vehicle_pose_result * result); | |
119 | + | |
120 | + VEHICLE_POSE_API int vehicle_pose_batch_draw(void * handle, sy_img *img_data_array, int batch_size, vehicle_pose_result * result, vehicle_pose_draw_param *draw_param); | |
121 | + | |
122 | +#ifdef _VEHICLE_DET_ | |
123 | + VEHICLE_POSE_API int vehicle_det_pose_process_path(void * handle, char* image_path, vehicle_pose_result *result, int *car_count, vehicle_pose_draw_param draw_param); | |
124 | + VEHICLE_POSE_API int vehicle_det_pose_process(void * handle, sy_img img_data, vehicle_pose_result *result,int *car_count, vehicle_pose_draw_param draw_param); | |
125 | + #endif | |
126 | + /************************************************************************* | |
127 | + * FUNCTION: car_pose_recg_release | |
128 | + * PURPOSE: 资源释放 | |
129 | + * PARAM: | |
130 | + [in] handle - 处理句柄 | |
131 | + * RETURN: NULL | |
132 | + * NOTES: | |
133 | + *************************************************************************/ | |
134 | + VEHICLE_POSE_API void vehicle_pose_release(void ** handle); | |
135 | + | |
136 | + | |
137 | + /************************************************************************* | |
138 | + * FUNCTION: car_pose_recg_get_version | |
139 | + * PURPOSE: 版本返回 | |
140 | + * PARAM: NULL | |
141 | + * RETURN: 版本号 | |
142 | + | |
143 | + * NOTES: | |
144 | + *************************************************************************/ | |
145 | + VEHICLE_POSE_API const char * vehicle_pose_get_version(); | |
146 | + | |
147 | + | |
148 | +#ifdef __cplusplus | |
149 | +}; | |
150 | +#endif | |
151 | +#endif | ... | ... |
src/demo/Makefile
... | ... | @@ -33,7 +33,7 @@ lib_dir=-L/usr/local/Ascend/ascend-toolkit/6.3.RC1/runtime/lib64 \ |
33 | 33 | lib=-lacl_dvpp -lascendcl -lacl_dvpp_mpi -lruntime -lascendalog -lc_sec -lmsprofiler -lgert -lmmpa -lascend_hal -lexe_graph -lge_executor -lgraph -lprofapi -lascend_protobuf -lerror_manager -lhybrid_executor -lregister -ldavinci_executor -lge_common -lge_common_base \ |
34 | 34 | -lplatform -lgraph_base -lqos_manager |
35 | 35 | |
36 | -LIBS= -L $(DEPEND_DIR) -lvpt_det_vdec -lsycheck -lface_det_vdec -lhs_tri_process -lhs_truck_process -lhs_motor_process -lphone_motor_det -lhcp_vdec -lmotor_rainshed_vdec -ltraffic_light_vdec -latlaslic -lvpt_ascend\ | |
36 | +LIBS= -L $(DEPEND_DIR) -lvpt_det_vdec -lsycheck -lface_det_vdec -lhs_tri_process -lhs_truck_process -lhs_motor_process -lphone_motor_det -lhcp_vdec -lmotor_rainshed_vdec -ltraffic_light_vdec -lvehicle_pose_vdec -latlaslic -lvpt_ascend\ | |
37 | 37 | -L $(OPENCV_ROOT)/lib -lopencv_world\ |
38 | 38 | -L $(JSON_ROOT)/lib -ljsoncpp \ |
39 | 39 | -L $(FFMPEG_ROOT)/lib -lavformat -lavcodec -lswscale -lavutil -lavfilter -lswresample -lavdevice \ | ... | ... |