/* * @Author: yangzilong * @Date: 2021-12-16 14:25:13 * @Last Modified by: yangzilong * @Email: yangzilong@objecteye.com * @Description: */ #include "human_gather_statistics.h" #include "mvpt_process_assist.h" namespace ai_engine_module { namespace human_gather_statistics { long long human_gather_statistics::gid_ = 0; int human_gather_statistics::human_gather_statistics_init() { m_task_param_manager = task_param_manager::getInstance(); return 0; } std::vector human_gather_statistics::human_gather_statistics_process(set& taskin_play_id, sy_img* images, vector &ol_det_result) { std::vector results; map && algor_config_param = m_task_param_manager->get_task_algor_params(); map> && algor_param = m_task_param_manager->get_task_other_params(); map taskid_humancount; map> taskid_to_boxes; int idx = 0; for (auto task_id : taskin_play_id) { if (algor_config_param.count(task_id) && algor_config_param[task_id].human_algors.count(algorithm_type_t::HUMAN_GATHER)) { task_param_manager::algo_param_type_t_* cur_task_params = algor_param[task_id][algorithm_type_t::HUMAN_GATHER]; // if (!algor_config_param[task_id].human_algors.count(algorithm_type_t::HUMAN_GATHER)) { onelevel_det_result &cur_task_ol_detres = ol_det_result[idx]; for (int c = 0; c < cur_task_ol_detres.obj_count; c++) { if (cur_task_ol_detres.obj[c].index == (int)det_class_label_t::HUMAN && snapshot_legal_inarea(cur_task_params->basic_param->algor_valid_rect, cur_task_ol_detres.obj[c].left, cur_task_ol_detres.obj[c].top, cur_task_ol_detres.obj[c].right, cur_task_ol_detres.obj[c].bottom)) { taskid_humancount[task_id]++; box_t box; auto tmp_box = cur_task_ol_detres.obj[c]; { box.top = tmp_box.top; box.left = tmp_box.left; box.right = tmp_box.right; box.bottom = tmp_box.bottom; box.score = tmp_box.confidence; } taskid_to_boxes[task_id].emplace_back(std::move(box)); } } } int human_count_threshold = ((algor_config_param_human_gather*)cur_task_params->algor_param)->human_count_threshold; int frame_stride = ((algor_config_param_human_gather*)cur_task_params->algor_param)->frame_stride; if (taskid_humancount[task_id] > human_count_threshold && taskid_framecount[task_id] % frame_stride == 0) { result_data_t data; // data.img = images; data.img = &images[idx]; // modified by zsh data.task_id = task_id; data.boxes = std::move(taskid_to_boxes[task_id]); data.id = gid_++; results.emplace_back(std::move(data)); } } idx++; taskid_framecount[task_id]++; } return results; } std::vector human_gather_statistics::human_gather_statistics_process2(vector& taskin_play_id, sy_img* images, vector &ol_det_result) { std::vector results; map && algor_config_param = m_task_param_manager->get_task_algor_params(); map> && algor_param = m_task_param_manager->get_task_other_params(); map taskid_humancount; map> taskid_to_boxes; int idx = 0; for (auto task_id : taskin_play_id) { if (algor_config_param.count(task_id) && algor_config_param[task_id].human_algors.count(algorithm_type_t::HUMAN_GATHER)) { task_param_manager::algo_param_type_t_* cur_task_params = algor_param[task_id][algorithm_type_t::HUMAN_GATHER]; // if (!algor_config_param[task_id].human_algors.count(algorithm_type_t::HUMAN_GATHER)) { onelevel_det_result &cur_task_ol_detres = ol_det_result[idx]; for (int c = 0; c < cur_task_ol_detres.obj_count; c++) { if (cur_task_ol_detres.obj[c].index == (int)det_class_label_t::HUMAN && snapshot_legal_inarea(cur_task_params->basic_param->algor_valid_rect, cur_task_ol_detres.obj[c].left, cur_task_ol_detres.obj[c].top, cur_task_ol_detres.obj[c].right, cur_task_ol_detres.obj[c].bottom)) { taskid_humancount[task_id]++; box_t box; auto tmp_box = cur_task_ol_detres.obj[c]; { box.top = tmp_box.top; box.left = tmp_box.left; box.right = tmp_box.right; box.bottom = tmp_box.bottom; box.score = tmp_box.confidence; } taskid_to_boxes[task_id].emplace_back(std::move(box)); } } } int human_count_threshold = ((algor_config_param_human_gather*)cur_task_params->algor_param)->human_count_threshold; int frame_stride = ((algor_config_param_human_gather*)cur_task_params->algor_param)->frame_stride; if (taskid_humancount[task_id] > human_count_threshold && taskid_framecount[task_id] % frame_stride == 0) { result_data_t data; // data.img = images; data.img = &images[idx]; // modified by zsh data.task_id = task_id; data.boxes = std::move(taskid_to_boxes[task_id]); data.id = gid_++; results.emplace_back(std::move(data)); } } idx++; taskid_framecount[task_id]++; } return results; } } }