Commit b283714b96d72ee7798f4d546da45cc779390a01
1 parent
d281e3a2
增加机动车不让行功能(516)
Showing
6 changed files
with
100 additions
and
30 deletions
src/ai_engine_module/road_seg_correlation_algor.cpp
... | ... | @@ -19,7 +19,8 @@ namespace ai_engine_module |
19 | 19 | algorithm_type_t::NONMOTOR_CEOSSPARKLINE, |
20 | 20 | algorithm_type_t::PERSON_CROSS, |
21 | 21 | algorithm_type_t::NONMOTOR_WRONGDIRECTION, |
22 | - algorithm_type_t::VEHICLE_WRONGDIRECTION, | |
22 | + algorithm_type_t::VEHICLE_WRONGDIRECTION, | |
23 | + algorithm_type_t::VEHICLE_NOTGIVEWAY, | |
23 | 24 | }; |
24 | 25 | |
25 | 26 | // 判断是否是机动车 |
... | ... | @@ -445,6 +446,8 @@ namespace ai_engine_module |
445 | 446 | std::map<int, int> flattened_idx_to_batch_idx; |
446 | 447 | //! 记录每个box对应的算法以及流id. |
447 | 448 | std::map<unsigned, stream_idx_and_algor_seq_t> flattened_idx_to_algor_seq; |
449 | + // 记录每帧中的行人目标 k:pic index v:data | |
450 | + std::map<int, vector<input_data_wrap_t>> frame_person_data; | |
448 | 451 | |
449 | 452 | /* 1. Crop & keep some interest class. */ |
450 | 453 | auto taskId_iter = taskIds.begin(); |
... | ... | @@ -491,7 +494,7 @@ namespace ai_engine_module |
491 | 494 | continue; |
492 | 495 | |
493 | 496 | stream_idx_and_algor_seq.algors.emplace(algor_type); |
494 | - if (algor_type == algorithm_type_t::VEHICLE_WRONGDIRECTION ) has_vehicle_algor = true; | |
497 | + if (algor_type == algorithm_type_t::VEHICLE_WRONGDIRECTION || algor_type == algorithm_type_t::VEHICLE_NOTGIVEWAY) has_vehicle_algor = true; | |
495 | 498 | } |
496 | 499 | |
497 | 500 | if (stream_idx_and_algor_seq.algors.empty()) |
... | ... | @@ -537,6 +540,12 @@ namespace ai_engine_module |
537 | 540 | flattened_interest_data.emplace_back(std::move(data)); |
538 | 541 | flattened_idx_to_algor_seq[flattened_idx] = std::move(stream_idx_and_algor_seq); |
539 | 542 | flattened_idx_to_batch_idx[flattened_idx++] = n; |
543 | + | |
544 | + // 汇总当前帧的行人目标 | |
545 | + if (static_cast<det_class_label_t>(box.index) == det_class_label_t::HUMAN) { | |
546 | + frame_person_data[n].push_back(data); | |
547 | + } | |
548 | + | |
540 | 549 | } |
541 | 550 | } |
542 | 551 | ++taskId_iter; |
... | ... | @@ -628,7 +637,7 @@ namespace ai_engine_module |
628 | 637 | if ((algor_type == algorithm_type_t::NONMOTOR_IN_VEHICLELANE || algor_type == algorithm_type_t::NONMOTOR_CEOSSPARKLINE || algor_type == algorithm_type_t::NONMOTOR_WRONGDIRECTION) && !is_valid_nomotor(static_cast<det_class_label_t>(det_result.box.cls))) |
629 | 638 | continue; |
630 | 639 | |
631 | - if ((algor_type == algorithm_type_t::VEHICLE_WRONGDIRECTION) && !is_valid_car(static_cast<det_class_label_t>(det_result.box.cls))) | |
640 | + if ((algor_type == algorithm_type_t::VEHICLE_WRONGDIRECTION || algor_type == algorithm_type_t::VEHICLE_NOTGIVEWAY) && !is_valid_car(static_cast<det_class_label_t>(det_result.box.cls))) | |
632 | 641 | continue; |
633 | 642 | |
634 | 643 | auto& e = id_to_mn_[obj_key]; |
... | ... | @@ -707,9 +716,37 @@ namespace ai_engine_module |
707 | 716 | if (!isalarm) continue; |
708 | 717 | } |
709 | 718 | |
719 | + // 机动车不让行:针对人行道区域有行人,车辆不停车的情形 | |
720 | + if (algor_type == algorithm_type_t::VEHICLE_NOTGIVEWAY) { | |
721 | + bool isalarm = false; | |
722 | + int stop_check_frames = 30; // 30 6s | |
723 | + float stop_min_move = 25; | |
724 | + if (m_total_obj_info[trace_obj_key].center_points.size() > stop_check_frames) { //1. 忽略太短轨迹 | |
725 | + for (auto human_data : frame_person_data[flattened_idx_to_batch_idx[n]]) { | |
726 | + tr_point humanpos; | |
727 | + humanpos.x = (human_data.box.left + human_data.box.right) * 0.5; humanpos.y = human_data.box.bottom; | |
728 | + float temp_diff_x = curpos.x-humanpos.x, temp_diff_y = curpos.y-humanpos.y; | |
729 | + float temp_dist = sqrt(temp_diff_x * temp_diff_x + temp_diff_y * temp_diff_y); | |
730 | + //2.查找当前车辆附近的行人:距离小于车宽认为在附近 | |
731 | + if (temp_dist < flattened_imgs[n].w_) { | |
732 | + for (auto region : crosswalk_regions) { | |
733 | + vector<tr_point> tr_boxes = Mbuild_area(region); | |
734 | + bool human_flag = McheckPointPolygon(tr_boxes, humanpos); //3.判断行人是否在人行道 | |
735 | + if (human_flag) { //4.判断行人在人行道时车辆是否停车 | |
736 | + float res_max_dist = 0; | |
737 | + float total_dist = diff_car_pos(m_total_obj_info[trace_obj_key].center_points, stop_check_frames, res_max_dist); | |
738 | + if (res_max_dist > stop_min_move) { isalarm = true; break; } // 未停车--->未礼让 | |
739 | + } | |
740 | + } | |
741 | + } | |
742 | + if (isalarm) break; | |
743 | + } | |
744 | + } | |
745 | + if (!isalarm) continue; | |
746 | + } | |
747 | + | |
710 | 748 | |
711 | 749 | { |
712 | - // if (++e.n_frame == algor_param->n) | |
713 | 750 | if (++e.n_frame == algor_param->n || |
714 | 751 | algor_type == algorithm_type_t::NONMOTOR_CEOSSPARKLINE || algor_type == algorithm_type_t::PERSON_CROSS ) //部分功能当前版本暂不投票 |
715 | 752 | { | ... | ... |
src/ai_platform/MultiSourceProcess.cpp
... | ... | @@ -503,6 +503,9 @@ bool CMultiSourceProcess::task_has_vpt_algor(const std::string &task_id){ |
503 | 503 | algor_map->find(algorithm_type_t::PERSON_RUNNING_REDLIGHTS) != algor_map->end() || |
504 | 504 | algor_map->find(algorithm_type_t::PERSON_CROSS) != algor_map->end() || |
505 | 505 | algor_map->find(algorithm_type_t::VEHICLE_WRONGDIRECTION) != algor_map->end() || |
506 | + algor_map->find(algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND) != algor_map->end() || | |
507 | + algor_map->find(algorithm_type_t::VEHICLE_NOTGIVEWAY) != algor_map->end() || | |
508 | + algor_map->find(algorithm_type_t::VEHICLE_NOTDECELERATION) != algor_map->end() || | |
506 | 509 | algor_map->find(algorithm_type_t::TRICYCLE_MANNED) != algor_map->end() || |
507 | 510 | algor_map->find(algorithm_type_t::TRUCK_MANNED) != algor_map->end()); |
508 | 511 | } |
... | ... | @@ -1643,7 +1646,8 @@ void CMultiSourceProcess::algorithm_roadseg_correlation_process(vector<string>& |
1643 | 1646 | algor_map->find(algorithm_type_t::NONMOTOR_CEOSSPARKLINE) != algor_map->end() || |
1644 | 1647 | algor_map->find(algorithm_type_t::PERSON_CROSS) != algor_map->end() || |
1645 | 1648 | algor_map->find(algorithm_type_t::NONMOTOR_WRONGDIRECTION) != algor_map->end() || |
1646 | - algor_map->find(algorithm_type_t::VEHICLE_WRONGDIRECTION) != algor_map->end() | |
1649 | + algor_map->find(algorithm_type_t::VEHICLE_WRONGDIRECTION) != algor_map->end() || | |
1650 | + algor_map->find(algorithm_type_t::VEHICLE_NOTGIVEWAY) != algor_map->end() | |
1647 | 1651 | ) { |
1648 | 1652 | |
1649 | 1653 | m_RoadSegTaskMtx.lock(); |
... | ... | @@ -1841,7 +1845,7 @@ void CMultiSourceProcess::village_snapshot(vector<string>& vpt_interest_task_id, |
1841 | 1845 | } |
1842 | 1846 | |
1843 | 1847 | vector<algo_type> roadseg_algor = {algorithm_type_t::PERSON_IN_VEHICLELANE, algorithm_type_t::PERSON_CROSS, algorithm_type_t::NONMOTOR_IN_VEHICLELANE, algorithm_type_t::NONMOTOR_CEOSSPARKLINE, |
1844 | - algorithm_type_t::NONMOTOR_WRONGDIRECTION, algorithm_type_t::VEHICLE_WRONGDIRECTION }; | |
1848 | + algorithm_type_t::NONMOTOR_WRONGDIRECTION, algorithm_type_t::VEHICLE_WRONGDIRECTION, algorithm_type_t::VEHICLE_NOTGIVEWAY }; | |
1845 | 1849 | for (size_t idx = 0; idx < roadseg_algor.size(); ++idx) { |
1846 | 1850 | if (algor_param[task_id].count(roadseg_algor.at(idx))) { |
1847 | 1851 | const auto &algor_other_params = task_other_params->find(roadseg_algor.at(idx)); | ... | ... |
src/ai_platform/header.h
... | ... | @@ -56,6 +56,9 @@ enum class algorithm_type_t { |
56 | 56 | PERSON_CROSS = 512, // 行人翻越护栏 |
57 | 57 | NONMOTOR_WRONGDIRECTION = 513, // 非机动车逆行 |
58 | 58 | VEHICLE_WRONGDIRECTION = 514, // 机动车逆行 |
59 | + VEHICLE_SOLIDLINETURNAROUND = 515,// 机动车实线掉头 | |
60 | + VEHICLE_NOTGIVEWAY = 516, // 机动车不让行 | |
61 | + VEHICLE_NOTDECELERATION = 517, // 机动车不减速 | |
59 | 62 | }; |
60 | 63 | |
61 | 64 | ... | ... |
src/ai_platform/task_param_manager.cpp
... | ... | @@ -85,6 +85,9 @@ bool copy_algor_param_aux(const algorithm_type_t &algor_type, const std::string |
85 | 85 | case algorithm_type_t::VEHICLE_WRONGDIRECTION: |
86 | 86 | m_algor_config_params[task_id].vehicle_algors.insert(algor_type); |
87 | 87 | goto _manned_param_copy; |
88 | + case algorithm_type_t::VEHICLE_NOTGIVEWAY: | |
89 | + m_algor_config_params[task_id].vehicle_algors.insert(algor_type); | |
90 | + goto _manned_param_copy; | |
88 | 91 | case algorithm_type_t::TRUCK_MANNED: { |
89 | 92 | m_algor_config_params[task_id].vehicle_algors.insert(algor_type); |
90 | 93 | _manned_param_copy : { | ... | ... |
src/demo/demo.cpp
... | ... | @@ -210,7 +210,7 @@ void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_ty |
210 | 210 | { |
211 | 211 | algor_params->m = 10; |
212 | 212 | algor_params->n = 8; |
213 | - algor_params->hs_count_threshold = 0; | |
213 | + algor_params->hs_count_threshold = 1; | |
214 | 214 | algor_params->obj_confidence_threshold = 0.5f; |
215 | 215 | algor_params->obj_min_height = 6; |
216 | 216 | algor_params->obj_min_width = 32; |
... | ... | @@ -354,7 +354,7 @@ void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_ty |
354 | 354 | algor_init_params->basic_param = basic_params; |
355 | 355 | } break; |
356 | 356 | |
357 | - case algorithm_type_t::VEHICLE_WRONGDIRECTION: { | |
357 | + case algorithm_type_t::VEHICLE_WRONGDIRECTION: { | |
358 | 358 | auto algor_params = new algor_config_param_manned_incident; |
359 | 359 | { |
360 | 360 | algor_params->m = 5; |
... | ... | @@ -375,6 +375,27 @@ void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_ty |
375 | 375 | algor_init_params->basic_param = basic_params; |
376 | 376 | } break; |
377 | 377 | |
378 | + case algorithm_type_t::VEHICLE_NOTGIVEWAY: { | |
379 | + auto algor_params = new algor_config_param_manned_incident; | |
380 | + { | |
381 | + algor_params->m = 10; | |
382 | + algor_params->n = 8; | |
383 | + algor_params->obj_confidence_threshold = 0.5f; | |
384 | + algor_params->obj_min_height = 40; | |
385 | + algor_params->obj_min_width = 40; | |
386 | + } | |
387 | + | |
388 | + auto basic_params = new algor_basic_config_param_t; | |
389 | + { | |
390 | + basic_params->video_folder = "res/video_recode"; | |
391 | + basic_params->result_folder = "res/vehicle_notgiveway"; | |
392 | + basic_params->result_folder_little = "res/vehicle_notgiveway_little"; | |
393 | + } | |
394 | + | |
395 | + algor_init_params->algor_param = algor_params; | |
396 | + algor_init_params->basic_param = basic_params; | |
397 | + } break; | |
398 | + | |
378 | 399 | |
379 | 400 | case algorithm_type_t::FACE_SNAPSHOT: { |
380 | 401 | auto basic_params = new algor_basic_config_param_t; |
... | ... | @@ -1016,8 +1037,8 @@ void test_gpu(int gpuID){ |
1016 | 1037 | |
1017 | 1038 | std::vector<algorithm_type_t> algor_vec2 = {algorithm_type_t::NONMOTOR_VEHICLE_NOHELMET, algorithm_type_t::NONMOTOR_VEHICLE_OVERMAN, algorithm_type_t::TRICYCLE_MANNED, algorithm_type_t::TRUCK_MANNED, algorithm_type_t::NONMOTOR_VEHICLE_USEPHONE, |
1018 | 1039 | algorithm_type_t::NONMOTOR_VEHICLE_REFIT, algorithm_type_t::PERSON_RUNNING_REDLIGHTS, algorithm_type_t::NONMOTOR_RUNNING_REDLIGHTS, algorithm_type_t::PERSON_IN_VEHICLELANE, algorithm_type_t::NONMOTOR_IN_VEHICLELANE, |
1019 | - algorithm_type_t::NONMOTOR_CEOSSPARKLINE, algorithm_type_t::PERSON_CROSS, algorithm_type_t::NONMOTOR_WRONGDIRECTION, algorithm_type_t::VEHICLE_WRONGDIRECTION}; | |
1020 | - std::vector<algorithm_type_t> algor_vec3 = {algorithm_type_t::NONMOTOR_WRONGDIRECTION, algorithm_type_t::VEHICLE_WRONGDIRECTION}; | |
1040 | + algorithm_type_t::NONMOTOR_CEOSSPARKLINE, algorithm_type_t::PERSON_CROSS, algorithm_type_t::NONMOTOR_WRONGDIRECTION, algorithm_type_t::VEHICLE_WRONGDIRECTION, algorithm_type_t::VEHICLE_NOTGIVEWAY}; | |
1041 | + std::vector<algorithm_type_t> algor_vec3 = {algorithm_type_t::PERSON_RUNNING_REDLIGHTS, algorithm_type_t::NONMOTOR_RUNNING_REDLIGHTS}; | |
1021 | 1042 | |
1022 | 1043 | /* |
1023 | 1044 | int repeat_num = 1000; |
... | ... | @@ -1039,22 +1060,22 @@ void test_gpu(int gpuID){ |
1039 | 1060 | // createTask(handle, algor_vec, 1); |
1040 | 1061 | // createTask(handle, algor_vec, 2); |
1041 | 1062 | // createTask(handle, algor_vec, 3); |
1042 | - createTask(handle, algor_vec3, 4); | |
1043 | - createTask(handle, algor_vec3, 5); | |
1044 | - createTask(handle, algor_vec3, 6); | |
1045 | - createTask(handle, algor_vec3, 7); | |
1046 | - createTask(handle, algor_vec3, 8); | |
1047 | - createTask(handle, algor_vec3, 9); | |
1048 | - createTask(handle, algor_vec3, 10); | |
1049 | - createTask(handle, algor_vec3, 11); | |
1050 | - createTask(handle, algor_vec3, 12); | |
1051 | - createTask(handle, algor_vec3, 13); | |
1052 | - createTask(handle, algor_vec3, 14); | |
1053 | - createTask(handle, algor_vec3, 15); | |
1054 | - createTask(handle, algor_vec3, 16); | |
1055 | - createTask(handle, algor_vec3, 17); | |
1056 | - createTask(handle, algor_vec3, 18); | |
1057 | - createTask(handle, algor_vec3, 19); | |
1063 | + createTask(handle, algor_vec2, 4); | |
1064 | + createTask(handle, algor_vec2, 5); | |
1065 | + createTask(handle, algor_vec2, 6); | |
1066 | + createTask(handle, algor_vec2, 7); | |
1067 | + createTask(handle, algor_vec2, 8); | |
1068 | + createTask(handle, algor_vec2, 9); | |
1069 | + createTask(handle, algor_vec2, 10); | |
1070 | + createTask(handle, algor_vec2, 11); | |
1071 | + createTask(handle, algor_vec2, 12); | |
1072 | + createTask(handle, algor_vec2, 13); | |
1073 | + createTask(handle, algor_vec2, 14); | |
1074 | + createTask(handle, algor_vec2, 15); | |
1075 | + createTask(handle, algor_vec2, 16); | |
1076 | + createTask(handle, algor_vec2, 17); | |
1077 | + createTask(handle, algor_vec2, 18); | |
1078 | + createTask(handle, algor_vec2, 19); | |
1058 | 1079 | // createTask(handle, algor_vec2, 20); |
1059 | 1080 | // createTask(handle, algor_vec2, 21); |
1060 | 1081 | // createTask(handle, algor_vec2, 22); | ... | ... |
src/reprocessing_module/snapshot_reprocessing.cpp
... | ... | @@ -393,8 +393,9 @@ void snapshot_reprocessing::update_village_bestsnapshot(vector<DeviceMemory*> ve |
393 | 393 | algor_param[task_id].count(algorithm_type_t::PERSON_RUNNING_REDLIGHTS) || algor_param[task_id].count(algorithm_type_t::NONMOTOR_RUNNING_REDLIGHTS) || |
394 | 394 | algor_param[task_id].count(algorithm_type_t::PERSON_IN_VEHICLELANE) || algor_param[task_id].count(algorithm_type_t::NONMOTOR_IN_VEHICLELANE) || |
395 | 395 | algor_param[task_id].count(algorithm_type_t::NONMOTOR_CEOSSPARKLINE) || algor_param[task_id].count(algorithm_type_t::PERSON_CROSS) || |
396 | - algor_param[task_id].count(algorithm_type_t::NONMOTOR_WRONGDIRECTION) || algor_param[task_id].count(algorithm_type_t::VEHICLE_WRONGDIRECTION) | |
397 | - )) | |
396 | + algor_param[task_id].count(algorithm_type_t::NONMOTOR_WRONGDIRECTION) || algor_param[task_id].count(algorithm_type_t::VEHICLE_WRONGDIRECTION) || | |
397 | + algor_param[task_id].count(algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND) || algor_param[task_id].count(algorithm_type_t::VEHICLE_NOTGIVEWAY) || | |
398 | + algor_param[task_id].count(algorithm_type_t::VEHICLE_NOTDECELERATION))) | |
398 | 399 | continue; |
399 | 400 | |
400 | 401 | if(!snapshot_legal_minarea(index, cur_real_width, cur_real_height)){ |
... | ... | @@ -460,8 +461,9 @@ void snapshot_reprocessing::update_village_bestsnapshot(vector<DeviceMemory*> ve |
460 | 461 | algor_param[task_id].count(algorithm_type_t::PERSON_RUNNING_REDLIGHTS) || algor_param[task_id].count(algorithm_type_t::NONMOTOR_RUNNING_REDLIGHTS) || |
461 | 462 | algor_param[task_id].count(algorithm_type_t::PERSON_IN_VEHICLELANE) || algor_param[task_id].count(algorithm_type_t::NONMOTOR_IN_VEHICLELANE) || |
462 | 463 | algor_param[task_id].count(algorithm_type_t::NONMOTOR_CEOSSPARKLINE) || algor_param[task_id].count(algorithm_type_t::PERSON_CROSS) || |
463 | - algor_param[task_id].count(algorithm_type_t::NONMOTOR_WRONGDIRECTION) || algor_param[task_id].count(algorithm_type_t::VEHICLE_WRONGDIRECTION) | |
464 | - )) | |
464 | + algor_param[task_id].count(algorithm_type_t::NONMOTOR_WRONGDIRECTION) || algor_param[task_id].count(algorithm_type_t::VEHICLE_WRONGDIRECTION) || | |
465 | + algor_param[task_id].count(algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND) || algor_param[task_id].count(algorithm_type_t::VEHICLE_NOTGIVEWAY) || | |
466 | + algor_param[task_id].count(algorithm_type_t::VEHICLE_NOTDECELERATION))) | |
465 | 467 | continue; |
466 | 468 | |
467 | 469 | // 过滤边缘位置 | ... | ... |