Commit 836a7b9c0cf4d51fdd5786724e51ca913e173a46
1 parent
473215b4
-不再保存非最佳抓拍图之外的抓拍小图;不含非机动车道的不判占用机动车道
-增加闯红灯 横穿马路 越过停止线 实线掉头 不让行等不易判别事件的报警图推送
Showing
12 changed files
with
169 additions
and
68 deletions
src/ai_engine_module/ai_engine_header.h
... | ... | @@ -83,4 +83,12 @@ typedef struct result_data_t { |
83 | 83 | acldvppPicDesc* roi_img_desc{nullptr}; |
84 | 84 | } result_data_t; |
85 | 85 | |
86 | + | |
87 | +typedef struct Alarm_Snapshot { | |
88 | + vpc_img_info snapShot; | |
89 | + vpc_img_info snapShotLittle; | |
90 | + int algor_type; | |
91 | + box_t box; | |
92 | +} Alarm_Snapshot; | |
93 | + | |
86 | 94 | } // namespace ai_engine_module | ... | ... |
src/ai_engine_module/motocycle_hs_process.cpp
... | ... | @@ -238,6 +238,7 @@ namespace ai_engine_module |
238 | 238 | data.box.right = right; |
239 | 239 | data.box.bottom = bottom; |
240 | 240 | data.box.score = box.confidence; |
241 | + data.box.cls = box.index; | |
241 | 242 | data.taskId = taskId; |
242 | 243 | data.objId = box.id; |
243 | 244 | // data.id = obj_key_t{ box.id, taskId, algorithm_type_t::TRUCK_MANNED }; | ... | ... |
src/ai_engine_module/motocycle_phone_process.cpp
... | ... | @@ -241,6 +241,7 @@ namespace ai_engine_module |
241 | 241 | data.box.right = right; |
242 | 242 | data.box.bottom = bottom; |
243 | 243 | data.box.score = box.confidence; |
244 | + data.box.cls = box.index; | |
244 | 245 | data.taskId = taskId; |
245 | 246 | data.objId = box.id; |
246 | 247 | // data.id = obj_key_t{ box.id, taskId, algorithm_type_t::TRUCK_MANNED }; | ... | ... |
src/ai_engine_module/motocycle_refit_phone_process.cpp
src/ai_engine_module/motocycle_refit_process.cpp
... | ... | @@ -243,6 +243,7 @@ namespace ai_engine_module |
243 | 243 | data.box.right = right; |
244 | 244 | data.box.bottom = bottom; |
245 | 245 | data.box.score = box.confidence; |
246 | + data.box.cls = box.index; | |
246 | 247 | data.taskId = taskId; |
247 | 248 | data.objId = box.id; |
248 | 249 | // data.id = obj_key_t{ box.id, taskId, algorithm_type_t::TRUCK_MANNED }; | ... | ... |
src/ai_engine_module/road_seg_correlation_algor.cpp
... | ... | @@ -634,7 +634,7 @@ namespace ai_engine_module |
634 | 634 | std::vector<sy_img> flattened_imgs(0); |
635 | 635 | std::vector<vpc_img_info> flattened_vpc_imgs(0); |
636 | 636 | std::vector<input_data_wrap_t> flattened_interest_data(0); // |
637 | - vector<vector<vector<int>>> vehiclelanes_regions, crosswalk_regions, solidlines, roadseg_fence_regions, road_fence_regions; | |
637 | + vector<vector<vector<int>>> vehiclelanes_regions, nonvehicle_regions, crosswalk_regions, solidlines, roadseg_fence_regions, road_fence_regions; | |
638 | 638 | vector<vector<vector<tr_point>>> processed_roadseg_fences; |
639 | 639 | VPCUtil* pVpcUtil = VPCUtil::getInstance(); |
640 | 640 | for (int n = 0; n < n_images; ++n) |
... | ... | @@ -645,6 +645,7 @@ namespace ai_engine_module |
645 | 645 | int src_img_h = src_img->getHeight(); |
646 | 646 | |
647 | 647 | vector<vector<int>> vehiclelanes_region; //机动车区域 |
648 | + vector<vector<int>> nonvehicle_region; //非机动车区域 | |
648 | 649 | vector<vector<int>> crosswalk_region; //人行道+十字路口区域 |
649 | 650 | vector<vector<int>> solidline; //黄实线+白实线 |
650 | 651 | for (unsigned i = 0; i < labels[n].size(); ++i) { |
... | ... | @@ -652,6 +653,10 @@ namespace ai_engine_module |
652 | 653 | if ((label == label_t::vehicle_lanes)) { |
653 | 654 | vector<int> cur_region(traffic_region[n][i].begin(),traffic_region[n][i].end()); |
654 | 655 | vehiclelanes_region.push_back(cur_region); |
656 | + } | |
657 | + if ((label == label_t::nonvehicle_lanes)) { | |
658 | + vector<int> cur_region(traffic_region[n][i].begin(),traffic_region[n][i].end()); | |
659 | + nonvehicle_region.push_back(cur_region); | |
655 | 660 | } |
656 | 661 | if ((label == label_t::crosswalk || label == label_t::interestion_area)) { |
657 | 662 | vector<int> cur_region(traffic_region[n][i].begin(),traffic_region[n][i].end()); |
... | ... | @@ -663,6 +668,7 @@ namespace ai_engine_module |
663 | 668 | } |
664 | 669 | } |
665 | 670 | vehiclelanes_regions.push_back(vehiclelanes_region); |
671 | + nonvehicle_regions.push_back(nonvehicle_region); | |
666 | 672 | crosswalk_regions.push_back(crosswalk_region); |
667 | 673 | solidlines.push_back(solidline); |
668 | 674 | |
... | ... | @@ -733,7 +739,7 @@ namespace ai_engine_module |
733 | 739 | data.box.right = right; data.box.bottom = bottom; |
734 | 740 | data.box.score = box.confidence; data.box.cls = box.index; |
735 | 741 | data.taskId = taskId; data.objId = box.id; |
736 | - | |
742 | +#if 0 | |
737 | 743 | // 抠图 |
738 | 744 | video_object_info obj; |
739 | 745 | strcpy(obj.task_id, taskId.c_str()); |
... | ... | @@ -742,12 +748,12 @@ namespace ai_engine_module |
742 | 748 | obj.right = right; obj.bottom = bottom; |
743 | 749 | |
744 | 750 | vpc_img_info img_info = pVpcUtil->crop(src_img, obj); |
745 | - | |
751 | +#endif | |
746 | 752 | sy_img img; |
747 | 753 | img.w_ = width; |
748 | 754 | img.h_ = height; |
749 | 755 | img.c_ = src_img->getChannel(); |
750 | - | |
756 | +#if 0 | |
751 | 757 | if (img_info.pic_desc != nullptr) { |
752 | 758 | void *outputDataDev = acldvppGetPicDescData(img_info.pic_desc); |
753 | 759 | img.data_ = reinterpret_cast<unsigned char*>(outputDataDev); |
... | ... | @@ -757,12 +763,10 @@ namespace ai_engine_module |
757 | 763 | src_img_w, src_img_h, data.box.left, data.box.top, data.box.right, data.box.bottom); |
758 | 764 | continue; |
759 | 765 | } |
760 | - | |
761 | 766 | |
762 | - | |
763 | - | |
764 | - flattened_imgs.emplace_back(std::move(img)); | |
765 | 767 | flattened_vpc_imgs.emplace_back(std::move(img_info)); |
768 | +#endif | |
769 | + flattened_imgs.emplace_back(std::move(img)); | |
766 | 770 | flattened_interest_data.emplace_back(std::move(data)); |
767 | 771 | flattened_idx_to_algor_seq[flattened_idx] = std::move(stream_idx_and_algor_seq); |
768 | 772 | flattened_idx_to_batch_idx[flattened_idx++] = n; |
... | ... | @@ -813,6 +817,7 @@ namespace ai_engine_module |
813 | 817 | // auto &model_result = model_results[flattened_idx_to_batch_idx[n]]; |
814 | 818 | |
815 | 819 | vector<vector<int>> vehiclelanes_region = vehiclelanes_regions[flattened_idx_to_batch_idx[n]]; //机动车区域 |
820 | + vector<vector<int>> nonvehicle_region = nonvehicle_regions[flattened_idx_to_batch_idx[n]]; //非机动车区域 | |
816 | 821 | vector<vector<int>> crosswalk_region = crosswalk_regions[flattened_idx_to_batch_idx[n]]; //人行道+十字路口区域 |
817 | 822 | vector<vector<int>> solidline = solidlines[flattened_idx_to_batch_idx[n]]; //黄实线+白实线 |
818 | 823 | vector<vector<int>> roadseg_fence_region = roadseg_fence_regions[flattened_idx_to_batch_idx[n]];//车道分割护栏区域 |
... | ... | @@ -856,6 +861,7 @@ namespace ai_engine_module |
856 | 861 | int src_w = src_img->getWidth(), src_h = src_img->getHeight(); |
857 | 862 | // 行人/非机动车占用机动车道 |
858 | 863 | if (algor_type == algorithm_type_t::PERSON_IN_VEHICLELANE || algor_type == algorithm_type_t::NONMOTOR_IN_VEHICLELANE) { |
864 | + if (nonvehicle_region.empty()) continue; //没有非机动车道的不判占用机动车道 | |
859 | 865 | bool isalarm = false; |
860 | 866 | float res_max_dist = 0; |
861 | 867 | int check_frames = m_total_obj_info[trace_obj_key].center_points.size(); |
... | ... | @@ -1062,10 +1068,12 @@ namespace ai_engine_module |
1062 | 1068 | result.taskId = det_result.taskId; |
1063 | 1069 | result.objId = det_result.objId; |
1064 | 1070 | result.algor_type = algor_type; |
1065 | -#if 0 /*暂不保存报警时刻的抓拍图,有需要再启用*/ | |
1071 | +#if 1 /*抓拍大图*/ | |
1066 | 1072 | // 原图 |
1067 | 1073 | vpc_img_info src_img_info = VPCUtil::vpc_devMem2vpcImg(src_img); |
1068 | 1074 | result.origin_img_desc = src_img_info.pic_desc; |
1075 | +#endif | |
1076 | +#if 0 /*暂不保存报警时刻的抓拍小图,有需要再启用*/ | |
1069 | 1077 | // 抠图--拷贝后赋值 |
1070 | 1078 | void *outputDataDev = acldvppGetPicDescData(flattened_vpc_imgs[n].pic_desc); |
1071 | 1079 | int nBufferSize = acldvppGetPicDescSize(flattened_vpc_imgs[n].pic_desc); |
... | ... | @@ -1098,9 +1106,9 @@ namespace ai_engine_module |
1098 | 1106 | e.reset(); |
1099 | 1107 | |
1100 | 1108 | } |
1101 | - | |
1109 | +#if 0 | |
1102 | 1110 | VPCUtil::vpc_img_release(flattened_vpc_imgs[n]); //flattened_imgs[n].data_ |
1103 | - | |
1111 | +#endif | |
1104 | 1112 | } |
1105 | 1113 | /* |
1106 | 1114 | for (int n = 0; n < n_input_image; ++n) | ... | ... |
src/ai_engine_module/traffic_light_process.cpp
... | ... | @@ -470,7 +470,7 @@ namespace ai_engine_module |
470 | 470 | data.box.right = right; data.box.bottom = bottom; |
471 | 471 | data.box.score = box.confidence; data.box.cls = box.index; |
472 | 472 | data.taskId = taskId; data.objId = box.id; |
473 | - | |
473 | +#if 0 | |
474 | 474 | // 抠图 |
475 | 475 | video_object_info obj; |
476 | 476 | strcpy(obj.task_id, taskId.c_str()); |
... | ... | @@ -479,12 +479,12 @@ namespace ai_engine_module |
479 | 479 | obj.right = right; obj.bottom = bottom; |
480 | 480 | |
481 | 481 | vpc_img_info img_info = pVpcUtil->crop(src_img, obj); |
482 | - | |
482 | +#endif | |
483 | 483 | sy_img img; |
484 | 484 | img.w_ = width; |
485 | 485 | img.h_ = height; |
486 | 486 | img.c_ = src_img->getChannel(); |
487 | - | |
487 | +#if 0 | |
488 | 488 | if (img_info.pic_desc != nullptr) { |
489 | 489 | void *outputDataDev = acldvppGetPicDescData(img_info.pic_desc); |
490 | 490 | img.data_ = reinterpret_cast<unsigned char*>(outputDataDev); |
... | ... | @@ -495,8 +495,9 @@ namespace ai_engine_module |
495 | 495 | continue; |
496 | 496 | } |
497 | 497 | |
498 | - flattened_imgs.emplace_back(std::move(img)); | |
499 | 498 | flattened_vpc_imgs.emplace_back(std::move(img_info)); |
499 | +#endif | |
500 | + flattened_imgs.emplace_back(std::move(img)); | |
500 | 501 | flattened_interest_data.emplace_back(std::move(data)); |
501 | 502 | flattened_idx_to_algor_seq[flattened_idx] = std::move(stream_idx_and_algor_seq); |
502 | 503 | flattened_idx_to_batch_idx[flattened_idx++] = n; |
... | ... | @@ -544,7 +545,7 @@ namespace ai_engine_module |
544 | 545 | const label_t label = static_cast<label_t>(box.index); |
545 | 546 | if (!is_valid_label(label)) |
546 | 547 | continue; |
547 | - // if (box.left < 1200 || box.top < 159 || box.right > 1307 || box.bottom > 212) continue; // 限制红绿灯的出现位置(泰兴黄桥锦润福府路口) | |
548 | + if (box.left < 1200 || box.top < 159 || box.right > 1307 || box.bottom > 212) continue; // 限制红绿灯的出现位置(泰兴黄桥锦润福府路口)==================24.1.3 | |
548 | 549 | LOG_TRACE("task id is {} obj_id {} label {} index {} score {}", task_id, objId, label, box.index, box.confidence); |
549 | 550 | red_cnt ++; |
550 | 551 | } |
... | ... | @@ -622,10 +623,12 @@ namespace ai_engine_module |
622 | 623 | result.taskId = det_result.taskId; |
623 | 624 | result.objId = det_result.objId; |
624 | 625 | result.algor_type = algor_type; |
625 | -#if 0 /*暂不保存报警时刻的抓拍图,有需要再启用*/ | |
626 | +#if 1 /*抓拍大图*/ | |
626 | 627 | // 原图 |
627 | 628 | vpc_img_info src_img_info = VPCUtil::vpc_devMem2vpcImg(src_img); |
628 | 629 | result.origin_img_desc = src_img_info.pic_desc; |
630 | +#endif | |
631 | +#if 0 /*暂不保存报警时刻的抓拍图,有需要再启用*/ | |
629 | 632 | // 抠图--拷贝后赋值 |
630 | 633 | void *outputDataDev = acldvppGetPicDescData(flattened_vpc_imgs[n].pic_desc); |
631 | 634 | int nBufferSize = acldvppGetPicDescSize(flattened_vpc_imgs[n].pic_desc); |
... | ... | @@ -658,9 +661,9 @@ namespace ai_engine_module |
658 | 661 | e.reset(); |
659 | 662 | |
660 | 663 | } |
661 | - | |
664 | +#if 0 | |
662 | 665 | VPCUtil::vpc_img_release(flattened_vpc_imgs[n]); //flattened_imgs[n].data_ |
663 | - | |
666 | +#endif | |
664 | 667 | } |
665 | 668 | } |
666 | 669 | ... | ... |
src/ai_engine_module/tricycle_manned_process.cpp
src/ai_engine_module/truck_manned_process.cpp
... | ... | @@ -302,7 +302,7 @@ namespace ai_engine_module |
302 | 302 | |
303 | 303 | data.box.top = top; data.box.left = left; |
304 | 304 | data.box.right = right; data.box.bottom = bottom; |
305 | - data.box.score = box.confidence; | |
305 | + data.box.score = box.confidence; data.box.cls = box.index; | |
306 | 306 | data.taskId = taskId; data.objId = box.id; |
307 | 307 | data.id = obj_key_t{ box.id, taskId, algorithm_type_t::TRUCK_MANNED }; |
308 | 308 | data.person_motocycle_cnt = person_motocycle_inarea; | ... | ... |
src/ai_platform/MultiSourceProcess.cpp
... | ... | @@ -1658,7 +1658,8 @@ void CMultiSourceProcess::village_snapshot(vector<string>& vpt_interest_task_id, |
1658 | 1658 | std::string video_folder = "", result_folder = "", result_folder_little = ""; //要求各事件使用同一个视频保存地址,否则会被最后一个事件的地址覆盖 |
1659 | 1659 | auto task_other_params = m_task_param_manager->get_task_other_param(task_id); |
1660 | 1660 | std::vector<int> algorithm_types; |
1661 | - bool save_single_algor_pic = false; // 是否保存单算法的报警图片(若设置为true需先去掉算法内部注释!!!) | |
1661 | + std::vector<ai_engine_module::Alarm_Snapshot> alarm_snapshots; | |
1662 | + bool save_single_algor_pic = true; // 是否保存单算法的报警图片(若设置为true需先去掉算法内部注释!!!) | |
1662 | 1663 | |
1663 | 1664 | if (task_param_ptr->nonmotor_vehicle_algors.find(algorithm_type_t::TRICYCLE_MANNED) != task_param_ptr->nonmotor_vehicle_algors.end()) { |
1664 | 1665 | const auto &algor_other_params = task_other_params->find(algorithm_type_t::TRICYCLE_MANNED); |
... | ... | @@ -1673,9 +1674,11 @@ void CMultiSourceProcess::village_snapshot(vector<string>& vpt_interest_task_id, |
1673 | 1674 | vpc_img_info src_img; src_img.pic_desc = result->origin_img_desc; src_img.task_id = obj_key.video_id; |
1674 | 1675 | vpc_img_info roi_img; roi_img.pic_desc = result->roi_img_desc; roi_img.task_id = obj_key.video_id; roi_img.object_id = obj_key.obj_id; |
1675 | 1676 | |
1676 | - if (save_single_algor_pic) { | |
1677 | - auto json_str = helpers::gen_json::gen_manned_json(obj_key.video_id, obj_key.obj_id, result->box, algorithm_type_t::TRICYCLE_MANNED); | |
1678 | - save_snapshot_process(obj_key, algorithm_type_t::TRICYCLE_MANNED, src_img, roi_img, 0, json_str); | |
1677 | + // if (save_single_algor_pic) { | |
1678 | + if (0) { | |
1679 | + ai_engine_module::Alarm_Snapshot alarm_snapshot; alarm_snapshot.algor_type = (int)algorithm_type_t::TRICYCLE_MANNED; | |
1680 | + alarm_snapshot.snapShot = src_img; alarm_snapshot.snapShotLittle = roi_img; alarm_snapshot.box = result->box; | |
1681 | + alarm_snapshots.push_back(alarm_snapshot); | |
1679 | 1682 | } else { |
1680 | 1683 | VPCUtil::vpc_img_release(src_img); VPCUtil::vpc_img_release(roi_img); |
1681 | 1684 | } |
... | ... | @@ -1696,9 +1699,11 @@ void CMultiSourceProcess::village_snapshot(vector<string>& vpt_interest_task_id, |
1696 | 1699 | vpc_img_info src_img; src_img.pic_desc = result->origin_img_desc; src_img.task_id = obj_key.video_id; |
1697 | 1700 | vpc_img_info roi_img; roi_img.pic_desc = result->roi_img_desc; roi_img.task_id = obj_key.video_id; roi_img.object_id = obj_key.obj_id; |
1698 | 1701 | |
1699 | - if (save_single_algor_pic) { | |
1700 | - auto json_str = helpers::gen_json::gen_manned_json(obj_key.video_id, obj_key.obj_id, result->box, algorithm_type_t::TRUCK_MANNED); | |
1701 | - save_snapshot_process(obj_key, algorithm_type_t::TRUCK_MANNED, src_img, roi_img, 0, json_str); | |
1702 | + // if (save_single_algor_pic) { | |
1703 | + if (0) { | |
1704 | + ai_engine_module::Alarm_Snapshot alarm_snapshot; alarm_snapshot.algor_type = (int)algorithm_type_t::TRUCK_MANNED; | |
1705 | + alarm_snapshot.snapShot = src_img; alarm_snapshot.snapShotLittle = roi_img; alarm_snapshot.box = result->box; | |
1706 | + alarm_snapshots.push_back(alarm_snapshot); | |
1702 | 1707 | } else { |
1703 | 1708 | VPCUtil::vpc_img_release(src_img); VPCUtil::vpc_img_release(roi_img); |
1704 | 1709 | } |
... | ... | @@ -1721,9 +1726,11 @@ void CMultiSourceProcess::village_snapshot(vector<string>& vpt_interest_task_id, |
1721 | 1726 | vpc_img_info src_img; src_img.pic_desc = result->origin_img_desc; src_img.task_id = obj_key.video_id; |
1722 | 1727 | vpc_img_info roi_img; roi_img.pic_desc = result->roi_img_desc; roi_img.task_id = obj_key.video_id; roi_img.object_id = obj_key.obj_id; |
1723 | 1728 | |
1724 | - if (save_single_algor_pic) { | |
1725 | - auto json_str = helpers::gen_json::gen_manned_json(obj_key.video_id, obj_key.obj_id, result->box, motorhs_algor.at(idx)); | |
1726 | - save_snapshot_process(obj_key, motorhs_algor.at(idx), src_img, roi_img, 0, json_str); | |
1729 | + // if (save_single_algor_pic) { | |
1730 | + if (0) { | |
1731 | + ai_engine_module::Alarm_Snapshot alarm_snapshot; alarm_snapshot.algor_type = (int)motorhs_algor.at(idx); | |
1732 | + alarm_snapshot.snapShot = src_img; alarm_snapshot.snapShotLittle = roi_img; alarm_snapshot.box = result->box; | |
1733 | + alarm_snapshots.push_back(alarm_snapshot); | |
1727 | 1734 | } else { |
1728 | 1735 | VPCUtil::vpc_img_release(src_img); VPCUtil::vpc_img_release(roi_img); |
1729 | 1736 | } |
... | ... | @@ -1746,9 +1753,11 @@ void CMultiSourceProcess::village_snapshot(vector<string>& vpt_interest_task_id, |
1746 | 1753 | vpc_img_info src_img; src_img.pic_desc = result->origin_img_desc; src_img.task_id = obj_key.video_id; |
1747 | 1754 | vpc_img_info roi_img; roi_img.pic_desc = result->roi_img_desc; roi_img.task_id = obj_key.video_id; roi_img.object_id = obj_key.obj_id; |
1748 | 1755 | |
1749 | - if (save_single_algor_pic) { | |
1750 | - auto json_str = helpers::gen_json::gen_manned_json(obj_key.video_id, obj_key.obj_id, result->box, algorithm_type_t::NONMOTOR_VEHICLE_USEPHONE); | |
1751 | - save_snapshot_process(obj_key, algorithm_type_t::NONMOTOR_VEHICLE_USEPHONE, src_img, roi_img, 0, json_str); | |
1756 | + // if (save_single_algor_pic) { | |
1757 | + if (0) { | |
1758 | + ai_engine_module::Alarm_Snapshot alarm_snapshot; alarm_snapshot.algor_type = (int)algorithm_type_t::NONMOTOR_VEHICLE_USEPHONE; | |
1759 | + alarm_snapshot.snapShot = src_img; alarm_snapshot.snapShotLittle = roi_img; alarm_snapshot.box = result->box; | |
1760 | + alarm_snapshots.push_back(alarm_snapshot); | |
1752 | 1761 | } else { |
1753 | 1762 | VPCUtil::vpc_img_release(src_img); VPCUtil::vpc_img_release(roi_img); |
1754 | 1763 | } |
... | ... | @@ -1770,9 +1779,11 @@ void CMultiSourceProcess::village_snapshot(vector<string>& vpt_interest_task_id, |
1770 | 1779 | vpc_img_info src_img; src_img.pic_desc = result->origin_img_desc; src_img.task_id = obj_key.video_id; |
1771 | 1780 | vpc_img_info roi_img; roi_img.pic_desc = result->roi_img_desc; roi_img.task_id = obj_key.video_id; roi_img.object_id = obj_key.obj_id; |
1772 | 1781 | |
1773 | - if (save_single_algor_pic) { | |
1774 | - auto json_str = helpers::gen_json::gen_manned_json(obj_key.video_id, obj_key.obj_id, result->box, algorithm_type_t::NONMOTOR_VEHICLE_REFIT); | |
1775 | - save_snapshot_process(obj_key, algorithm_type_t::NONMOTOR_VEHICLE_REFIT, src_img, roi_img, 0, json_str); | |
1782 | + // if (save_single_algor_pic) { | |
1783 | + if (0) { | |
1784 | + ai_engine_module::Alarm_Snapshot alarm_snapshot; alarm_snapshot.algor_type = (int)algorithm_type_t::NONMOTOR_VEHICLE_REFIT; | |
1785 | + alarm_snapshot.snapShot = src_img; alarm_snapshot.snapShotLittle = roi_img; alarm_snapshot.box = result->box; | |
1786 | + alarm_snapshots.push_back(alarm_snapshot); | |
1776 | 1787 | } else { |
1777 | 1788 | VPCUtil::vpc_img_release(src_img); VPCUtil::vpc_img_release(roi_img); |
1778 | 1789 | } |
... | ... | @@ -1796,8 +1807,11 @@ void CMultiSourceProcess::village_snapshot(vector<string>& vpt_interest_task_id, |
1796 | 1807 | vpc_img_info roi_img; roi_img.pic_desc = result->roi_img_desc; roi_img.task_id = obj_key.video_id; roi_img.object_id = obj_key.obj_id; |
1797 | 1808 | |
1798 | 1809 | if (save_single_algor_pic) { |
1799 | - auto json_str = helpers::gen_json::gen_manned_json(obj_key.video_id, obj_key.obj_id, result->box, trafficlight_algor.at(idx)); | |
1800 | - save_snapshot_process(obj_key, trafficlight_algor.at(idx), src_img, roi_img, 0, json_str); | |
1810 | + // auto json_str = helpers::gen_json::gen_manned_json(obj_key.video_id, obj_key.obj_id, result->box, trafficlight_algor.at(idx)); | |
1811 | + // save_snapshot_process(obj_key, trafficlight_algor.at(idx), src_img, roi_img, 0, json_str); | |
1812 | + ai_engine_module::Alarm_Snapshot alarm_snapshot; alarm_snapshot.algor_type = (int)trafficlight_algor.at(idx); | |
1813 | + alarm_snapshot.snapShot = src_img; alarm_snapshot.snapShotLittle = roi_img; alarm_snapshot.box = result->box; | |
1814 | + alarm_snapshots.push_back(alarm_snapshot); | |
1801 | 1815 | } else { |
1802 | 1816 | VPCUtil::vpc_img_release(src_img); VPCUtil::vpc_img_release(roi_img); |
1803 | 1817 | } |
... | ... | @@ -1822,9 +1836,11 @@ void CMultiSourceProcess::village_snapshot(vector<string>& vpt_interest_task_id, |
1822 | 1836 | vpc_img_info src_img; src_img.pic_desc = result->origin_img_desc; src_img.task_id = obj_key.video_id; |
1823 | 1837 | vpc_img_info roi_img; roi_img.pic_desc = result->roi_img_desc; roi_img.task_id = obj_key.video_id; roi_img.object_id = obj_key.obj_id; |
1824 | 1838 | |
1825 | - if (save_single_algor_pic) { | |
1826 | - auto json_str = helpers::gen_json::gen_manned_json(obj_key.video_id, obj_key.obj_id, result->box, roadseg_algor.at(idx)); | |
1827 | - save_snapshot_process(obj_key, roadseg_algor.at(idx), src_img, roi_img, 0, json_str); | |
1839 | + if (save_single_algor_pic && (roadseg_algor.at(idx) == algorithm_type_t::PERSON_CROSS || roadseg_algor.at(idx) == algorithm_type_t::NONMOTOR_CEOSSPARKLINE || | |
1840 | + roadseg_algor.at(idx) == algorithm_type_t::VEHICLE_NOTGIVEWAY || roadseg_algor.at(idx) == algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND)) { | |
1841 | + ai_engine_module::Alarm_Snapshot alarm_snapshot; alarm_snapshot.algor_type = (int)roadseg_algor.at(idx); | |
1842 | + alarm_snapshot.snapShot = src_img; alarm_snapshot.snapShotLittle = roi_img; alarm_snapshot.box = result->box; | |
1843 | + alarm_snapshots.push_back(alarm_snapshot); | |
1828 | 1844 | } else { |
1829 | 1845 | VPCUtil::vpc_img_release(src_img); VPCUtil::vpc_img_release(roi_img); |
1830 | 1846 | } |
... | ... | @@ -1842,13 +1858,21 @@ void CMultiSourceProcess::village_snapshot(vector<string>& vpt_interest_task_id, |
1842 | 1858 | |
1843 | 1859 | |
1844 | 1860 | map<OBJ_KEY, OBJ_VALUES> _total_snapshot_info = m_snapshot_reprocessing->get_total_village_snapshot_info(); |
1845 | - if(_total_snapshot_info.size() <= 0){ | |
1861 | + if(_total_snapshot_info.size() <= 0) { | |
1862 | + for (int sp_idx = 0; sp_idx < alarm_snapshots.size(); sp_idx ++) { | |
1863 | + VPCUtil::vpc_img_release(alarm_snapshots[sp_idx].snapShot); | |
1864 | + VPCUtil::vpc_img_release(alarm_snapshots[sp_idx].snapShotLittle); | |
1865 | + } | |
1846 | 1866 | continue; |
1847 | 1867 | } |
1848 | 1868 | |
1849 | 1869 | LOG_DEBUG("_total_snapshot_info size: {}", _total_snapshot_info.size()); |
1850 | 1870 | auto it = _total_snapshot_info.find(obj_key); |
1851 | 1871 | if (it == _total_snapshot_info.end()) { |
1872 | + for (int sp_idx = 0; sp_idx < alarm_snapshots.size(); sp_idx ++) { | |
1873 | + VPCUtil::vpc_img_release(alarm_snapshots[sp_idx].snapShot); | |
1874 | + VPCUtil::vpc_img_release(alarm_snapshots[sp_idx].snapShotLittle); | |
1875 | + } | |
1852 | 1876 | continue; |
1853 | 1877 | } |
1854 | 1878 | |
... | ... | @@ -1883,6 +1907,7 @@ void CMultiSourceProcess::village_snapshot(vector<string>& vpt_interest_task_id, |
1883 | 1907 | |
1884 | 1908 | string json_str = ""; |
1885 | 1909 | std::vector<video_object_snapshot> algo_results; |
1910 | + // 存轨迹抓拍图 | |
1886 | 1911 | for (int sp_idx = 0; sp_idx < 3; sp_idx ++) { |
1887 | 1912 | int num = sp_idx + 1; |
1888 | 1913 | // 原图 |
... | ... | @@ -1899,12 +1924,15 @@ void CMultiSourceProcess::village_snapshot(vector<string>& vpt_interest_task_id, |
1899 | 1924 | |
1900 | 1925 | LOG_DEBUG("抠图"); |
1901 | 1926 | // 抠图 |
1902 | - string object_file_name = result_folder_little + helpers::os::sep + obj_key.video_id + "_" + | |
1903 | - std::to_string(obj_key.obj_id) + "_" + cur_timestamp_ms + "_picnum_" + std::to_string(num) + ".jpg"; | |
1904 | - ImgSaveInfo obj_save_info; | |
1905 | - obj_save_info.file_path = object_file_name; | |
1906 | - obj_save_info.img_info = obj_value.snapShots[sp_idx].snapShotLittle; | |
1907 | - m_save_snapshot_reprocessing->reprocessing_process_wo_locus_async(obj_save_info); | |
1927 | + string object_file_name = ""; | |
1928 | + if (num == 2) { //暂不存最佳抓拍之外的小图,注意和update_village_bestsnapshot对应 | |
1929 | + object_file_name = result_folder_little + helpers::os::sep + obj_key.video_id + "_" + | |
1930 | + std::to_string(obj_key.obj_id) + "_" + cur_timestamp_ms + "_picnum_" + std::to_string(num) + ".jpg"; | |
1931 | + ImgSaveInfo obj_save_info; | |
1932 | + obj_save_info.file_path = object_file_name; | |
1933 | + obj_save_info.img_info = obj_value.snapShots[sp_idx].snapShotLittle; | |
1934 | + m_save_snapshot_reprocessing->reprocessing_process_wo_locus_async(obj_save_info); | |
1935 | + } | |
1908 | 1936 | |
1909 | 1937 | #ifdef POST_USE_RABBITMQ |
1910 | 1938 | video_object_snapshot new_obj_ss_info; |
... | ... | @@ -1920,6 +1948,44 @@ void CMultiSourceProcess::village_snapshot(vector<string>& vpt_interest_task_id, |
1920 | 1948 | #endif |
1921 | 1949 | } |
1922 | 1950 | |
1951 | + // 存报警抓拍图 | |
1952 | + for (int sp_idx = 0; sp_idx < alarm_snapshots.size(); sp_idx ++) { | |
1953 | + int num = sp_idx + 4; | |
1954 | + // 原图 | |
1955 | + std::string fpath_origin = result_folder + helpers::os::sep + obj_key.video_id + "_" + std::to_string(obj_key.obj_id) + "_" + | |
1956 | + cur_timestamp_ms + "_picnum_" + std::to_string(num) + "_" + std::to_string(alarm_snapshots[sp_idx].algor_type) + ".jpg"; | |
1957 | + | |
1958 | + ImgSaveInfo origin_save_info; | |
1959 | + origin_save_info.file_path = fpath_origin; | |
1960 | + origin_save_info.img_info = alarm_snapshots[sp_idx].snapShot; | |
1961 | + m_save_snapshot_reprocessing->reprocessing_process_wo_locus_async(origin_save_info); | |
1962 | + | |
1963 | +#if 1 /*不保存抠图*/ | |
1964 | + string object_file_name = ""; | |
1965 | +#else | |
1966 | + // 抠图 | |
1967 | + string object_file_name = result_folder_little + helpers::os::sep + obj_key.video_id + "_" + std::to_string(obj_key.obj_id) + "_" + | |
1968 | + cur_timestamp_ms + "_picnum_" + std::to_string(num) + "_" + std::to_string(alarm_snapshots[sp_idx].algor_type) + ".jpg"; | |
1969 | + ImgSaveInfo obj_save_info; | |
1970 | + obj_save_info.file_path = object_file_name; | |
1971 | + obj_save_info.img_info = alarm_snapshots[sp_idx].snapShotLittle; | |
1972 | + m_save_snapshot_reprocessing->reprocessing_process_wo_locus_async(obj_save_info); | |
1973 | +#endif | |
1974 | + | |
1975 | +#ifdef POST_USE_RABBITMQ | |
1976 | + video_object_snapshot new_obj_ss_info; | |
1977 | + new_obj_ss_info.analysisRes = nullptr; | |
1978 | + new_obj_ss_info.object_id = obj_key.obj_id; | |
1979 | + new_obj_ss_info.obj_info.set_data(alarm_snapshots[sp_idx].box.cls, alarm_snapshots[sp_idx].box.score, alarm_snapshots[sp_idx].box.left, | |
1980 | + alarm_snapshots[sp_idx].box.top, alarm_snapshots[sp_idx].box.right, alarm_snapshots[sp_idx].box.bottom); | |
1981 | + strcpy(new_obj_ss_info.task_id, obj_key.video_id.c_str()); | |
1982 | + strcpy(new_obj_ss_info.video_image_path, fpath_origin.c_str()); | |
1983 | + strcpy(new_obj_ss_info.snapshot_image_path, object_file_name.c_str()); | |
1984 | + algo_results.push_back(new_obj_ss_info); | |
1985 | +#endif | |
1986 | + } | |
1987 | + std::vector<ai_engine_module::Alarm_Snapshot>().swap(alarm_snapshots); | |
1988 | + | |
1923 | 1989 | #ifdef POST_USE_RABBITMQ |
1924 | 1990 | json_str = helpers::gen_json::gen_village_json(task_id, obj_key.obj_id, algorithm_types, algo_results, video_file_name); |
1925 | 1991 | #endif | ... | ... |
src/demo/demo.cpp
... | ... | @@ -12,23 +12,23 @@ using namespace std; |
12 | 12 | void init_mq_conn(void *handle) { |
13 | 13 | for (auto key : {mq_type_t::ALARM_MQ, mq_type_t::GET_TASK_MQ, mq_type_t::HEART_BEAT_MQ, mq_type_t::SCREENSHORT_TASK_MQ, mq_type_t::TIMING_SCREENSHORT_TASK_MQ}) { |
14 | 14 | rabbitmq_conn_params_t mq_conn_params; |
15 | - mq_conn_params.port = 5672; | |
16 | 15 | |
17 | - strcpy(mq_conn_params.ip, "192.168.60.126"); | |
18 | - strcpy(mq_conn_params.uname, "admin"); | |
19 | - strcpy(mq_conn_params.passwd, "123456"); | |
20 | - strcpy(mq_conn_params.vhost, "/"); | |
21 | - strcpy(mq_conn_params.exchange, "topExchange"); | |
22 | - strcpy(mq_conn_params.exchange_type, "topic"); | |
23 | - | |
24 | - // mq_conn_params.port = 5673; | |
25 | - // strcpy(mq_conn_params.ip, "192.168.10.187"); | |
16 | + // mq_conn_params.port = 5672; | |
17 | + // strcpy(mq_conn_params.ip, "192.168.60.126"); | |
26 | 18 | // strcpy(mq_conn_params.uname, "admin"); |
27 | - // strcpy(mq_conn_params.passwd, "admin123456"); | |
19 | + // strcpy(mq_conn_params.passwd, "123456"); | |
28 | 20 | // strcpy(mq_conn_params.vhost, "/"); |
29 | 21 | // strcpy(mq_conn_params.exchange, "topExchange"); |
30 | 22 | // strcpy(mq_conn_params.exchange_type, "topic"); |
31 | 23 | |
24 | + mq_conn_params.port = 5673; | |
25 | + strcpy(mq_conn_params.ip, "192.168.10.187"); | |
26 | + strcpy(mq_conn_params.uname, "admin"); | |
27 | + strcpy(mq_conn_params.passwd, "admin123456"); | |
28 | + strcpy(mq_conn_params.vhost, "/"); | |
29 | + strcpy(mq_conn_params.exchange, "topExchange"); | |
30 | + strcpy(mq_conn_params.exchange_type, "topic"); | |
31 | + | |
32 | 32 | switch (key) { |
33 | 33 | case mq_type_t::ALARM_MQ: { |
34 | 34 | strcpy(mq_conn_params.queue, "topic.queue.alarm"); |
... | ... | @@ -1121,7 +1121,7 @@ void test_gpu(int gpuID){ |
1121 | 1121 | std::vector<algorithm_type_t> algor_vec3 = {algorithm_type_t::PERSON_CROSS, algorithm_type_t::NONMOTOR_WRONGDIRECTION, algorithm_type_t::VEHICLE_WRONGDIRECTION, algorithm_type_t::VEHICLE_NOTGIVEWAY, |
1122 | 1122 | algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND}; |
1123 | 1123 | |
1124 | - | |
1124 | +/* | |
1125 | 1125 | int repeat_num = 1000; |
1126 | 1126 | createTask(handle, algor_vec2, 0, false); |
1127 | 1127 | createTask(handle, algor_vec2, 2, false); |
... | ... | @@ -1141,9 +1141,9 @@ void test_gpu(int gpuID){ |
1141 | 1141 | sleep(5); |
1142 | 1142 | } |
1143 | 1143 | |
1144 | - } | |
1144 | + }*/ | |
1145 | 1145 | |
1146 | - /* | |
1146 | + | |
1147 | 1147 | char ch = 'a'; |
1148 | 1148 | while (ch != 'q') { |
1149 | 1149 | ch = getchar(); |
... | ... | @@ -1153,10 +1153,10 @@ void test_gpu(int gpuID){ |
1153 | 1153 | createTask(handle, algor_vec2, 4, false); |
1154 | 1154 | createTask(handle, algor_vec2, 5, false); |
1155 | 1155 | createTask(handle, algor_vec2, 6, false); |
1156 | - createTask(handle, algor_vec2, 7, false); | |
1156 | + // createTask(handle, algor_vec2, 7, false); | |
1157 | 1157 | createTask(handle, algor_vec2, 8, false); |
1158 | 1158 | createTask(handle, algor_vec2, 9, false); |
1159 | - createTask(handle, algor_vec2, 10, false); | |
1159 | + // createTask(handle, algor_vec2, 10, false); | |
1160 | 1160 | // createTask(handle, algor_vec2, 11, false); |
1161 | 1161 | // createTask(handle, algor_vec2, 12, false); |
1162 | 1162 | // createTask(handle, algor_vec2, 13, false); |
... | ... | @@ -1173,7 +1173,7 @@ void test_gpu(int gpuID){ |
1173 | 1173 | break; |
1174 | 1174 | } |
1175 | 1175 | |
1176 | - }*/ | |
1176 | + } | |
1177 | 1177 | |
1178 | 1178 | // finish_task(handle, (char*)task_id.data(), 0); |
1179 | 1179 | ... | ... |
src/reprocessing_module/snapshot_reprocessing.cpp
... | ... | @@ -435,20 +435,25 @@ void snapshot_reprocessing::update_village_bestsnapshot(vector<DeviceMemory*> ve |
435 | 435 | vec_obj_info.push_back(info);//用于最佳抓拍图 |
436 | 436 | |
437 | 437 | // 首张抓拍图:切图+信息存储 |
438 | - vpc_img_info crop_img = pVpcUtil->crop(memPtr, info); | |
439 | 438 | total_village_snapshot_info[new_obj].exists[0] = true; |
440 | 439 | total_village_snapshot_info[new_obj].snapShots[0].index.index = cur_real_index; |
441 | 440 | total_village_snapshot_info[new_obj].snapShots[0].confidence = obj_info.confidence; |
442 | 441 | total_village_snapshot_info[new_obj].snapShots[0].obj_pos = { cur_left, cur_top, cur_right - cur_left, cur_bottom - cur_top }; |
443 | 442 | total_village_snapshot_info[new_obj].snapShots[0].snapShot = VPCUtil::vpc_devMem2vpcImg(memPtr); |
443 | +#if 0 /*暂不存最佳抓拍之外的小图*/ | |
444 | + vpc_img_info crop_img = pVpcUtil->crop(memPtr, info); | |
444 | 445 | total_village_snapshot_info[new_obj].snapShots[0].snapShotLittle = crop_img; |
445 | - | |
446 | +#endif | |
446 | 447 | // 缓存末张抓拍图 |
447 | 448 | total_village_snapshot_info[new_obj].exists[2] = true; |
448 | 449 | total_village_snapshot_info[new_obj].snapShots[2].index.index = cur_real_index; |
449 | 450 | total_village_snapshot_info[new_obj].snapShots[2].confidence = obj_info.confidence; |
450 | 451 | total_village_snapshot_info[new_obj].snapShots[2].obj_pos = { cur_left, cur_top, cur_right - cur_left, cur_bottom - cur_top }; |
452 | +#if 0 /*暂不存最佳抓拍之外的小图*/ | |
451 | 453 | last_vec_obj_info.push_back(info); |
454 | +#else | |
455 | + total_village_snapshot_info[new_obj].snapShots[2].snapShot = VPCUtil::vpc_devMem2vpcImg(memPtr); | |
456 | +#endif | |
452 | 457 | |
453 | 458 | } else { |
454 | 459 | total_village_snapshot_info[new_obj].snapShots[1].last_area = (obj_info.right - obj_info.left) * (obj_info.bottom - obj_info.top); |
... | ... | @@ -490,7 +495,12 @@ void snapshot_reprocessing::update_village_bestsnapshot(vector<DeviceMemory*> ve |
490 | 495 | total_village_snapshot_info[new_obj].snapShots[2].index.index = cur_real_index; |
491 | 496 | total_village_snapshot_info[new_obj].snapShots[2].confidence = obj_info.confidence; |
492 | 497 | total_village_snapshot_info[new_obj].snapShots[2].obj_pos = { cur_left, cur_top, cur_right - cur_left, cur_bottom - cur_top }; |
498 | +#if 0 /*暂不存最佳抓拍之外的小图*/ | |
493 | 499 | last_vec_obj_info.push_back(info); |
500 | +#else | |
501 | + VPCUtil::vpc_img_release(total_village_snapshot_info[new_obj].snapShots[2].snapShot); | |
502 | + total_village_snapshot_info[new_obj].snapShots[2].snapShot = VPCUtil::vpc_devMem2vpcImg(memPtr); | |
503 | +#endif | |
494 | 504 | //--------------------------------------------------------------- |
495 | 505 | if (!best_snapshot_judge_algor(new_obj, total_village_snapshot_info[new_obj].snapShots[1], obj_info.left, obj_info.top, |
496 | 506 | cur_real_width, cur_real_height, frame_width, frame_height)) |
... | ... | @@ -530,7 +540,7 @@ void snapshot_reprocessing::update_village_bestsnapshot(vector<DeviceMemory*> ve |
530 | 540 | total_village_snapshot_info[objKey].snapShots[1].snapShotLittle = obj_info; |
531 | 541 | } |
532 | 542 | imgList.clear(); |
533 | - | |
543 | +#if 0 /*暂不存最佳抓拍之外的小图*/ | |
534 | 544 | vector<vpc_img_info> last_imgList = pVpcUtil->crop_batch(memPtr, last_vec_obj_info); |
535 | 545 | last_vec_obj_info.clear(); |
536 | 546 | for (size_t i = 0; i < last_imgList.size(); i++) { |
... | ... | @@ -542,6 +552,7 @@ void snapshot_reprocessing::update_village_bestsnapshot(vector<DeviceMemory*> ve |
542 | 552 | total_village_snapshot_info[objKey].snapShots[2].snapShotLittle = obj_info; |
543 | 553 | } |
544 | 554 | last_imgList.clear(); |
555 | +#endif | |
545 | 556 | } |
546 | 557 | } |
547 | 558 | ... | ... |