Commit 8791718402fbeeb39c3efd9fadda0558f5d51c88
1 parent
f1eb769d
同步代码,新添加了一些事件检测
Showing
31 changed files
with
927 additions
and
720 deletions
build/src/Makefile
1 | 1 | XX = g++ |
2 | 2 | |
3 | 3 | |
4 | -PROJECT_ROOT= /home/cmhu/vpt_ascend_arm | |
4 | +PROJECT_ROOT= /data/cmhu/projects/vpt_ascend_arm | |
5 | 5 | |
6 | 6 | DEPEND_DIR = $(PROJECT_ROOT)/bin |
7 | 7 | SRC_ROOT = $(PROJECT_ROOT)/src |
... | ... | @@ -68,6 +68,7 @@ SRCS:=$(wildcard $(SRC_ROOT)/ai_platform/*.cpp) \ |
68 | 68 | $(wildcard $(SRC_ROOT)/decoder/gb28181/Message/*.cpp) \ |
69 | 69 | $(wildcard $(SRC_ROOT)/decoder/gb28181/tinyxml2/*.cpp) \ |
70 | 70 | $(wildcard $(SRC_ROOT)/decoder/gb28181/websocket/*.cpp) \ |
71 | + $(wildcard $(SRC_ROOT)/helpers/*.cpp) \ | |
71 | 72 | |
72 | 73 | OBJS = $(patsubst %.cpp, %.o, $(notdir $(SRCS))) |
73 | 74 | |
... | ... | @@ -116,6 +117,8 @@ $(TARGET):$(OBJS) |
116 | 117 | %.o:$(SRC_ROOT)/decoder/gb28181/tinyxml2/%.cpp |
117 | 118 | $(XX) $(CXXFLAGS) -c $< |
118 | 119 | |
120 | +%.o:$(SRC_ROOT)/helpers/%.cpp | |
121 | + $(XX) $(CXXFLAGS) -c $< | |
119 | 122 | |
120 | 123 | |
121 | 124 | ... | ... |
src/ai_engine_module/GatherDetect.cpp
... | ... | @@ -6,14 +6,19 @@ |
6 | 6 | * @Description: |
7 | 7 | */ |
8 | 8 | #include "GatherDetect.h" |
9 | -#include "../ai_platform/mvpt_process_assist.h" | |
9 | +#include "../helpers/img_util.h" | |
10 | 10 | |
11 | 11 | GatherDetect::GatherDetect() |
12 | 12 | { |
13 | 13 | m_task_param_manager = task_param_manager::getInstance(); |
14 | 14 | } |
15 | 15 | |
16 | -std::vector<GatherResult> GatherDetect::process(vector<DeviceMemory*> vec_vptMem, vector<onelevel_det_result> &ol_det_result, algorithm_type_t algor_type) { | |
16 | +void GatherDetect::init(algorithm_type_t eType) | |
17 | +{ | |
18 | + m_eType = eType; | |
19 | +} | |
20 | + | |
21 | +std::vector<GatherResult> GatherDetect::process(vector<DeviceMemory*> vec_vptMem, vector<onelevel_det_result> &ol_det_result) { | |
17 | 22 | std::vector<GatherResult> results; |
18 | 23 | |
19 | 24 | map<string, algor_open_config_param> && algor_config_param = m_task_param_manager->get_task_algor_params(); |
... | ... | @@ -23,55 +28,65 @@ std::vector<GatherResult> GatherDetect::process(vector<DeviceMemory*> vec_vptMem |
23 | 28 | { |
24 | 29 | DeviceMemory* cur_vptMem = vec_vptMem[idx]; |
25 | 30 | string task_id = cur_vptMem->getId(); |
26 | - map<string, int> taskid_obj_count; | |
31 | + | |
32 | + auto it_algor = algor_param.find(task_id); | |
33 | + if (it_algor == algor_param.end()) { | |
34 | + continue; | |
35 | + } | |
36 | + | |
37 | + task_param_manager::algo_param_type_t_* cur_task_params = algor_param[task_id][m_eType]; | |
38 | + if (nullptr == cur_task_params) { | |
39 | + continue; | |
40 | + } | |
41 | + | |
42 | + algor_basic_config_param_t* basic_param = (algor_basic_config_param_t*)cur_task_params->basic_param; | |
43 | + if (basic_param == nullptr || basic_param->adapt_param == nullptr) { | |
44 | + continue; | |
45 | + } | |
46 | + universal_algor_adapt_param *adapt_param = basic_param->adapt_param; | |
47 | + | |
27 | 48 | map<string, std::vector<box_t>> taskid_to_boxes; |
28 | - if (algor_config_param.count(task_id) && algor_config_param[task_id].human_algors.count(algor_type)) | |
49 | + | |
50 | + onelevel_det_result &cur_task_ol_detres = ol_det_result[idx]; | |
51 | + for (int c = 0; c < cur_task_ol_detres.obj_count; c++) | |
29 | 52 | { |
30 | - task_param_manager::algo_param_type_t_* cur_task_params = algor_param[task_id][algor_type]; | |
31 | - { | |
32 | - onelevel_det_result &cur_task_ol_detres = ol_det_result[idx]; | |
53 | + auto& obj_c = cur_task_ol_detres.obj[c]; | |
33 | 54 | |
34 | - for (int c = 0; c < cur_task_ol_detres.obj_count; c++) | |
35 | - { | |
36 | - auto& obj_c = cur_task_ol_detres.obj[c]; | |
55 | + bool bHuman = m_eType == algorithm_type_t::HUMAN_GATHER || m_eType == algorithm_type_t::HUMAN_DENSITY || m_eType == algorithm_type_t::HUMAN_REGION_GATHER; | |
37 | 56 | |
38 | - bool bHuman = algor_type == algorithm_type_t::HUMAN_GATHER || algor_type == algorithm_type_t::HUMAN_DENSITY || algor_type == algorithm_type_t::HUMAN_REGION_GATHER; | |
57 | + bool bCount = false; | |
58 | + if(bHuman && obj_c.index == (int)det_class_label_t::HUMAN) { | |
59 | + bCount = true; | |
60 | + } else if (m_eType == algorithm_type_t::VEHICLE_GATHER && obj_c.index >= 4 && obj_c.index <= 8) { | |
61 | + bCount = true; | |
62 | + } | |
39 | 63 | |
40 | - bool bCount = false; | |
41 | - if(bHuman && obj_c.index == (int)det_class_label_t::HUMAN) { | |
42 | - bCount = true; | |
43 | - } else if (algor_type == algorithm_type_t::VEHICLE_GATHER && obj_c.index >= 4 && obj_c.index <= 8) { | |
44 | - bCount = true; | |
45 | - } | |
46 | - | |
47 | - if (bCount && snapshot_legal_inarea(cur_task_params->basic_param->algor_valid_rect, obj_c.left, obj_c.top, obj_c.right, obj_c.bottom)) | |
48 | - { | |
49 | - taskid_obj_count[task_id]++; | |
50 | - | |
51 | - auto tmp_box = cur_task_ol_detres.obj[c]; | |
52 | - box_t box; | |
53 | - box.top = tmp_box.top; | |
54 | - box.left = tmp_box.left; | |
55 | - box.right = tmp_box.right; | |
56 | - box.bottom = tmp_box.bottom; | |
57 | - box.score = tmp_box.confidence; | |
58 | - taskid_to_boxes[task_id].emplace_back(std::move(box)); | |
59 | - } | |
60 | - } | |
64 | + sy_point center; | |
65 | + center.x_ = (obj_c.right + obj_c.left)/ 2 ; | |
66 | + center.y_ = (obj_c.bottom + obj_c.top) / 2; | |
67 | + // vec_pt.push_back(center); | |
68 | + if (bCount && common::isInPolygon(adapt_param->points, adapt_param->points_count, center)) { | |
69 | + box_t box; | |
70 | + box.top = obj_c.top; | |
71 | + box.left = obj_c.left; | |
72 | + box.right = obj_c.right; | |
73 | + box.bottom = obj_c.bottom; | |
74 | + box.score = obj_c.confidence; | |
75 | + taskid_to_boxes[task_id].emplace_back(std::move(box)); | |
61 | 76 | } |
77 | + } | |
62 | 78 | |
63 | - int count_threshold = ((algor_config_param_human_gather*)cur_task_params->algor_param)->human_count_threshold; | |
64 | - int frame_stride = ((algor_config_param_human_gather*)cur_task_params->algor_param)->frame_stride; | |
79 | + int count_threshold = ((algor_config_param_human_gather*)cur_task_params->algor_param)->human_count_threshold; | |
80 | + int frame_stride = ((algor_config_param_human_gather*)cur_task_params->algor_param)->frame_stride; | |
65 | 81 | |
66 | - if (taskid_obj_count[task_id] > count_threshold && cur_vptMem->getFrameNb() % frame_stride == 0) | |
67 | - { | |
68 | - GatherResult data; | |
69 | - data.origin_img = VPCUtil::vpc_devMem2vpcImg(vec_vptMem[idx]); | |
70 | - data.task_id = task_id; | |
71 | - data.boxes = std::move(taskid_to_boxes[task_id]); | |
72 | - data.id = gid_++; | |
73 | - results.emplace_back(std::move(data)); | |
74 | - } | |
82 | + if (taskid_to_boxes[task_id].size() > count_threshold && cur_vptMem->getFrameNb() % frame_stride == 0) | |
83 | + { | |
84 | + GatherResult data; | |
85 | + data.origin_img = VPCUtil::vpc_devMem2vpcImg(vec_vptMem[idx]); | |
86 | + data.task_id = task_id; | |
87 | + data.boxes = std::move(taskid_to_boxes[task_id]); | |
88 | + data.id = gid_++; | |
89 | + results.emplace_back(std::move(data)); | |
75 | 90 | } |
76 | 91 | } |
77 | 92 | ... | ... |
src/ai_engine_module/GatherDetect.h
... | ... | @@ -28,9 +28,13 @@ class GatherDetect |
28 | 28 | public: |
29 | 29 | GatherDetect(); |
30 | 30 | |
31 | - std::vector<GatherResult> process(vector<DeviceMemory*> vec_vptMem, vector<onelevel_det_result> &ol_det_result, algorithm_type_t type); | |
31 | + void init(algorithm_type_t eType); | |
32 | + | |
33 | + std::vector<GatherResult> process(vector<DeviceMemory*> vec_vptMem, vector<onelevel_det_result> &ol_det_result); | |
32 | 34 | |
33 | 35 | private: |
34 | 36 | task_param_manager *m_task_param_manager{nullptr}; |
35 | 37 | long long gid_{0}; |
38 | + | |
39 | + algorithm_type_t m_eType{algorithm_type_t::UNKNOWN}; | |
36 | 40 | }; |
37 | 41 | \ No newline at end of file | ... | ... |
src/ai_engine_module/RegionLeave.cpp
... | ... | @@ -5,9 +5,10 @@ |
5 | 5 | #include <cmath> |
6 | 6 | |
7 | 7 | #include "../helpers/gen_json.hpp" |
8 | -#include "../ai_platform/mvpt_process_assist.h" | |
8 | +#include "../helpers/img_util.h" | |
9 | 9 | |
10 | 10 | |
11 | +namespace ai_engine_module { | |
11 | 12 | |
12 | 13 | std::set<det_class_label_t> algor_type_to_det_label_set(const algorithm_type_t &algor_type) { |
13 | 14 | if (algorithm_type_t::HUMAN_LEAVE_REGION == algor_type || algorithm_type_t::HUMAN_REGION_DISMISS == algor_type |
... | ... | @@ -55,65 +56,6 @@ void RegionLeave::set_callback(callback_t cb) { |
55 | 56 | } |
56 | 57 | #endif |
57 | 58 | |
58 | -/* 根据用户输入的点 初始化禁区区域mask */ | |
59 | -bool RegionLeave::add_task(const string &task_id, const int width, const int height) { | |
60 | - | |
61 | - auto &¶ms_ptr = m_task_param_manager->get_task_other_param(task_id, m_eType); | |
62 | - if (!params_ptr) | |
63 | - { | |
64 | - LOG_ERROR("{} is nullptr when get algor param from task_param", task_id); | |
65 | - return false; | |
66 | - } | |
67 | - | |
68 | - if (params_ptr->algor_param == nullptr) | |
69 | - return false; | |
70 | - | |
71 | - auto *algor_params_ptr = (algor_config_param_trespass_basic *)(params_ptr->algor_param); | |
72 | - if (algor_params_ptr == nullptr) | |
73 | - { | |
74 | - return false; | |
75 | - } | |
76 | - | |
77 | - cv::Mat src(height, width, CV_8UC3); | |
78 | - src.setTo(0); | |
79 | - | |
80 | - std::vector<cv::Point> contour; | |
81 | - for (int idx = 0; idx < algor_params_ptr->points_count; idx++) { | |
82 | - contour.emplace_back(algor_params_ptr->points[idx].x_, algor_params_ptr->points[idx].y_); | |
83 | - } | |
84 | - | |
85 | - if(contour.size() <= 0){ | |
86 | - return false; | |
87 | - } | |
88 | - | |
89 | - std::vector<std::vector<cv::Point>> contours; | |
90 | - contours.push_back(contour); | |
91 | - | |
92 | - cv::polylines(src, contours, true, cv::Scalar(255, 255, 255), 2, 8); // 第2个参数可以采用contour或者contours,均可 | |
93 | - cv::fillPoly(src, contours, cv::Scalar(255, 255, 255)); // fillPoly函数的第二个参数是二维数组 | |
94 | - | |
95 | - cv::Mat &dst_mat = region_map[task_id]; | |
96 | - cv::cvtColor(src, region_map[task_id], cv::COLOR_BGR2GRAY); | |
97 | - cv::threshold(region_map[task_id], region_map[task_id], 100, 255, cv::THRESH_BINARY); | |
98 | - | |
99 | - return true; | |
100 | -} | |
101 | - | |
102 | -/* 目标在禁区内外的辅助判断函数 */ | |
103 | -bool RegionLeave::in_rect_analysis(string task_id, const box_t &cur_bos) { | |
104 | - int center_x = int((cur_bos.left + cur_bos.right) / 2.0); | |
105 | - int center_y = int((cur_bos.top + cur_bos.bottom) / 2.0); | |
106 | - | |
107 | - cv::Mat &dst_mat = region_map[task_id]; | |
108 | - if (dst_mat.data[center_y * dst_mat.cols + center_x] && dst_mat.data[center_y * dst_mat.cols + center_x + 1] && | |
109 | - dst_mat.data[center_y * dst_mat.cols + center_x - 1] && dst_mat.data[(center_y + 1) * dst_mat.cols + center_x] && | |
110 | - dst_mat.data[(center_y - 1) * dst_mat.cols + center_x]) { | |
111 | - return true; // 进入禁区 | |
112 | - } else { | |
113 | - return false; // 未进入禁区 | |
114 | - } | |
115 | -} | |
116 | - | |
117 | 59 | bool RegionLeave::is_valid_box(string task_id, const box_t &box, const algorithm_type_t &algor_type) { |
118 | 60 | auto &¶ms_ptr = m_task_param_manager->get_task_other_param(task_id, algor_type); |
119 | 61 | if (!params_ptr) |
... | ... | @@ -125,9 +67,6 @@ bool RegionLeave::is_valid_box(string task_id, const box_t &box, const algorithm |
125 | 67 | if (params_ptr->basic_param == nullptr) |
126 | 68 | return false; |
127 | 69 | |
128 | - if (!snapshot_legal_inarea(params_ptr->basic_param->algor_valid_rect, box.left, box.top, box.right, box.bottom)) | |
129 | - return false; | |
130 | - | |
131 | 70 | if (params_ptr->algor_param == nullptr) |
132 | 71 | return false; |
133 | 72 | |
... | ... | @@ -163,23 +102,20 @@ void RegionLeave::process(std::vector<DeviceMemory*>& vec_gpuMem, const std::vec |
163 | 102 | } |
164 | 103 | } |
165 | 104 | |
166 | - auto it = region_map.find(task_id); | |
167 | - if (it == region_map.end()) { | |
168 | - continue; | |
169 | - } | |
170 | - | |
171 | 105 | auto &¶ms_ptr = m_task_param_manager->get_task_other_param(task_id, m_eType); |
172 | - if (!params_ptr && !params_ptr->basic_param) | |
106 | + if (!params_ptr || !params_ptr->basic_param) | |
173 | 107 | { |
174 | - LOG_ERROR("{} is nullptr when get algor param from task_param", task_id); | |
175 | 108 | continue; |
176 | 109 | } |
177 | 110 | |
178 | - bool b_src_saved = false; | |
111 | + auto& basic_param = params_ptr->basic_param; | |
112 | + if (basic_param == nullptr || basic_param->adapt_param == nullptr) { | |
113 | + continue; | |
114 | + } | |
115 | + universal_algor_adapt_param *adapt_param = basic_param->adapt_param; | |
179 | 116 | |
180 | 117 | string sep = "/"; |
181 | 118 | |
182 | - auto& basic_param = params_ptr->basic_param; | |
183 | 119 | std::string cur_src_ts = std::to_string(helpers::timer::get_timestamp<std::chrono::milliseconds>()); |
184 | 120 | std::string origin_file_path = basic_param->result_folder + sep + task_id + "_origin_" + cur_src_ts + ".jpg"; |
185 | 121 | |
... | ... | @@ -205,12 +141,15 @@ void RegionLeave::process(std::vector<DeviceMemory*>& vec_gpuMem, const std::vec |
205 | 141 | obj_to_position_.erase(obj_key); // 如果不满足条件 非 合法框 依然删除 |
206 | 142 | } |
207 | 143 | |
208 | - //! add or update. | |
209 | - if (in_rect_analysis(task_id, unique_box)) { | |
144 | + sy_point center; | |
145 | + center.x_ = (obj_c.right + obj_c.left)/ 2 ; | |
146 | + center.y_ = (obj_c.bottom + obj_c.top) / 2; | |
147 | + if (common::isInPolygon(adapt_param->points, adapt_param->points_count, center)) { | |
210 | 148 | // 禁区内 |
211 | 149 | // 新加 |
212 | 150 | obj_to_position_[obj_key] = unique_box; |
213 | - } else { | |
151 | + } else { | |
152 | + // 更新 | |
214 | 153 | if (obj_to_position_.find(obj_key) != obj_to_position_.end()) // 之前在禁区内,可报警 |
215 | 154 | { |
216 | 155 | box_t box; |
... | ... | @@ -243,13 +182,4 @@ void RegionLeave::process(std::vector<DeviceMemory*>& vec_gpuMem, const std::vec |
243 | 182 | } |
244 | 183 | } |
245 | 184 | |
246 | -void RegionLeave::release_task(string task_id){ | |
247 | - auto it = region_map.find(task_id); | |
248 | - if (it != region_map.end()) | |
249 | - { | |
250 | - region_map.erase(it); | |
251 | - } | |
252 | -} | |
253 | - | |
254 | - | |
255 | - | |
185 | +} // namespace ai_engine_module | |
256 | 186 | \ No newline at end of file | ... | ... |
src/ai_engine_module/RegionLeave.h
... | ... | @@ -13,6 +13,8 @@ |
13 | 13 | #include "../reprocessing_module/save_snapshot_reprocessing.h" |
14 | 14 | |
15 | 15 | |
16 | +namespace ai_engine_module { | |
17 | + | |
16 | 18 | class RegionLeave { |
17 | 19 | public: |
18 | 20 | RegionLeave(); |
... | ... | @@ -20,20 +22,14 @@ public: |
20 | 22 | |
21 | 23 | void init(int devId, algorithm_type_t eType); |
22 | 24 | |
23 | - bool add_task(const string &task_id, const int width, const int height); | |
24 | - | |
25 | 25 | void process(std::vector<DeviceMemory*>& vec_gpuMem, const std::vector<onelevel_det_result> &det_result, const vector<vector<int>> &delete_objs); |
26 | 26 | |
27 | - void release_task(string task_id); | |
28 | - | |
29 | 27 | #ifdef POST_USE_RABBITMQ |
30 | 28 | typedef std::function<bool(const char *msg)> callback_t; |
31 | 29 | void set_callback(callback_t cb); |
32 | 30 | #endif |
33 | 31 | |
34 | 32 | private: |
35 | - bool in_rect_analysis(string task_id, const box_t &cur_bos); | |
36 | - | |
37 | 33 | bool is_valid_box(string task_id, const box_t &box, const algorithm_type_t &algor_type); |
38 | 34 | |
39 | 35 | private: |
... | ... | @@ -48,4 +44,6 @@ private: |
48 | 44 | }; |
49 | 45 | |
50 | 46 | |
47 | +} // namespace ai_engine_module | |
48 | + | |
51 | 49 | #endif // __REGION_LEAVE_H__ |
52 | 50 | \ No newline at end of file | ... | ... |
src/ai_engine_module/common.h
0 → 100644
src/ai_engine_module/face_det_ai_engine.cpp
... | ... | @@ -7,6 +7,8 @@ |
7 | 7 | #include "opencv2/opencv.hpp" |
8 | 8 | #include "face_detect.h" |
9 | 9 | |
10 | +#include "../helpers/img_util.h" | |
11 | + | |
10 | 12 | face_det_ai_engine::face_det_ai_engine(){ |
11 | 13 | m_max_batchsize = 10; |
12 | 14 | } |
... | ... | @@ -81,15 +83,27 @@ int face_det_ai_engine::ai_engine_process_batch(std::vector<std::string> &task_i |
81 | 83 | auto task_id_iter = task_ids.cbegin(); |
82 | 84 | for (int c = 0; c < total_batchsize; ++c) |
83 | 85 | { |
84 | - task_param_manager::algo_param_type_t_* cur_task_params = algor_param[*task_id_iter++][algorithm_type_t::FACE_SNAPSHOT]; | |
86 | + string task_id = *task_id_iter; | |
87 | + task_id_iter++; | |
88 | + | |
89 | + task_param_manager::algo_param_type_t_* cur_task_params = algor_param[task_id][algorithm_type_t::FACE_SNAPSHOT]; | |
90 | + if (cur_task_params->basic_param == nullptr) { | |
91 | + continue; | |
92 | + } | |
93 | + | |
94 | + auto adapt_param = cur_task_params->basic_param->adapt_param; | |
95 | + if (adapt_param == nullptr){ | |
96 | + continue; | |
97 | + } | |
98 | + | |
85 | 99 | for (int i = 0; i < fd_result_[c].count; ++i) |
86 | 100 | { |
87 | - if (!snapshot_legal_inarea(cur_task_params->basic_param->algor_valid_rect, | |
88 | - fd_result_[c].info[i].face_position.left_, fd_result_[c].info[i].face_position.top_, | |
89 | - fd_result_[c].info[i].face_position.left_ + fd_result_[c].info[i].face_position.width_, | |
90 | - fd_result_[c].info[i].face_position.top_ + fd_result_[c].info[i].face_position.height_) | |
91 | - || fd_result_[c].info[i].face_pos_score < ((algor_config_param_snapshot *)cur_task_params->algor_param)->threshold) | |
92 | - { | |
101 | + auto& obj_c = fd_result_[c].info[i]; | |
102 | + | |
103 | + sy_point center; | |
104 | + center.x_ = obj_c.face_position.left_ + obj_c.face_position.width_ / 2 ; | |
105 | + center.y_ = obj_c.face_position.top_ + obj_c.face_position.height_ / 2; | |
106 | + if (!common::isInPolygon(adapt_param->points, adapt_param->points_count, center) || obj_c.face_pos_score < ((algor_config_param_snapshot *)cur_task_params->algor_param)->threshold) { | |
93 | 107 | continue; |
94 | 108 | } |
95 | 109 | ... | ... |
src/ai_engine_module/motocycle_hs_process.cpp
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | #include "../decoder/interface/DeviceMemory.hpp" |
5 | 5 | #include "../common/logger.hpp" |
6 | 6 | #include "../ai_platform/mvpt_process_assist.h" |
7 | - | |
7 | +#include "../helpers/img_util.h" | |
8 | 8 | |
9 | 9 | namespace ai_engine_module |
10 | 10 | { |
... | ... | @@ -37,10 +37,18 @@ namespace ai_engine_module |
37 | 37 | bool is_valid_box(const int top, const int left, const int right, const int bottom, const float score, |
38 | 38 | const algorithm_type_t &algor_type, |
39 | 39 | const task_param_manager::algo_param_type_t_ *params_ptr = nullptr) { |
40 | - if (!params_ptr) | |
40 | + if (!params_ptr || params_ptr->basic_param == nullptr) | |
41 | + return false; | |
42 | + | |
43 | + universal_algor_adapt_param *adapt_param = params_ptr->basic_param->adapt_param; | |
44 | + if (nullptr == adapt_param) { | |
41 | 45 | return false; |
46 | + } | |
42 | 47 | |
43 | - if (!snapshot_legal_inarea(params_ptr->basic_param->algor_valid_rect, left, top, right, bottom)) | |
48 | + sy_point center; | |
49 | + center.x_ = (right + left)/ 2 ; | |
50 | + center.y_ = (bottom + top) / 2; | |
51 | + if (!common::isInPolygon(adapt_param->points, adapt_param->points_count, center)) | |
44 | 52 | return false; |
45 | 53 | |
46 | 54 | if (params_ptr->algor_param == nullptr) | ... | ... |
src/ai_engine_module/motocycle_phone_process.cpp
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | #include "../decoder/interface/DeviceMemory.hpp" |
5 | 5 | #include "../common/logger.hpp" |
6 | 6 | #include "../ai_platform/mvpt_process_assist.h" |
7 | - | |
7 | +#include "../helpers/img_util.h" | |
8 | 8 | |
9 | 9 | namespace ai_engine_module |
10 | 10 | { |
... | ... | @@ -38,10 +38,18 @@ namespace ai_engine_module |
38 | 38 | const algorithm_type_t &algor_type, |
39 | 39 | const int src_img_w, const int src_img_h, |
40 | 40 | const task_param_manager::algo_param_type_t_ *params_ptr = nullptr) { |
41 | - if (!params_ptr) | |
41 | + if (!params_ptr || params_ptr->basic_param == nullptr) | |
42 | + return false; | |
43 | + | |
44 | + universal_algor_adapt_param *adapt_param = params_ptr->basic_param->adapt_param; | |
45 | + if (nullptr == adapt_param) { | |
42 | 46 | return false; |
47 | + } | |
43 | 48 | |
44 | - if (!snapshot_legal_inarea(params_ptr->basic_param->algor_valid_rect, left, top, right, bottom)) | |
49 | + sy_point center; | |
50 | + center.x_ = (right + left)/ 2 ; | |
51 | + center.y_ = (bottom + top) / 2; | |
52 | + if (!common::isInPolygon(adapt_param->points, adapt_param->points_count, center)) | |
45 | 53 | return false; |
46 | 54 | |
47 | 55 | if (params_ptr->algor_param == nullptr) | ... | ... |
src/ai_engine_module/motocycle_refit_phone_process.cpp
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | #include "../decoder/interface/DeviceMemory.hpp" |
5 | 5 | #include "../common/logger.hpp" |
6 | 6 | #include "../ai_platform/mvpt_process_assist.h" |
7 | - | |
7 | +#include "../helpers/img_util.h" | |
8 | 8 | |
9 | 9 | namespace ai_engine_module |
10 | 10 | { |
... | ... | @@ -39,10 +39,18 @@ namespace ai_engine_module |
39 | 39 | const algorithm_type_t &algor_type, |
40 | 40 | const int src_img_w, const int src_img_h, |
41 | 41 | const task_param_manager::algo_param_type_t_ *params_ptr = nullptr) { |
42 | - if (!params_ptr) | |
42 | + if (!params_ptr || params_ptr->basic_param == nullptr) | |
43 | + return false; | |
44 | + | |
45 | + universal_algor_adapt_param *adapt_param = params_ptr->basic_param->adapt_param; | |
46 | + if (nullptr == adapt_param) { | |
43 | 47 | return false; |
48 | + } | |
44 | 49 | |
45 | - if (!snapshot_legal_inarea(params_ptr->basic_param->algor_valid_rect, left, top, right, bottom)) | |
50 | + sy_point center; | |
51 | + center.x_ = (right + left)/ 2 ; | |
52 | + center.y_ = (bottom + top) / 2; | |
53 | + if (!common::isInPolygon(adapt_param->points, adapt_param->points_count, center)) | |
46 | 54 | return false; |
47 | 55 | |
48 | 56 | if (params_ptr->algor_param == nullptr) | ... | ... |
src/ai_engine_module/motocycle_refit_process.cpp
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | #include "../decoder/interface/DeviceMemory.hpp" |
5 | 5 | #include "../common/logger.hpp" |
6 | 6 | #include "../ai_platform/mvpt_process_assist.h" |
7 | - | |
7 | +#include "../helpers/img_util.h" | |
8 | 8 | |
9 | 9 | namespace ai_engine_module |
10 | 10 | { |
... | ... | @@ -36,10 +36,18 @@ namespace ai_engine_module |
36 | 36 | const algorithm_type_t &algor_type, |
37 | 37 | const int src_img_w, const int src_img_h, |
38 | 38 | const task_param_manager::algo_param_type_t_ *params_ptr = nullptr) { |
39 | - if (!params_ptr) | |
39 | + if (!params_ptr || params_ptr->basic_param == nullptr) | |
40 | + return false; | |
41 | + | |
42 | + universal_algor_adapt_param *adapt_param = params_ptr->basic_param->adapt_param; | |
43 | + if (nullptr == adapt_param) { | |
40 | 44 | return false; |
45 | + } | |
41 | 46 | |
42 | - if (!snapshot_legal_inarea(params_ptr->basic_param->algor_valid_rect, left, top, right, bottom)) | |
47 | + sy_point center; | |
48 | + center.x_ = (right + left)/ 2 ; | |
49 | + center.y_ = (bottom + top) / 2; | |
50 | + if (!common::isInPolygon(adapt_param->points, adapt_param->points_count, center)) | |
43 | 51 | return false; |
44 | 52 | |
45 | 53 | if (params_ptr->algor_param == nullptr) | ... | ... |
src/ai_engine_module/pedestrian_vehicle_retrograde.cpp
... | ... | @@ -15,6 +15,7 @@ |
15 | 15 | #include "../decoder/interface/DeviceMemory.hpp" |
16 | 16 | #include "../common/logger.hpp" |
17 | 17 | #include "../ai_platform/mvpt_process_assist.h" |
18 | +#include "../helpers/img_util.h" | |
18 | 19 | |
19 | 20 | namespace ai_engine_module { |
20 | 21 | namespace pedestrian_vehicle_retrograde { |
... | ... | @@ -50,11 +51,19 @@ bool is_valid_box(const int &cls, const algorithm_type_t &algor_type) { |
50 | 51 | |
51 | 52 | bool is_valid_box(const box_t &box, const algorithm_type_t &algor_type, |
52 | 53 | const task_param_manager::algo_param_type_t_ *params_ptr = nullptr) { |
53 | - if (!params_ptr) | |
54 | - return false; | |
54 | + if (!params_ptr || params_ptr->basic_param == nullptr) | |
55 | + return false; | |
55 | 56 | |
56 | - if (!snapshot_legal_inarea(params_ptr->basic_param->algor_valid_rect, box.left, box.top, box.right, box.bottom)) | |
57 | - return false; | |
57 | + universal_algor_adapt_param *adapt_param = params_ptr->basic_param->adapt_param; | |
58 | + if (nullptr == adapt_param) { | |
59 | + return false; | |
60 | + } | |
61 | + | |
62 | + sy_point center; | |
63 | + center.x_ = (box.right + box.left)/ 2 ; | |
64 | + center.y_ = (box.bottom + box.top) / 2; | |
65 | + if (!common::isInPolygon(adapt_param->points, adapt_param->points_count, center)) | |
66 | + return false; | |
58 | 67 | |
59 | 68 | if (params_ptr->algor_param == nullptr) |
60 | 69 | return false; | ... | ... |
src/ai_engine_module/pedestrian_vehicle_trespass.cpp
... | ... | @@ -17,7 +17,7 @@ |
17 | 17 | #include "../decoder/interface/DeviceMemory.hpp" |
18 | 18 | #include "../common/logger.hpp" |
19 | 19 | #include "../ai_platform/mvpt_process_assist.h" |
20 | - | |
20 | +#include "../helpers/img_util.h" | |
21 | 21 | |
22 | 22 | namespace ai_engine_module { |
23 | 23 | namespace pedestrian_vehicle_trespass { |
... | ... | @@ -55,11 +55,19 @@ bool is_valid_box(const int &cls, const algorithm_type_t &algor_type) { |
55 | 55 | |
56 | 56 | bool is_valid_box(const box_t &box, const algorithm_type_t &algor_type, |
57 | 57 | const task_param_manager::algo_param_type_t_ *params_ptr = nullptr) { |
58 | - if (!params_ptr) | |
59 | - return false; | |
58 | + if (!params_ptr || params_ptr->basic_param == nullptr) | |
59 | + return false; | |
60 | 60 | |
61 | - if (!snapshot_legal_inarea(params_ptr->basic_param->algor_valid_rect, box.left, box.top, box.right, box.bottom)) | |
62 | - return false; | |
61 | + universal_algor_adapt_param *adapt_param = params_ptr->basic_param->adapt_param; | |
62 | + if (nullptr == adapt_param) { | |
63 | + return false; | |
64 | + } | |
65 | + | |
66 | + sy_point center; | |
67 | + center.x_ = (box.right + box.left)/ 2 ; | |
68 | + center.y_ = (box.bottom + box.top) / 2; | |
69 | + if (!common::isInPolygon(adapt_param->points, adapt_param->points_count, center)) | |
70 | + return false; | |
63 | 71 | |
64 | 72 | if (params_ptr->algor_param == nullptr) |
65 | 73 | return false; | ... | ... |
src/ai_engine_module/road_seg_correlation_algor.cpp
... | ... | @@ -5,9 +5,9 @@ |
5 | 5 | #include "../common/logger.hpp" |
6 | 6 | #include "../ai_platform/mvpt_process_assist.h" |
7 | 7 | #include <iostream> |
8 | -#if 1 | |
9 | 8 | #include "opencv2/opencv.hpp" |
10 | -#endif | |
9 | +#include "../helpers/img_util.h" | |
10 | + | |
11 | 11 | |
12 | 12 | namespace ai_engine_module |
13 | 13 | { |
... | ... | @@ -62,10 +62,18 @@ namespace ai_engine_module |
62 | 62 | const algorithm_type_t &algor_type, |
63 | 63 | const int src_img_w, const int src_img_h, |
64 | 64 | const task_param_manager::algo_param_type_t_ *params_ptr = nullptr) { |
65 | - if (!params_ptr) | |
65 | + if (!params_ptr || params_ptr->basic_param == nullptr) | |
66 | 66 | return false; |
67 | 67 | |
68 | - if (!snapshot_legal_inarea(params_ptr->basic_param->algor_valid_rect, left, top, right, bottom)) | |
68 | + universal_algor_adapt_param *adapt_param = params_ptr->basic_param->adapt_param; | |
69 | + if (nullptr == adapt_param) { | |
70 | + return false; | |
71 | + } | |
72 | + | |
73 | + sy_point center; | |
74 | + center.x_ = (right + left)/ 2 ; | |
75 | + center.y_ = (bottom + top) / 2; | |
76 | + if (!common::isInPolygon(adapt_param->points, adapt_param->points_count, center)) | |
69 | 77 | return false; |
70 | 78 | |
71 | 79 | if (params_ptr->algor_param == nullptr) | ... | ... |
src/ai_engine_module/traffic_light_process.cpp
... | ... | @@ -4,10 +4,8 @@ |
4 | 4 | #include "../decoder/interface/DeviceMemory.hpp" |
5 | 5 | #include "../common/logger.hpp" |
6 | 6 | #include "../ai_platform/mvpt_process_assist.h" |
7 | - | |
8 | -#if 1 | |
9 | 7 | #include "opencv2/opencv.hpp" |
10 | -#endif | |
8 | +#include "../helpers/img_util.h" | |
11 | 9 | |
12 | 10 | namespace ai_engine_module |
13 | 11 | { |
... | ... | @@ -40,10 +38,18 @@ namespace ai_engine_module |
40 | 38 | const algorithm_type_t &algor_type, |
41 | 39 | const int src_img_w, const int src_img_h, |
42 | 40 | const task_param_manager::algo_param_type_t_ *params_ptr = nullptr) { |
43 | - if (!params_ptr) | |
41 | + if (!params_ptr || params_ptr->basic_param == nullptr) | |
44 | 42 | return false; |
45 | 43 | |
46 | - if (!snapshot_legal_inarea(params_ptr->basic_param->algor_valid_rect, left, top, right, bottom)) | |
44 | + universal_algor_adapt_param *adapt_param = params_ptr->basic_param->adapt_param; | |
45 | + if (nullptr == adapt_param) { | |
46 | + return false; | |
47 | + } | |
48 | + | |
49 | + sy_point center; | |
50 | + center.x_ = (right + left)/ 2 ; | |
51 | + center.y_ = (bottom + top) / 2; | |
52 | + if (!common::isInPolygon(adapt_param->points, adapt_param->points_count, center)) | |
47 | 53 | return false; |
48 | 54 | |
49 | 55 | if (params_ptr->algor_param == nullptr) | ... | ... |
src/ai_engine_module/tricycle_manned_process.cpp
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | #include "../decoder/interface/DeviceMemory.hpp" |
5 | 5 | #include "../common/logger.hpp" |
6 | 6 | #include "../ai_platform/mvpt_process_assist.h" |
7 | - | |
7 | +#include "../helpers/img_util.h" | |
8 | 8 | |
9 | 9 | namespace ai_engine_module |
10 | 10 | { |
... | ... | @@ -144,13 +144,18 @@ namespace ai_engine_module |
144 | 144 | { |
145 | 145 | auto& taskId = *taskId_iter; |
146 | 146 | auto algor_param_wrap = task_param_manager_->get_task_other_param(taskId, this->algor_type_); |
147 | - if (!algor_param_wrap) | |
147 | + if (!algor_param_wrap || algor_param_wrap->basic_param == nullptr) | |
148 | 148 | { |
149 | 149 | LOG_ERROR("{} is nullptr when get algor param from task_param", taskId.c_str()); |
150 | 150 | continue; |
151 | 151 | } |
152 | 152 | auto algor_param = ((algor_param_type)algor_param_wrap->algor_param); |
153 | 153 | |
154 | + universal_algor_adapt_param *adapt_param = algor_param_wrap->basic_param->adapt_param; | |
155 | + if (nullptr == adapt_param) { | |
156 | + continue; | |
157 | + } | |
158 | + | |
154 | 159 | input_data_wrap_t data; |
155 | 160 | int top = std::max(int(box.top - (IMAGE_CROP_EXPAND_RATIO * box.top)), 0); |
156 | 161 | int left = std::max(int(box.left - (IMAGE_CROP_EXPAND_RATIO * box.left)), 0); |
... | ... | @@ -160,8 +165,12 @@ namespace ai_engine_module |
160 | 165 | int width = right - left; |
161 | 166 | int height = bottom - top; |
162 | 167 | |
168 | + sy_point center; | |
169 | + center.x_ = (right + left)/ 2 ; | |
170 | + center.y_ = (bottom + top) / 2; | |
171 | + | |
163 | 172 | if ((width < algor_param->obj_min_width || height < algor_param->obj_min_height || box.confidence < algor_param->obj_confidence_threshold) || |
164 | - !snapshot_legal_inarea(algor_param_wrap->basic_param->algor_valid_rect, left, top, right, bottom)) | |
173 | + !common::isInPolygon(adapt_param->points, adapt_param->points_count, center)) | |
165 | 174 | continue; |
166 | 175 | |
167 | 176 | data.box.top = top; | ... | ... |
src/ai_engine_module/truck_manned_process.cpp
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | |
8 | 8 | #include "opencv2/opencv.hpp" |
9 | 9 | #include "opencv2/imgcodecs/legacy/constants_c.h" |
10 | - | |
10 | +#include "../helpers/img_util.h" | |
11 | 11 | |
12 | 12 | namespace ai_engine_module |
13 | 13 | { |
... | ... | @@ -260,13 +260,18 @@ namespace ai_engine_module |
260 | 260 | { |
261 | 261 | auto& taskId = *taskId_iter; |
262 | 262 | auto algor_param_wrap = task_param_manager_->get_task_other_param(taskId, this->algor_type_); |
263 | - if (!algor_param_wrap) | |
263 | + if (!algor_param_wrap || algor_param_wrap->basic_param == nullptr) | |
264 | 264 | { |
265 | 265 | LOG_ERROR("{} is nullptr when get algor param from task_param", taskId.c_str()); |
266 | 266 | continue; |
267 | 267 | } |
268 | 268 | auto algor_param = ((algor_param_type)algor_param_wrap->algor_param); |
269 | 269 | |
270 | + universal_algor_adapt_param *adapt_param = algor_param_wrap->basic_param->adapt_param; | |
271 | + if (nullptr == adapt_param) { | |
272 | + continue; | |
273 | + } | |
274 | + | |
270 | 275 | input_data_wrap_t data; |
271 | 276 | int top = std::max(int(box.top - (IMAGE_CROP_EXPAND_RATIO * box.top)), 0); |
272 | 277 | int left = std::max(int(box.left - (IMAGE_CROP_EXPAND_RATIO * box.left)), 0); |
... | ... | @@ -276,8 +281,12 @@ namespace ai_engine_module |
276 | 281 | int width = right - left; |
277 | 282 | int height = bottom - top; |
278 | 283 | |
284 | + sy_point center; | |
285 | + center.x_ = (right + left)/ 2 ; | |
286 | + center.y_ = (bottom + top) / 2; | |
287 | + | |
279 | 288 | if ((width < algor_param->obj_min_width || height < algor_param->obj_min_height || box.confidence < algor_param->obj_confidence_threshold) || |
280 | - !snapshot_legal_inarea(algor_param_wrap->basic_param->algor_valid_rect, left, top, right, bottom)) | |
289 | + !common::isInPolygon(adapt_param->points, adapt_param->points_count, center)) | |
281 | 290 | continue; |
282 | 291 | |
283 | 292 | //统计货车检测框内行人及非机动车的数量 | ... | ... |
src/ai_platform/MultiSourceProcess.cpp
... | ... | @@ -13,7 +13,8 @@ |
13 | 13 | #include "../helpers/os_helper.hpp" |
14 | 14 | #include "../helpers/gen_json.hpp" |
15 | 15 | #include "../helpers/str_helper.hpp" |
16 | -#include "../helpers/common_tool.h" | |
16 | +#include "../helpers/img_util.h" | |
17 | + | |
17 | 18 | #include "../reprocessing_module/save_snapshot_reprocessing.h" |
18 | 19 | |
19 | 20 | #include "macro_definition.h" |
... | ... | @@ -22,6 +23,7 @@ |
22 | 23 | #include "mvpt_process_assist.h" |
23 | 24 | |
24 | 25 | #include "../util/vpc_util.h" |
26 | +#include "../util/common_tool.h" | |
25 | 27 | |
26 | 28 | #include "../decoder/gb28181/websocket/WebsocketClient.h" |
27 | 29 | |
... | ... | @@ -229,6 +231,11 @@ int CMultiSourceProcess::InitAlgorthim(tsl_aiplatform_param vptParam){ |
229 | 231 | m_algorthim_region_dismiss.init(vptParam.gpuid, algorithm_type_t::HUMAN_REGION_DISMISS); |
230 | 232 | m_algorthim_region_fastmoving.init(vptParam.gpuid, algorithm_type_t::HUMAN_REGION_FAST_MOVING); |
231 | 233 | |
234 | + m_human_gather.init(algorithm_type_t::HUMAN_GATHER); | |
235 | + m_human_density.init(algorithm_type_t::HUMAN_DENSITY); | |
236 | + m_human_region_gather.init(algorithm_type_t::HUMAN_REGION_GATHER); | |
237 | + m_vehicle_gather.init(algorithm_type_t::VEHICLE_GATHER); | |
238 | + | |
232 | 239 | m_task_param_manager = task_param_manager::getInstance(); |
233 | 240 | |
234 | 241 | m_snapshot_reprocessing = new snapshot_reprocessing(m_devId); |
... | ... | @@ -432,11 +439,6 @@ bool CMultiSourceProcess::AddTask(task_param _cur_task_param){ |
432 | 439 | m_face_det_ai_engine.add_tracker(task_id, skip_frame_); // 跳帧数暂时写死 |
433 | 440 | #endif |
434 | 441 | |
435 | - // 必须在 add_task_param 之后 todo 这里需要用参数过滤是否初始化 | |
436 | - m_algorthim_region_leave.add_task(task_id, input_image_width, input_image_height); | |
437 | - m_algorthim_region_dismiss.add_task(task_id, input_image_width, input_image_height); | |
438 | - m_algorthim_region_fastmoving.add_task(task_id, input_image_width, input_image_height); | |
439 | - | |
440 | 442 | m_FinishedTaskMtx.lock(); |
441 | 443 | m_FinishedTaskMap[task_id] = false; |
442 | 444 | m_FinishedTaskMtx.unlock(); |
... | ... | @@ -689,10 +691,6 @@ bool CMultiSourceProcess::finish_task(const string taskID, const bool delete_sna |
689 | 691 | pedestrian_vehicle_retrograde_.force_release_result(taskID); //221024 byzsh |
690 | 692 | // #endif |
691 | 693 | |
692 | - m_algorthim_region_leave.release_task(taskID); | |
693 | - m_algorthim_region_dismiss.release_task(taskID); | |
694 | - m_algorthim_region_fastmoving.release_task(taskID); | |
695 | - | |
696 | 694 | #ifdef USE_VILLAGE |
697 | 695 | tricycle_manned_.force_release_result(taskID); |
698 | 696 | truck_manned_.force_release_result(taskID); |
... | ... | @@ -932,8 +930,8 @@ int CMultiSourceProcess::algorthim_vpt(vector<DeviceMemory*> vec_gpuMem){ |
932 | 930 | |
933 | 931 | gather_process(vec_vptMem, vptResult, algorithm_type_t::HUMAN_GATHER); // modified by zsh |
934 | 932 | gather_process(vec_vptMem, vptResult, algorithm_type_t::HUMAN_DENSITY); |
935 | - gather_process(vec_vptMem, vptResult, algorithm_type_t::VEHICLE_GATHER); | |
936 | 933 | gather_process(vec_vptMem, vptResult, algorithm_type_t::HUMAN_REGION_GATHER); |
934 | + gather_process(vec_vptMem, vptResult, algorithm_type_t::VEHICLE_GATHER); | |
937 | 935 | |
938 | 936 | // m_snapshot_reprocessing->screen_effective_snapshot(vptResult); |
939 | 937 | |
... | ... | @@ -2208,11 +2206,14 @@ void CMultiSourceProcess::cross_line_process(vector<DeviceMemory*> vec_gpuMem, v |
2208 | 2206 | { |
2209 | 2207 | continue; |
2210 | 2208 | } |
2211 | - | |
2212 | - bool b_src_saved = false; | |
2213 | 2209 | |
2214 | 2210 | algor_config_param_illegal_crossing_line* algor_param = (algor_config_param_illegal_crossing_line*)cur_task_params->algor_param; |
2215 | 2211 | algor_basic_config_param_t* basic_param = (algor_basic_config_param_t*)cur_task_params->basic_param; |
2212 | + if (basic_param == nullptr || basic_param->adapt_param == nullptr) { | |
2213 | + continue; | |
2214 | + } | |
2215 | + universal_algor_adapt_param *adapt_param = basic_param->adapt_param; | |
2216 | + | |
2216 | 2217 | jxline std_line(algor_param->p1.x_, algor_param->p1.y_, algor_param->p2.x_, algor_param->p2.y_); |
2217 | 2218 | |
2218 | 2219 | std::string cur_src_ts = std::to_string(helpers::timer::get_timestamp<std::chrono::milliseconds>()); |
... | ... | @@ -2231,8 +2232,10 @@ void CMultiSourceProcess::cross_line_process(vector<DeviceMemory*> vec_gpuMem, v |
2231 | 2232 | bCount = true; |
2232 | 2233 | } |
2233 | 2234 | |
2234 | - if (!bCount || !snapshot_legal_inarea(basic_param->algor_valid_rect, obj_c.left, obj_c.top, obj_c.right, obj_c.bottom)) | |
2235 | - { | |
2235 | + sy_point center; | |
2236 | + center.x_ = (obj_c.right + obj_c.left)/ 2 ; | |
2237 | + center.y_ = (obj_c.bottom + obj_c.top) / 2; | |
2238 | + if (!bCount || !common::isInPolygon(adapt_param->points, adapt_param->points_count, center)) { | |
2236 | 2239 | continue; |
2237 | 2240 | } |
2238 | 2241 | |
... | ... | @@ -2312,6 +2315,10 @@ void CMultiSourceProcess::wander_detect(vector<DeviceMemory*>& vec_gpuMem, vecto |
2312 | 2315 | |
2313 | 2316 | algor_config_param_behavior* algor_param = (algor_config_param_behavior*)cur_task_params->algor_param; |
2314 | 2317 | algor_basic_config_param_t* basic_param = (algor_basic_config_param_t*)cur_task_params->basic_param; |
2318 | + if (basic_param == nullptr || basic_param->adapt_param == nullptr) { | |
2319 | + continue; | |
2320 | + } | |
2321 | + universal_algor_adapt_param *adapt_param = basic_param->adapt_param; | |
2315 | 2322 | |
2316 | 2323 | long algor_skip_gap = algor_param->duration; |
2317 | 2324 | |
... | ... | @@ -2329,8 +2336,10 @@ void CMultiSourceProcess::wander_detect(vector<DeviceMemory*>& vec_gpuMem, vecto |
2329 | 2336 | bCount = true; |
2330 | 2337 | } |
2331 | 2338 | |
2332 | - if (!bCount || !snapshot_legal_inarea(basic_param->algor_valid_rect, obj_c.left, obj_c.top, obj_c.right, obj_c.bottom)) | |
2333 | - { | |
2339 | + sy_point center; | |
2340 | + center.x_ = (obj_c.right + obj_c.left)/ 2 ; | |
2341 | + center.y_ = (obj_c.bottom + obj_c.top) / 2; | |
2342 | + if (!bCount || !common::isInPolygon(adapt_param->points, adapt_param->points_count, center)) { | |
2334 | 2343 | continue; |
2335 | 2344 | } |
2336 | 2345 | |
... | ... | @@ -2390,7 +2399,15 @@ void CMultiSourceProcess::wander_detect(vector<DeviceMemory*>& vec_gpuMem, vecto |
2390 | 2399 | int CMultiSourceProcess::gather_process(vector<DeviceMemory*>& vec_gpuMem, vector<onelevel_det_result> &ol_det_result, algorithm_type_t algor_type) { |
2391 | 2400 | /* 人数聚集算法功能 每帧都会获取算法结果 并返回 */ |
2392 | 2401 | std::vector<GatherResult> results; |
2393 | - results = m_algorthim_gather.process(vec_gpuMem, ol_det_result, algor_type); | |
2402 | + if (algor_type == algorithm_type_t::HUMAN_GATHER) { | |
2403 | + results = m_human_gather.process(vec_gpuMem, ol_det_result); | |
2404 | + } else if (algor_type == algorithm_type_t::HUMAN_DENSITY) { | |
2405 | + results = m_human_density.process(vec_gpuMem, ol_det_result); | |
2406 | + } else if (algor_type == algorithm_type_t::HUMAN_REGION_GATHER) { | |
2407 | + results = m_human_region_gather.process(vec_gpuMem, ol_det_result); | |
2408 | + } else if (algor_type == algorithm_type_t::VEHICLE_GATHER) { | |
2409 | + results = m_vehicle_gather.process(vec_gpuMem, ol_det_result); | |
2410 | + } | |
2394 | 2411 | |
2395 | 2412 | int algorithm_type = (int)algor_type; |
2396 | 2413 | for (auto &result : results) { |
... | ... | @@ -2511,7 +2528,7 @@ bool CMultiSourceProcess::CheckTime() { |
2511 | 2528 | nYear = info->tm_year + 1900; |
2512 | 2529 | nMonth = info->tm_mon + 1; |
2513 | 2530 | nDay = info->tm_mday; |
2514 | - if (nYear == 2024 && nMonth <= 12) | |
2531 | + if (nYear == 2025 && nMonth <= 12) | |
2515 | 2532 | { |
2516 | 2533 | return true; |
2517 | 2534 | } | ... | ... |
src/ai_platform/MultiSourceProcess.h
... | ... | @@ -182,11 +182,14 @@ private: |
182 | 182 | |
183 | 183 | face_det_ai_engine m_face_det_ai_engine; // 人脸检测 |
184 | 184 | |
185 | - RegionLeave m_algorthim_region_leave; | |
186 | - RegionLeave m_algorthim_region_dismiss; | |
187 | - RegionLeave m_algorthim_region_fastmoving; | |
188 | - | |
189 | - GatherDetect m_algorthim_gather; | |
185 | + ai_engine_module::RegionLeave m_algorthim_region_leave; | |
186 | + ai_engine_module::RegionLeave m_algorthim_region_dismiss; | |
187 | + ai_engine_module::RegionLeave m_algorthim_region_fastmoving; | |
188 | + | |
189 | + GatherDetect m_human_gather; | |
190 | + GatherDetect m_human_density; | |
191 | + GatherDetect m_human_region_gather; | |
192 | + GatherDetect m_vehicle_gather; | |
190 | 193 | |
191 | 194 | deque<RecoderInfo> m_recoderinfo_queue; |
192 | 195 | mutex m_recoderinfo_queue_mtx; | ... | ... |
src/ai_platform/header.h
... | ... | @@ -480,11 +480,28 @@ typedef struct algor_config_param_snapshot { |
480 | 480 | #endif |
481 | 481 | |
482 | 482 | |
483 | +#ifndef __UNIVERSAL_ADAPTATON__ | |
484 | +#define __UNIVERSAL_ADAPTATON__ | |
485 | +#define ROI_MAX_POINT 50 | |
486 | +#define MAX_DIRECTION_LINE 50 | |
487 | +typedef struct universal_algor_adapt_param { | |
488 | + sy_point points[ROI_MAX_POINT]; | |
489 | + int points_count; //多边形顶点数量(不超过ROI_MAX_POINT) | |
490 | + // sy_direction direction[MAX_DIRECTION_LINE]; | |
491 | + int line_count; //拌线数量(不超过MAX_DIRECTION_LINE) | |
492 | + | |
493 | + universal_algor_adapt_param() | |
494 | + : points_count(0), line_count(0) { | |
495 | + } | |
496 | +} universal_algor_adapt_param; | |
497 | +#endif | |
498 | + | |
483 | 499 | |
484 | 500 | // 算法的初始化参数 |
485 | 501 | #ifndef __ALGOR_CONFIG_PARAM__BASIC__ |
486 | 502 | #define __ALGOR_CONFIG_PARAM__BASIC__ |
487 | 503 | typedef struct algor_basic_config_param_t { |
504 | + universal_algor_adapt_param *adapt_param{nullptr}; //此处传入共性适配参数 | |
488 | 505 | sy_rect algor_valid_rect; |
489 | 506 | char *result_folder_little; //目标快照抠图保存地址 |
490 | 507 | char *result_folder; //目标快照大图保存地址 |
... | ... | @@ -496,7 +513,6 @@ typedef struct algor_basic_config_param_t { |
496 | 513 | |
497 | 514 | |
498 | 515 | |
499 | - | |
500 | 516 | //算法的初始化参数 |
501 | 517 | #ifndef __ALGOR_CONFIG_PARAM__ |
502 | 518 | #define __ALGOR_CONFIG_PARAM__ | ... | ... |
src/ai_platform/task_param_manager.cpp
... | ... | @@ -311,6 +311,14 @@ void task_param_manager::add_task_param(string task_id, task_param task_param) { |
311 | 311 | dst_basic_param->algor_valid_rect.width_ = src_basic_param->algor_valid_rect.width_; |
312 | 312 | dst_basic_param->algor_valid_rect.height_ = src_basic_param->algor_valid_rect.height_; |
313 | 313 | |
314 | + /* 拷贝共性算法适配参数 */ | |
315 | + auto &adapt_param = src_basic_param->adapt_param; | |
316 | + if (adapt_param) { | |
317 | + dst_basic_param->adapt_param = new universal_algor_adapt_param; | |
318 | + *((universal_algor_adapt_param *)(dst_basic_param->adapt_param)) = | |
319 | + *((universal_algor_adapt_param *)adapt_param); // deep copy. | |
320 | + } | |
321 | + | |
314 | 322 | copied_algor_param->basic_param = dst_basic_param; |
315 | 323 | m_task_params[task_id][algor_config_param.algor_type] = copied_algor_param; |
316 | 324 | } |
... | ... | @@ -339,6 +347,14 @@ void task_param_manager::delete_task_param(string task_id) { |
339 | 347 | delete[] cur_param->video_folder; |
340 | 348 | cur_param->video_folder = nullptr; |
341 | 349 | } |
350 | + | |
351 | + universal_algor_adapt_param *adapt_param = | |
352 | + (universal_algor_adapt_param *)cur_param->adapt_param; | |
353 | + if (adapt_param) { | |
354 | + delete (universal_algor_adapt_param *)cur_param->adapt_param; | |
355 | + cur_param->adapt_param = nullptr; | |
356 | + } | |
357 | + | |
342 | 358 | if (cur_param) { |
343 | 359 | delete ((algor_init_config_param_t *)m_task_params[task_id][iter.first])->basic_param; |
344 | 360 | ((algor_init_config_param_t *)m_task_params[task_id][iter.first])->basic_param = nullptr; | ... | ... |
src/decoder/dvpp/DvppDecoder.cpp
... | ... | @@ -601,7 +601,6 @@ void DvppDecoder::read_thread() { |
601 | 601 | continue; |
602 | 602 | } |
603 | 603 | |
604 | - frame_nb++; | |
605 | 604 | int nSended = -1; |
606 | 605 | while ((ret = av_bsf_receive_packet(h264bsfc, pkt)) == 0) { |
607 | 606 | if(!m_bRunning){ |
... | ... | @@ -609,6 +608,7 @@ void DvppDecoder::read_thread() { |
609 | 608 | } |
610 | 609 | nSended = sendPkt(vdecChannelDesc, pkt, frame_nb); |
611 | 610 | } |
611 | + frame_nb++; | |
612 | 612 | |
613 | 613 | if(nSended < 0) { |
614 | 614 | // 执行出错,强行结束整个任务 | ... | ... |
src/demo/demo.cpp
... | ... | @@ -65,476 +65,222 @@ void init_mq_conn(void *handle) { |
65 | 65 | |
66 | 66 | void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_type_t &algor_type) { |
67 | 67 | auto algor_init_params = new algor_init_config_param_t; |
68 | - | |
69 | 68 | switch (algor_type) { |
70 | - | |
71 | - case algorithm_type_t::NONMOTOR_VEHICLE_NOHELMET: { | |
72 | - auto algor_params = new algor_config_param_manned_incident; | |
73 | - { | |
74 | - algor_params->m = 10; | |
75 | - algor_params->n = 8; | |
76 | - algor_params->obj_confidence_threshold = 0.5f; | |
77 | - algor_params->obj_min_height = 6; | |
78 | - algor_params->obj_min_width = 32; | |
79 | - } | |
80 | - | |
81 | - auto basic_params = new algor_basic_config_param_t; | |
82 | - { | |
83 | - // basic_params->algor_valid_rect.top_ = 0; | |
84 | - // basic_params->algor_valid_rect.left_ = 0; | |
85 | - // basic_params->algor_valid_rect.width_ = 1920; | |
86 | - // basic_params->algor_valid_rect.height_ = 1080; | |
87 | - basic_params->video_folder = "res/video_recode"; | |
88 | - basic_params->result_folder = "res/motor_nohelmet"; | |
89 | - basic_params->result_folder_little = "res/motor_nohelmet_little"; | |
90 | - } | |
91 | - | |
92 | - algor_init_params->algor_param = algor_params; | |
93 | - algor_init_params->basic_param = basic_params; | |
94 | - } break; | |
95 | - | |
96 | - case algorithm_type_t::NONMOTOR_VEHICLE_OVERMAN: { | |
97 | - auto algor_params = new algor_config_param_manned_incident; | |
98 | - { | |
99 | - algor_params->m = 10; | |
100 | - algor_params->n = 8; | |
101 | - algor_params->hs_count_threshold = 2; | |
102 | - algor_params->obj_confidence_threshold = 0.5f; | |
103 | - algor_params->obj_min_height = 6; | |
104 | - algor_params->obj_min_width = 32; | |
105 | - } | |
106 | - | |
107 | - auto basic_params = new algor_basic_config_param_t; | |
108 | - { | |
109 | - // basic_params->algor_valid_rect.top_ = 0; | |
110 | - // basic_params->algor_valid_rect.left_ = 0; | |
111 | - // basic_params->algor_valid_rect.width_ = 1920; | |
112 | - // basic_params->algor_valid_rect.height_ = 1080; | |
113 | - basic_params->video_folder = "res/video_recode"; | |
114 | - basic_params->result_folder = "res/motor_overman"; | |
115 | - basic_params->result_folder_little = "res/motor_overman_little"; | |
116 | - } | |
117 | - | |
118 | - algor_init_params->algor_param = algor_params; | |
119 | - algor_init_params->basic_param = basic_params; | |
120 | - } break; | |
121 | - | |
122 | - case algorithm_type_t::TRICYCLE_MANNED: { | |
123 | - auto algor_params = new algor_config_param_manned_incident; | |
124 | - { | |
125 | - algor_params->m = 10; | |
126 | - algor_params->n = 8; | |
127 | - algor_params->hs_count_threshold = 1; | |
128 | - algor_params->obj_confidence_threshold = 0.5f; | |
129 | - algor_params->obj_min_height = 6; | |
130 | - algor_params->obj_min_width = 32; | |
131 | - } | |
132 | - | |
133 | - auto basic_params = new algor_basic_config_param_t; | |
134 | - { | |
135 | - basic_params->video_folder = "res/video_recode"; | |
136 | - basic_params->result_folder = "res/tricycle_manned"; | |
137 | - basic_params->result_folder_little = "res/tricycle_manned_little"; | |
138 | - } | |
139 | - | |
140 | - algor_init_params->algor_param = algor_params; | |
141 | - algor_init_params->basic_param = basic_params; | |
142 | - } break; | |
143 | - | |
144 | - case algorithm_type_t::TRUCK_MANNED: { | |
145 | - auto algor_params = new algor_config_param_manned_incident; | |
146 | - { | |
147 | - // algor_params->m = 10; | |
148 | - // algor_params->n = 8; | |
149 | - algor_params->m = 5; | |
150 | - algor_params->n = 5; | |
151 | - algor_params->hs_count_threshold = 1; | |
152 | - algor_params->obj_confidence_threshold = 0.5f; | |
153 | - algor_params->obj_min_height = 6; | |
154 | - algor_params->obj_min_width = 32; | |
155 | - } | |
156 | - | |
157 | - auto basic_params = new algor_basic_config_param_t; | |
158 | - { | |
159 | - basic_params->video_folder = "res/video_recode"; | |
160 | - basic_params->result_folder = "res/truck_manned"; | |
161 | - basic_params->result_folder_little = "res/truck_manned_little"; | |
162 | - } | |
163 | - | |
164 | - algor_init_params->algor_param = algor_params; | |
165 | - algor_init_params->basic_param = basic_params; | |
166 | - } break; | |
167 | - | |
168 | - case algorithm_type_t::NONMOTOR_VEHICLE_USEPHONE: { | |
169 | - auto algor_params = new algor_config_param_manned_incident; | |
170 | - { | |
171 | - algor_params->m = 10; | |
172 | - algor_params->n = 8; | |
173 | - algor_params->obj_confidence_threshold = 0.5f; | |
174 | - algor_params->obj_min_height = 75; | |
175 | - algor_params->obj_min_width = 51; | |
176 | - } | |
177 | - | |
178 | - auto basic_params = new algor_basic_config_param_t; | |
179 | - { | |
180 | - basic_params->video_folder = "res/video_recode"; | |
181 | - basic_params->result_folder = "res/motor_usephone"; | |
182 | - basic_params->result_folder_little = "res/motor_usephone_little"; | |
183 | - } | |
184 | - | |
185 | - algor_init_params->algor_param = algor_params; | |
186 | - algor_init_params->basic_param = basic_params; | |
187 | - } break; | |
188 | - | |
189 | - case algorithm_type_t::NONMOTOR_VEHICLE_REFIT: { | |
190 | - auto algor_params = new algor_config_param_manned_incident; | |
191 | - { | |
192 | - algor_params->m = 10; | |
193 | - algor_params->n = 8; | |
194 | - algor_params->obj_confidence_threshold = 0.5f; | |
195 | - algor_params->obj_min_height = 75; | |
196 | - algor_params->obj_min_width = 51; | |
197 | - } | |
198 | - | |
199 | - auto basic_params = new algor_basic_config_param_t; | |
200 | - { | |
201 | - basic_params->video_folder = "res/video_recode"; | |
202 | - basic_params->result_folder = "res/motor_refit"; | |
203 | - basic_params->result_folder_little = "res/motor_refit_little"; | |
204 | - } | |
205 | - | |
206 | - algor_init_params->algor_param = algor_params; | |
207 | - algor_init_params->basic_param = basic_params; | |
208 | - } break; | |
209 | - | |
210 | - case algorithm_type_t::PERSON_RUNNING_REDLIGHTS: { | |
211 | - auto algor_params = new algor_config_param_manned_incident; | |
212 | - { | |
213 | - algor_params->m = 10; | |
214 | - algor_params->n = 8; | |
215 | - algor_params->hs_count_threshold = 1; | |
216 | - algor_params->obj_confidence_threshold = 0.5f; | |
217 | - algor_params->obj_min_height = 6; | |
218 | - algor_params->obj_min_width = 32; | |
219 | - } | |
220 | - | |
69 | + case algorithm_type_t::FACE_SNAPSHOT: { | |
221 | 70 | auto basic_params = new algor_basic_config_param_t; |
222 | 71 | { |
223 | - basic_params->video_folder = "res/video_recode"; | |
224 | - basic_params->result_folder = "res/person_runred"; | |
225 | - basic_params->result_folder_little = "res/person_runred_little"; | |
72 | + basic_params->result_folder = "res/face"; | |
73 | + basic_params->result_folder_little = "res/face_little"; | |
74 | + | |
75 | + //共性算法适配测试用 | |
76 | + auto adapt_params = new universal_algor_adapt_param; | |
77 | + { | |
78 | + adapt_params->points_count = 4; // 0表示不生效 | |
79 | + adapt_params->points[0].x_ = 505; adapt_params->points[0].y_ = 481; | |
80 | + adapt_params->points[1].x_ = 741; adapt_params->points[1].y_ = 881; | |
81 | + adapt_params->points[2].x_ = 1911; adapt_params->points[2].y_ = 667; | |
82 | + adapt_params->points[3].x_ = 1484; adapt_params->points[3].y_ = 410; | |
83 | + } | |
84 | + basic_params->adapt_param = adapt_params; | |
226 | 85 | } |
86 | + auto algor_params = new algor_config_param_snapshot; | |
87 | + { algor_params->threshold = 0.5f; } | |
227 | 88 | |
228 | 89 | algor_init_params->algor_param = algor_params; |
229 | 90 | algor_init_params->basic_param = basic_params; |
230 | 91 | } break; |
231 | 92 | |
232 | - case algorithm_type_t::NONMOTOR_RUNNING_REDLIGHTS: { | |
233 | - auto algor_params = new algor_config_param_manned_incident; | |
234 | - { | |
235 | - algor_params->m = 10; | |
236 | - algor_params->n = 8; | |
237 | - algor_params->hs_count_threshold = 0; | |
238 | - algor_params->obj_confidence_threshold = 0.5f; | |
239 | - algor_params->obj_min_height = 6; | |
240 | - algor_params->obj_min_width = 32; | |
241 | - } | |
242 | - | |
93 | + case algorithm_type_t::HUMAN_SNAPSHOT: { | |
243 | 94 | auto basic_params = new algor_basic_config_param_t; |
244 | 95 | { |
245 | - basic_params->video_folder = "res/video_recode"; | |
246 | - basic_params->result_folder = "res/motor_runred"; | |
247 | - basic_params->result_folder_little = "res/motor_runred_little"; | |
248 | - } | |
249 | - | |
250 | - algor_init_params->algor_param = algor_params; | |
251 | - algor_init_params->basic_param = basic_params; | |
252 | - } break; | |
253 | - | |
254 | - case algorithm_type_t::PERSON_IN_VEHICLELANE: { | |
255 | - auto algor_params = new algor_config_param_manned_incident; | |
256 | - { | |
257 | - algor_params->m = 10; | |
258 | - algor_params->n = 8; | |
259 | - algor_params->obj_confidence_threshold = 0.5f; | |
260 | - algor_params->obj_min_height = 6; | |
261 | - algor_params->obj_min_width = 32; | |
262 | - } | |
96 | + basic_params->result_folder = "res/human"; | |
97 | + basic_params->result_folder_little = "res/human_little"; | |
263 | 98 | |
264 | - auto basic_params = new algor_basic_config_param_t; | |
265 | - { | |
266 | - basic_params->video_folder = "res/video_recode"; | |
267 | - basic_params->result_folder = "res/person_vehiclelane"; | |
268 | - basic_params->result_folder_little = "res/person_vehiclelane_little"; | |
99 | + //共性算法适配测试用 | |
100 | + auto adapt_params = new universal_algor_adapt_param; | |
101 | + { | |
102 | + adapt_params->points_count = 4; // 0表示不生效 | |
103 | + adapt_params->points[0].x_ = 505; adapt_params->points[0].y_ = 481; | |
104 | + adapt_params->points[1].x_ = 741; adapt_params->points[1].y_ = 881; | |
105 | + adapt_params->points[2].x_ = 1911; adapt_params->points[2].y_ = 667; | |
106 | + adapt_params->points[3].x_ = 1484; adapt_params->points[3].y_ = 410; | |
107 | + } | |
108 | + basic_params->adapt_param = adapt_params; | |
269 | 109 | } |
110 | + auto algor_params = new algor_config_param_snapshot; | |
111 | + { algor_params->threshold = 0.5f; } | |
270 | 112 | |
271 | 113 | algor_init_params->algor_param = algor_params; |
272 | 114 | algor_init_params->basic_param = basic_params; |
273 | 115 | } break; |
274 | 116 | |
275 | - case algorithm_type_t::NONMOTOR_IN_VEHICLELANE: { | |
276 | - auto algor_params = new algor_config_param_manned_incident; | |
277 | - { | |
278 | - algor_params->m = 10; | |
279 | - algor_params->n = 8; | |
280 | - algor_params->obj_confidence_threshold = 0.5f; | |
281 | - algor_params->obj_min_height = 6; | |
282 | - algor_params->obj_min_width = 32; | |
117 | + case algorithm_type_t::PEDESTRIAN_FALL: { | |
118 | + auto algor_params = new algor_config_param_pedestrian_fall; | |
119 | + { | |
120 | + algor_params->threshold = 0.85f; | |
121 | + algor_params->pedestrian_min_width = 20; | |
122 | + algor_params->pedestrian_min_height = 20; | |
123 | + algor_params->pedestrian_confidence_threshold = 0.85; | |
283 | 124 | } |
284 | 125 | |
285 | 126 | auto basic_params = new algor_basic_config_param_t; |
286 | 127 | { |
287 | - basic_params->video_folder = "res/video_recode"; | |
288 | - basic_params->result_folder = "res/motor_vehiclelane"; | |
289 | - basic_params->result_folder_little = "res/motor_vehiclelane_little"; | |
290 | - } | |
291 | - | |
292 | - algor_init_params->algor_param = algor_params; | |
293 | - algor_init_params->basic_param = basic_params; | |
294 | - } break; | |
295 | - | |
296 | - case algorithm_type_t::NONMOTOR_CEOSSPARKLINE: { | |
297 | - auto algor_params = new algor_config_param_manned_incident; | |
298 | - { | |
299 | - algor_params->m = 10; | |
300 | - algor_params->n = 8; | |
301 | - algor_params->obj_confidence_threshold = 0.5f; | |
302 | - algor_params->obj_min_height = 6; | |
303 | - algor_params->obj_min_width = 32; | |
304 | - } | |
128 | + basic_params->result_folder = "res/fall"; | |
129 | + basic_params->result_folder_little = "res/fall_little"; | |
305 | 130 | |
306 | - auto basic_params = new algor_basic_config_param_t; | |
307 | - { | |
308 | - basic_params->video_folder = "res/video_recode"; | |
309 | - basic_params->result_folder = "res/motor_crossparkline"; | |
310 | - basic_params->result_folder_little = "res/motor_crossparkline_little"; | |
131 | + auto adapt_params = new universal_algor_adapt_param; | |
132 | + { | |
133 | + adapt_params->points_count = 4; // 0表示不生效 | |
134 | + adapt_params->points[0].x_ = 0; adapt_params->points[0].y_ = 0; | |
135 | + adapt_params->points[1].x_ = 1920; adapt_params->points[1].y_ = 0; | |
136 | + adapt_params->points[2].x_ = 1920; adapt_params->points[2].y_ = 1080; | |
137 | + adapt_params->points[3].x_ = 0; adapt_params->points[3].y_ = 1080; | |
138 | + } | |
139 | + basic_params->adapt_param = adapt_params; | |
311 | 140 | } |
312 | 141 | |
313 | 142 | algor_init_params->algor_param = algor_params; |
314 | 143 | algor_init_params->basic_param = basic_params; |
315 | 144 | } break; |
316 | 145 | |
317 | - case algorithm_type_t::PERSON_CROSS: { | |
318 | - auto algor_params = new algor_config_param_manned_incident; | |
146 | + case algorithm_type_t::PEDESTRIAN_FIGHT: { | |
147 | + auto algor_params = new algor_config_param_pedestrian_fight; | |
319 | 148 | { |
320 | - algor_params->m = 10; | |
321 | - algor_params->n = 8; | |
322 | - algor_params->obj_confidence_threshold = 0.5f; | |
323 | - algor_params->obj_min_height = 6; | |
324 | - algor_params->obj_min_width = 32; | |
149 | + algor_params->threshold = 0.85f; | |
150 | + algor_params->pedestrian_min_width = 20; | |
151 | + algor_params->pedestrian_min_height = 20; | |
152 | + algor_params->pedestrian_confidence_threshold = 0.85; | |
325 | 153 | } |
326 | 154 | |
327 | 155 | auto basic_params = new algor_basic_config_param_t; |
328 | 156 | { |
329 | - basic_params->video_folder = "res/video_recode"; | |
330 | - basic_params->result_folder = "res/person_cross"; | |
331 | - basic_params->result_folder_little = "res/person_cross_little"; | |
332 | - } | |
333 | - | |
334 | - algor_init_params->algor_param = algor_params; | |
335 | - algor_init_params->basic_param = basic_params; | |
336 | - } break; | |
337 | - | |
338 | - case algorithm_type_t::NONMOTOR_WRONGDIRECTION: { | |
339 | - auto algor_params = new algor_config_param_manned_incident; | |
340 | - { | |
341 | - algor_params->m = 10; | |
342 | - algor_params->n = 8; | |
343 | - algor_params->obj_confidence_threshold = 0.5f; | |
344 | - algor_params->obj_min_height = 6; | |
345 | - algor_params->obj_min_width = 32; | |
346 | - } | |
157 | + basic_params->result_folder = "res/fight"; | |
158 | + basic_params->result_folder_little = "res/fight_little"; | |
347 | 159 | |
348 | - auto basic_params = new algor_basic_config_param_t; | |
349 | - { | |
350 | - basic_params->video_folder = "res/video_recode"; | |
351 | - basic_params->result_folder = "res/motor_wrongdirection"; | |
352 | - basic_params->result_folder_little = "res/motor_wrongdirection_little"; | |
160 | + auto adapt_params = new universal_algor_adapt_param; | |
161 | + { | |
162 | + adapt_params->points_count = 4; // 0表示不生效 | |
163 | + adapt_params->points[0].x_ = 0; adapt_params->points[0].y_ = 0; | |
164 | + adapt_params->points[1].x_ = 1920; adapt_params->points[1].y_ = 0; | |
165 | + adapt_params->points[2].x_ = 1920; adapt_params->points[2].y_ = 1080; | |
166 | + adapt_params->points[3].x_ = 0; adapt_params->points[3].y_ = 1080; | |
167 | + } | |
168 | + basic_params->adapt_param = adapt_params; | |
353 | 169 | } |
354 | 170 | |
355 | 171 | algor_init_params->algor_param = algor_params; |
356 | 172 | algor_init_params->basic_param = basic_params; |
357 | 173 | } break; |
358 | 174 | |
359 | - case algorithm_type_t::VEHICLE_WRONGDIRECTION: { | |
360 | - auto algor_params = new algor_config_param_manned_incident; | |
361 | - { | |
362 | - algor_params->m = 5; | |
363 | - algor_params->n = 5; | |
364 | - algor_params->obj_confidence_threshold = 0.5f; | |
365 | - algor_params->obj_min_height = 60; | |
366 | - algor_params->obj_min_width = 60; | |
367 | - } | |
368 | - | |
369 | - auto basic_params = new algor_basic_config_param_t; | |
370 | - { | |
371 | - basic_params->video_folder = "res/video_recode"; | |
372 | - basic_params->result_folder = "res/vehicle_wrongdirection"; | |
373 | - basic_params->result_folder_little = "res/vehicle_wrongdirection_little"; | |
374 | - } | |
375 | - | |
376 | - algor_init_params->algor_param = algor_params; | |
377 | - algor_init_params->basic_param = basic_params; | |
378 | - } break; | |
175 | + case algorithm_type_t::HUMAN_GATHER: { | |
379 | 176 | |
380 | - case algorithm_type_t::VEHICLE_NOTGIVEWAY: { | |
381 | - auto algor_params = new algor_config_param_manned_incident; | |
177 | + auto algor_params = new algor_config_param_human_gather; | |
382 | 178 | { |
383 | - algor_params->m = 10; | |
384 | - algor_params->n = 8; | |
385 | - algor_params->obj_confidence_threshold = 0.5f; | |
386 | - algor_params->obj_min_height = 40; | |
387 | - algor_params->obj_min_width = 40; | |
179 | + algor_params->frame_stride = 3; | |
180 | + algor_params->human_count_threshold = 3; | |
388 | 181 | } |
389 | 182 | |
390 | 183 | auto basic_params = new algor_basic_config_param_t; |
391 | 184 | { |
392 | - basic_params->video_folder = "res/video_recode"; | |
393 | - basic_params->result_folder = "res/vehicle_notgiveway"; | |
394 | - basic_params->result_folder_little = "res/vehicle_notgiveway_little"; | |
395 | - } | |
396 | - | |
397 | - algor_init_params->algor_param = algor_params; | |
398 | - algor_init_params->basic_param = basic_params; | |
399 | - } break; | |
400 | - | |
401 | - case algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND: { | |
402 | - auto algor_params = new algor_config_param_manned_incident; | |
403 | - { | |
404 | - algor_params->m = 10; | |
405 | - algor_params->n = 8; | |
406 | - algor_params->obj_confidence_threshold = 0.5f; | |
407 | - algor_params->obj_min_height = 40; | |
408 | - algor_params->obj_min_width = 40; | |
409 | - } | |
185 | + basic_params->result_folder = "res/gather"; | |
186 | + basic_params->result_folder_little = "res/gather_little"; | |
410 | 187 | |
411 | - auto basic_params = new algor_basic_config_param_t; | |
412 | - { | |
413 | - basic_params->video_folder = "res/video_recode"; | |
414 | - basic_params->result_folder = "res/vehicle_solid_turnaround"; | |
415 | - basic_params->result_folder_little = "res/vehicle_solid_turnaround_little"; | |
188 | + //共性算法适配测试用 | |
189 | + auto adapt_params = new universal_algor_adapt_param; | |
190 | + { | |
191 | + adapt_params->points_count = 4; // 0表示不生效 | |
192 | + adapt_params->points[0].x_ = 505; adapt_params->points[0].y_ = 481; | |
193 | + adapt_params->points[1].x_ = 741; adapt_params->points[1].y_ = 881; | |
194 | + adapt_params->points[2].x_ = 1911; adapt_params->points[2].y_ = 667; | |
195 | + adapt_params->points[3].x_ = 1484; adapt_params->points[3].y_ = 410; | |
196 | + } | |
197 | + basic_params->adapt_param = adapt_params; | |
416 | 198 | } |
417 | 199 | |
418 | 200 | algor_init_params->algor_param = algor_params; |
419 | 201 | algor_init_params->basic_param = basic_params; |
420 | 202 | } break; |
421 | - | |
422 | - case algorithm_type_t::VEHICLE_NOTDECELERATION: { | |
423 | - auto algor_params = new algor_config_param_manned_incident; | |
424 | - { | |
425 | - algor_params->m = 10; | |
426 | - algor_params->n = 8; | |
427 | - algor_params->obj_confidence_threshold = 0.5f; | |
428 | - algor_params->obj_min_height = 40; | |
429 | - algor_params->obj_min_width = 40; | |
430 | - } | |
431 | - | |
432 | - auto basic_params = new algor_basic_config_param_t; | |
433 | - { | |
434 | - basic_params->video_folder = "res/video_recode"; | |
435 | - basic_params->result_folder = "res/vehicle_not_deceleration"; | |
436 | - basic_params->result_folder_little = "res/vehicle_not_deceleration_little"; | |
437 | - } | |
438 | 203 | |
439 | - algor_init_params->algor_param = algor_params; | |
440 | - algor_init_params->basic_param = basic_params; | |
441 | - } break; | |
204 | + case algorithm_type_t::HUMAN_REGION_GATHER: { | |
442 | 205 | |
443 | - | |
444 | - case algorithm_type_t::FACE_SNAPSHOT: { | |
445 | - auto basic_params = new algor_basic_config_param_t; | |
206 | + auto algor_params = new algor_config_param_human_gather; | |
446 | 207 | { |
447 | - basic_params->algor_valid_rect.top_ = 0; | |
448 | - basic_params->algor_valid_rect.left_ = 0; | |
449 | - basic_params->algor_valid_rect.width_ = 1920; | |
450 | - basic_params->algor_valid_rect.height_ = 1080; | |
451 | - | |
452 | - basic_params->result_folder = "res/face"; | |
453 | - basic_params->result_folder_little = "res/face_little"; | |
208 | + algor_params->frame_stride = 3; | |
209 | + algor_params->human_count_threshold = 3; | |
454 | 210 | } |
455 | - auto algor_params = new algor_config_param_snapshot; | |
456 | - { algor_params->threshold = 0.5f; } | |
457 | - | |
458 | - algor_init_params->algor_param = algor_params; | |
459 | - algor_init_params->basic_param = basic_params; | |
460 | - } break; | |
461 | 211 | |
462 | - case algorithm_type_t::HUMAN_SNAPSHOT: { | |
463 | 212 | auto basic_params = new algor_basic_config_param_t; |
464 | 213 | { |
465 | - basic_params->algor_valid_rect.top_ = 0; | |
466 | - basic_params->algor_valid_rect.left_ = 0; | |
467 | - basic_params->algor_valid_rect.width_ = 1920; | |
468 | - basic_params->algor_valid_rect.height_ = 1080; | |
469 | - | |
470 | - basic_params->result_folder = "res/human"; | |
471 | - basic_params->result_folder_little = "res/human_little"; | |
214 | + basic_params->result_folder = "res/region_gather"; | |
215 | + basic_params->result_folder_little = "res/region_gather_little"; | |
216 | + | |
217 | + //共性算法适配测试用 | |
218 | + auto adapt_params = new universal_algor_adapt_param; | |
219 | + { | |
220 | + adapt_params->points_count = 4; // 0表示不生效 | |
221 | + adapt_params->points[0].x_ = 505; adapt_params->points[0].y_ = 481; | |
222 | + adapt_params->points[1].x_ = 741; adapt_params->points[1].y_ = 881; | |
223 | + adapt_params->points[2].x_ = 1911; adapt_params->points[2].y_ = 667; | |
224 | + adapt_params->points[3].x_ = 1484; adapt_params->points[3].y_ = 410; | |
225 | + } | |
226 | + basic_params->adapt_param = adapt_params; | |
472 | 227 | } |
473 | - auto algor_params = new algor_config_param_snapshot; | |
474 | - { algor_params->threshold = 0.5f; } | |
475 | 228 | |
476 | 229 | algor_init_params->algor_param = algor_params; |
477 | 230 | algor_init_params->basic_param = basic_params; |
478 | 231 | } break; |
479 | 232 | |
480 | - case algorithm_type_t::PEDESTRIAN_FALL: { | |
481 | - auto algor_params = new algor_config_param_pedestrian_fall; | |
482 | - { algor_params->threshold = 0.7f; } | |
233 | + case algorithm_type_t::HUMAN_DENSITY: { | |
483 | 234 | |
484 | - auto basic_params = new algor_basic_config_param_t; | |
485 | - { | |
486 | - basic_params->algor_valid_rect.top_ = 0; | |
487 | - basic_params->algor_valid_rect.left_ = 0; | |
488 | - basic_params->algor_valid_rect.width_ = 1920; | |
489 | - basic_params->algor_valid_rect.height_ = 1080; | |
490 | - | |
491 | - basic_params->result_folder = "res/fall"; | |
492 | - basic_params->result_folder_little = "res/fall_little"; | |
493 | - } | |
494 | - | |
495 | - algor_init_params->algor_param = algor_params; | |
496 | - algor_init_params->basic_param = basic_params; | |
497 | - } break; | |
498 | - | |
499 | - case algorithm_type_t::PEDESTRIAN_FIGHT: { | |
500 | - auto algor_params = new algor_config_param_pedestrian_fight; | |
235 | + auto algor_params = new algor_config_param_human_gather; | |
501 | 236 | { |
502 | - algor_params->threshold = 0.7f; | |
503 | - algor_params->iou_threshold = 0.1f; | |
237 | + algor_params->frame_stride = 3; | |
238 | + algor_params->human_count_threshold = 3; | |
504 | 239 | } |
505 | 240 | |
506 | 241 | auto basic_params = new algor_basic_config_param_t; |
507 | 242 | { |
508 | - | |
509 | - basic_params->algor_valid_rect.top_ = 0; | |
510 | - basic_params->algor_valid_rect.left_ = 0; | |
511 | - basic_params->algor_valid_rect.width_ = 1920; | |
512 | - basic_params->algor_valid_rect.height_ = 1080; | |
513 | - basic_params->result_folder = "res/fight"; | |
514 | - basic_params->result_folder_little = "res/fight_little"; | |
243 | + basic_params->result_folder = "res/human_density"; | |
244 | + basic_params->result_folder_little = "res/human_density_little"; | |
245 | + | |
246 | + //共性算法适配测试用 | |
247 | + auto adapt_params = new universal_algor_adapt_param; | |
248 | + { | |
249 | + adapt_params->points_count = 4; // 0表示不生效 | |
250 | + adapt_params->points[0].x_ = 505; adapt_params->points[0].y_ = 481; | |
251 | + adapt_params->points[1].x_ = 741; adapt_params->points[1].y_ = 881; | |
252 | + adapt_params->points[2].x_ = 1911; adapt_params->points[2].y_ = 667; | |
253 | + adapt_params->points[3].x_ = 1484; adapt_params->points[3].y_ = 410; | |
254 | + } | |
255 | + basic_params->adapt_param = adapt_params; | |
515 | 256 | } |
516 | 257 | |
517 | 258 | algor_init_params->algor_param = algor_params; |
518 | 259 | algor_init_params->basic_param = basic_params; |
519 | 260 | } break; |
520 | 261 | |
521 | - case algorithm_type_t::HUMAN_GATHER: { | |
262 | + case algorithm_type_t::VEHICLE_GATHER: { | |
522 | 263 | |
523 | 264 | auto algor_params = new algor_config_param_human_gather; |
524 | 265 | { |
525 | - algor_params->frame_stride = 1; | |
526 | - // algor_params->human_count_threshold = 3; | |
266 | + algor_params->frame_stride = 3; | |
527 | 267 | algor_params->human_count_threshold = 1; |
528 | 268 | } |
529 | 269 | |
530 | 270 | auto basic_params = new algor_basic_config_param_t; |
531 | 271 | { |
532 | - basic_params->algor_valid_rect.top_ = 0; | |
533 | - basic_params->algor_valid_rect.left_ = 0; | |
534 | - basic_params->algor_valid_rect.width_ = 1920; | |
535 | - basic_params->algor_valid_rect.height_ = 1080; | |
536 | - basic_params->result_folder = "res/gather"; | |
537 | - basic_params->result_folder_little = "res/gather_little"; | |
272 | + basic_params->result_folder = "res/vehicle_gather"; | |
273 | + basic_params->result_folder_little = "res/vehicle_gather_little"; | |
274 | + | |
275 | + auto adapt_params = new universal_algor_adapt_param; | |
276 | + { | |
277 | + adapt_params->points_count = 4; // 0表示不生效 | |
278 | + adapt_params->points[0].x_ = 505; adapt_params->points[0].y_ = 481; | |
279 | + adapt_params->points[1].x_ = 741; adapt_params->points[1].y_ = 881; | |
280 | + adapt_params->points[2].x_ = 1911; adapt_params->points[2].y_ = 667; | |
281 | + adapt_params->points[3].x_ = 1484; adapt_params->points[3].y_ = 410; | |
282 | + } | |
283 | + basic_params->adapt_param = adapt_params; | |
538 | 284 | } |
539 | 285 | |
540 | 286 | algor_init_params->algor_param = algor_params; |
... | ... | @@ -554,12 +300,11 @@ void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_ty |
554 | 300 | |
555 | 301 | auto basic_params = new algor_basic_config_param_t; |
556 | 302 | { |
557 | - basic_params->algor_valid_rect.top_ = 0; | |
558 | - basic_params->algor_valid_rect.left_ = 0; | |
559 | - basic_params->algor_valid_rect.width_ = 1920; | |
560 | - basic_params->algor_valid_rect.height_ = 1080; | |
561 | 303 | basic_params->result_folder = "res/no_reflective_clothing"; |
562 | 304 | basic_params->result_folder_little = "res/no_reflective_clothing_little"; |
305 | + | |
306 | + auto adapt_params = new universal_algor_adapt_param; | |
307 | + basic_params->adapt_param = adapt_params; | |
563 | 308 | } |
564 | 309 | |
565 | 310 | algor_init_params->algor_param = algor_params; |
... | ... | @@ -579,12 +324,11 @@ void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_ty |
579 | 324 | |
580 | 325 | auto basic_params = new algor_basic_config_param_t; |
581 | 326 | { |
582 | - basic_params->algor_valid_rect.top_ = 0; | |
583 | - basic_params->algor_valid_rect.left_ = 0; | |
584 | - basic_params->algor_valid_rect.width_ = 1920; | |
585 | - basic_params->algor_valid_rect.height_ = 1080; | |
586 | 327 | basic_params->result_folder = "res/no_safety_helmet"; |
587 | 328 | basic_params->result_folder_little = "res/no_safety_helmet_little"; |
329 | + | |
330 | + auto adapt_params = new universal_algor_adapt_param; | |
331 | + basic_params->adapt_param = adapt_params; | |
588 | 332 | } |
589 | 333 | |
590 | 334 | algor_init_params->algor_param = algor_params; |
... | ... | @@ -604,12 +348,11 @@ void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_ty |
604 | 348 | |
605 | 349 | auto basic_params = new algor_basic_config_param_t; |
606 | 350 | { |
607 | - basic_params->algor_valid_rect.top_ = 0; | |
608 | - basic_params->algor_valid_rect.left_ = 0; | |
609 | - basic_params->algor_valid_rect.width_ = 1920; | |
610 | - basic_params->algor_valid_rect.height_ = 1080; | |
611 | 351 | basic_params->result_folder = "res/call_phone"; |
612 | 352 | basic_params->result_folder_little = "res/call_phone_little"; |
353 | + | |
354 | + auto adapt_params = new universal_algor_adapt_param; | |
355 | + basic_params->adapt_param = adapt_params; | |
613 | 356 | } |
614 | 357 | |
615 | 358 | algor_init_params->algor_param = algor_params; |
... | ... | @@ -629,12 +372,11 @@ void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_ty |
629 | 372 | |
630 | 373 | auto basic_params = new algor_basic_config_param_t; |
631 | 374 | { |
632 | - basic_params->algor_valid_rect.top_ = 0; | |
633 | - basic_params->algor_valid_rect.left_ = 0; | |
634 | - basic_params->algor_valid_rect.width_ = 1920; | |
635 | - basic_params->algor_valid_rect.height_ = 1080; | |
636 | 375 | basic_params->result_folder = "res/smoking"; |
637 | 376 | basic_params->result_folder_little = "res/smoking_little"; |
377 | + | |
378 | + auto adapt_params = new universal_algor_adapt_param; | |
379 | + basic_params->adapt_param = adapt_params; | |
638 | 380 | } |
639 | 381 | |
640 | 382 | algor_init_params->algor_param = algor_params; |
... | ... | @@ -645,18 +387,25 @@ void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_ty |
645 | 387 | |
646 | 388 | auto basic_params = new algor_basic_config_param_t; |
647 | 389 | { |
648 | - basic_params->algor_valid_rect.top_ = 0; | |
649 | - basic_params->algor_valid_rect.left_ = 0; | |
650 | - basic_params->algor_valid_rect.width_ = 1920; | |
651 | - basic_params->algor_valid_rect.height_ = 1080; | |
652 | 390 | basic_params->result_folder = "res/vehicle"; |
653 | 391 | basic_params->result_folder_little = "res/vehicle_little"; |
392 | + | |
393 | + //共性算法适配测试用 | |
394 | + auto adapt_params = new universal_algor_adapt_param; | |
395 | + { | |
396 | + adapt_params->points_count = 4; // 0表示不生效 | |
397 | + adapt_params->points[0].x_ = 505; adapt_params->points[0].y_ = 481; | |
398 | + adapt_params->points[1].x_ = 741; adapt_params->points[1].y_ = 881; | |
399 | + adapt_params->points[2].x_ = 1911; adapt_params->points[2].y_ = 667; | |
400 | + adapt_params->points[3].x_ = 1484; adapt_params->points[3].y_ = 410; | |
401 | + } | |
402 | + basic_params->adapt_param = adapt_params; | |
654 | 403 | } |
655 | - | |
656 | 404 | auto algor_params = new algor_config_param_snapshot; |
657 | - algor_params->threshold = 0.5f; | |
658 | - algor_params->snap_frame_interval = 5; | |
659 | - | |
405 | + { | |
406 | + algor_params->threshold = 0.5f; | |
407 | + algor_params->snap_frame_interval = 1; | |
408 | + } | |
660 | 409 | algor_init_params->algor_param = algor_params; |
661 | 410 | algor_init_params->basic_param = basic_params; |
662 | 411 | } break; |
... | ... | @@ -665,12 +414,18 @@ void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_ty |
665 | 414 | |
666 | 415 | auto basic_params = new algor_basic_config_param_t; |
667 | 416 | { |
668 | - basic_params->algor_valid_rect.top_ = 0; | |
669 | - basic_params->algor_valid_rect.left_ = 0; | |
670 | - basic_params->algor_valid_rect.width_ = 1920; | |
671 | - basic_params->algor_valid_rect.height_ = 1080; | |
672 | 417 | basic_params->result_folder = "res/nonmotor"; |
673 | 418 | basic_params->result_folder_little = "res/nonmotor_little"; |
419 | + | |
420 | + auto adapt_params = new universal_algor_adapt_param; | |
421 | + { | |
422 | + adapt_params->points_count = 4; // 0表示不生效 | |
423 | + adapt_params->points[0].x_ = 505; adapt_params->points[0].y_ = 481; | |
424 | + adapt_params->points[1].x_ = 741; adapt_params->points[1].y_ = 881; | |
425 | + adapt_params->points[2].x_ = 1911; adapt_params->points[2].y_ = 667; | |
426 | + adapt_params->points[3].x_ = 1484; adapt_params->points[3].y_ = 410; | |
427 | + } | |
428 | + basic_params->adapt_param = adapt_params; | |
674 | 429 | } |
675 | 430 | |
676 | 431 | auto algor_params = new algor_config_param_snapshot; |
... | ... | @@ -679,6 +434,7 @@ void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_ty |
679 | 434 | algor_init_params->algor_param = algor_params; |
680 | 435 | algor_init_params->basic_param = basic_params; |
681 | 436 | } break; |
437 | + | |
682 | 438 | |
683 | 439 | case algorithm_type_t::TAKEAWAY_MEMBER_CLASSIFICATION: { |
684 | 440 | auto algor_params = new algor_config_param_takeaway_member_classification; |
... | ... | @@ -690,12 +446,11 @@ void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_ty |
690 | 446 | |
691 | 447 | auto basic_params = new algor_basic_config_param_t; |
692 | 448 | { |
693 | - basic_params->algor_valid_rect.top_ = 0; | |
694 | - basic_params->algor_valid_rect.left_ = 0; | |
695 | - basic_params->algor_valid_rect.width_ = 1920; | |
696 | - basic_params->algor_valid_rect.height_ = 1080; | |
697 | 449 | basic_params->result_folder = "res/takeaway"; |
698 | 450 | basic_params->result_folder_little = "res/takeaway_little"; |
451 | + | |
452 | + auto adapt_params = new universal_algor_adapt_param; | |
453 | + basic_params->adapt_param = adapt_params; | |
699 | 454 | } |
700 | 455 | |
701 | 456 | algor_init_params->algor_param = algor_params; |
... | ... | @@ -720,12 +475,11 @@ void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_ty |
720 | 475 | |
721 | 476 | auto basic_params = new algor_basic_config_param_t; |
722 | 477 | { |
723 | - basic_params->algor_valid_rect.top_ = 0; | |
724 | - basic_params->algor_valid_rect.left_ = 0; | |
725 | - basic_params->algor_valid_rect.width_ = 1920; | |
726 | - basic_params->algor_valid_rect.height_ = 1080; | |
727 | 478 | basic_params->result_folder = "res/pedestrian_retrograde"; |
728 | 479 | basic_params->result_folder_little = "res/pedestrian_retrograde_little"; |
480 | + | |
481 | + auto adapt_params = new universal_algor_adapt_param; | |
482 | + basic_params->adapt_param = adapt_params; | |
729 | 483 | } |
730 | 484 | |
731 | 485 | algor_init_params->algor_param = algor_params; |
... | ... | @@ -751,13 +505,10 @@ void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_ty |
751 | 505 | |
752 | 506 | auto basic_params = new algor_basic_config_param_t; |
753 | 507 | { |
754 | - basic_params->algor_valid_rect.top_ = 0; | |
755 | - | |
756 | - basic_params->algor_valid_rect.left_ = 0; | |
757 | - basic_params->algor_valid_rect.width_ = 1920; | |
758 | - basic_params->algor_valid_rect.height_ = 1080; | |
759 | 508 | basic_params->result_folder = "res/vehicle_retrograde"; |
760 | 509 | basic_params->result_folder_little = "res/vehicle_retrograde_little"; |
510 | + auto adapt_params = new universal_algor_adapt_param; | |
511 | + basic_params->adapt_param = adapt_params; | |
761 | 512 | } |
762 | 513 | |
763 | 514 | algor_init_params->algor_param = algor_params; |
... | ... | @@ -770,31 +521,123 @@ void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_ty |
770 | 521 | auto algor_params = new algor_config_param_pedestrian_trespass; |
771 | 522 | { |
772 | 523 | algor_params->conf_threshold = 0.5f; |
773 | - algor_params->minmum_height = 64; | |
774 | - algor_params->minmum_width = 32; | |
524 | + algor_params->minmum_height = 20; | |
525 | + algor_params->minmum_width = 20; | |
775 | 526 | algor_params->points_count = 4; |
776 | 527 | |
777 | - algor_params->points[0].x_ = 200; | |
778 | - algor_params->points[0].y_ = 200; | |
528 | + algor_params->points[0].x_ = 505; | |
529 | + algor_params->points[0].y_ = 481; | |
779 | 530 | |
780 | - algor_params->points[1].x_ = 600; | |
781 | - algor_params->points[1].y_ = 200; | |
531 | + algor_params->points[1].x_ = 741; | |
532 | + algor_params->points[1].y_ = 881; | |
782 | 533 | |
783 | - algor_params->points[2].x_ = 600; | |
784 | - algor_params->points[2].y_ = 500; | |
534 | + algor_params->points[2].x_ = 1911; | |
535 | + algor_params->points[2].y_ = 667; | |
785 | 536 | |
786 | - algor_params->points[3].x_ = 200; | |
787 | - algor_params->points[3].y_ = 500; | |
537 | + algor_params->points[3].x_ = 1484; | |
538 | + algor_params->points[3].y_ = 410; | |
788 | 539 | } |
789 | 540 | |
790 | 541 | auto basic_params = new algor_basic_config_param_t; |
791 | 542 | { |
792 | - basic_params->algor_valid_rect.top_ = 0; | |
793 | - basic_params->algor_valid_rect.left_ = 0; | |
794 | - basic_params->algor_valid_rect.width_ = 1920; | |
795 | - basic_params->algor_valid_rect.height_ = 1080; | |
796 | 543 | basic_params->result_folder = "res/pedestrian_trespass"; |
797 | 544 | basic_params->result_folder_little = "res/pedestrian_trespass_little"; |
545 | + auto adapt_params = new universal_algor_adapt_param; | |
546 | + { | |
547 | + adapt_params->points_count = 4; // 0表示不生效 | |
548 | + adapt_params->points[0].x_ = 0; adapt_params->points[0].y_ = 0; | |
549 | + adapt_params->points[1].x_ = 1920; adapt_params->points[1].y_ = 0; | |
550 | + adapt_params->points[2].x_ = 1920; adapt_params->points[2].y_ = 1080; | |
551 | + adapt_params->points[3].x_ = 0; adapt_params->points[3].y_ = 1080; | |
552 | + } | |
553 | + basic_params->adapt_param = adapt_params; | |
554 | + } | |
555 | + | |
556 | + algor_init_params->algor_param = algor_params; | |
557 | + algor_init_params->basic_param = basic_params; | |
558 | + | |
559 | + } break; | |
560 | + | |
561 | + case algorithm_type_t::HUMAN_LEAVE_REGION: { | |
562 | + // 578 1300 600 | |
563 | + auto algor_params = new algor_config_param_trespass_basic; | |
564 | + { | |
565 | + algor_params->conf_threshold = 0.5f; | |
566 | + algor_params->minmum_height = 20; | |
567 | + algor_params->minmum_width = 20; | |
568 | + } | |
569 | + | |
570 | + auto basic_params = new algor_basic_config_param_t; | |
571 | + { | |
572 | + basic_params->result_folder = "res/human_region_leave"; | |
573 | + basic_params->result_folder_little = "res/human_region_leave_little"; | |
574 | + auto adapt_params = new universal_algor_adapt_param; | |
575 | + { | |
576 | + adapt_params->points_count = 4; // 0表示不生效 | |
577 | + adapt_params->points[0].x_ = 505; adapt_params->points[0].y_ = 481; | |
578 | + adapt_params->points[1].x_ = 741; adapt_params->points[1].y_ = 881; | |
579 | + adapt_params->points[2].x_ = 1911; adapt_params->points[2].y_ = 667; | |
580 | + adapt_params->points[3].x_ = 1484; adapt_params->points[3].y_ = 410; | |
581 | + } | |
582 | + basic_params->adapt_param = adapt_params; | |
583 | + } | |
584 | + | |
585 | + algor_init_params->algor_param = algor_params; | |
586 | + algor_init_params->basic_param = basic_params; | |
587 | + | |
588 | + } break; | |
589 | + | |
590 | + case algorithm_type_t::HUMAN_REGION_DISMISS: { | |
591 | + // 578 1300 600 | |
592 | + auto algor_params = new algor_config_param_trespass_basic; | |
593 | + { | |
594 | + algor_params->conf_threshold = 0.5f; | |
595 | + algor_params->minmum_height = 20; | |
596 | + algor_params->minmum_width = 20; | |
597 | + } | |
598 | + | |
599 | + auto basic_params = new algor_basic_config_param_t; | |
600 | + { | |
601 | + basic_params->result_folder = "res/human_region_dismiss"; | |
602 | + basic_params->result_folder_little = "res/human_region_dismiss_little"; | |
603 | + auto adapt_params = new universal_algor_adapt_param; | |
604 | + { | |
605 | + adapt_params->points_count = 4; // 0表示不生效 | |
606 | + adapt_params->points[0].x_ = 505; adapt_params->points[0].y_ = 481; | |
607 | + adapt_params->points[1].x_ = 741; adapt_params->points[1].y_ = 881; | |
608 | + adapt_params->points[2].x_ = 1911; adapt_params->points[2].y_ = 667; | |
609 | + adapt_params->points[3].x_ = 1484; adapt_params->points[3].y_ = 410; | |
610 | + } | |
611 | + basic_params->adapt_param = adapt_params; | |
612 | + } | |
613 | + | |
614 | + algor_init_params->algor_param = algor_params; | |
615 | + algor_init_params->basic_param = basic_params; | |
616 | + | |
617 | + } break; | |
618 | + | |
619 | + case algorithm_type_t::HUMAN_REGION_FAST_MOVING: { | |
620 | + // 578 1300 600 | |
621 | + auto algor_params = new algor_config_param_trespass_basic; | |
622 | + { | |
623 | + algor_params->conf_threshold = 0.5f; | |
624 | + algor_params->minmum_height = 20; | |
625 | + algor_params->minmum_width = 20; | |
626 | + } | |
627 | + | |
628 | + auto basic_params = new algor_basic_config_param_t; | |
629 | + { | |
630 | + basic_params->result_folder = "res/human_region_fastmoving"; | |
631 | + basic_params->result_folder_little = "res/human_region_fastmoving_little"; | |
632 | + auto adapt_params = new universal_algor_adapt_param; | |
633 | + { | |
634 | + adapt_params->points_count = 4; // 0表示不生效 | |
635 | + adapt_params->points[0].x_ = 505; adapt_params->points[0].y_ = 481; | |
636 | + adapt_params->points[1].x_ = 741; adapt_params->points[1].y_ = 881; | |
637 | + adapt_params->points[2].x_ = 1911; adapt_params->points[2].y_ = 667; | |
638 | + adapt_params->points[3].x_ = 1484; adapt_params->points[3].y_ = 410; | |
639 | + } | |
640 | + basic_params->adapt_param = adapt_params; | |
798 | 641 | } |
799 | 642 | |
800 | 643 | algor_init_params->algor_param = algor_params; |
... | ... | @@ -807,31 +650,36 @@ void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_ty |
807 | 650 | auto algor_params = new algor_config_param_vehicle_trespass; |
808 | 651 | { |
809 | 652 | algor_params->conf_threshold = 0.5f; |
810 | - algor_params->minmum_height = 64; | |
811 | - algor_params->minmum_width = 64; | |
812 | - algor_params->points_count = 4; | |
653 | + algor_params->minmum_height = 20; | |
654 | + algor_params->minmum_width = 20; | |
813 | 655 | |
814 | - algor_params->points[0].x_ = 500; | |
815 | - algor_params->points[0].y_ = 500; | |
656 | + algor_params->points_count = 4; | |
657 | + algor_params->points[0].x_ = 505; | |
658 | + algor_params->points[0].y_ = 481; | |
816 | 659 | |
817 | - algor_params->points[1].x_ = 1500; | |
818 | - algor_params->points[1].y_ = 500; | |
660 | + algor_params->points[1].x_ = 741; | |
661 | + algor_params->points[1].y_ = 881; | |
819 | 662 | |
820 | - algor_params->points[2].x_ = 1500; | |
821 | - algor_params->points[2].y_ = 900; | |
663 | + algor_params->points[2].x_ = 1911; | |
664 | + algor_params->points[2].y_ = 667; | |
822 | 665 | |
823 | - algor_params->points[3].x_ = 500; | |
824 | - algor_params->points[3].y_ = 900; | |
666 | + algor_params->points[3].x_ = 1484; | |
667 | + algor_params->points[3].y_ = 410; | |
825 | 668 | } |
826 | 669 | |
827 | 670 | auto basic_params = new algor_basic_config_param_t; |
828 | 671 | { |
829 | - basic_params->algor_valid_rect.top_ = 0; | |
830 | - basic_params->algor_valid_rect.left_ = 0; | |
831 | - basic_params->algor_valid_rect.width_ = 1920; | |
832 | - basic_params->algor_valid_rect.height_ = 1080; | |
833 | 672 | basic_params->result_folder = "res/vehicle_trespass"; |
834 | 673 | basic_params->result_folder_little = "res/vehicle_trespass_little"; |
674 | + auto adapt_params = new universal_algor_adapt_param; | |
675 | + { | |
676 | + adapt_params->points_count = 4; // 0表示不生效 | |
677 | + adapt_params->points[0].x_ = 0; adapt_params->points[0].y_ = 0; | |
678 | + adapt_params->points[1].x_ = 1920; adapt_params->points[1].y_ = 0; | |
679 | + adapt_params->points[2].x_ = 1920; adapt_params->points[2].y_ = 1080; | |
680 | + adapt_params->points[3].x_ = 0; adapt_params->points[3].y_ = 1080; | |
681 | + } | |
682 | + basic_params->adapt_param = adapt_params; | |
835 | 683 | } |
836 | 684 | |
837 | 685 | algor_init_params->algor_param = algor_params; |
... | ... | @@ -858,12 +706,6 @@ void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_ty |
858 | 706 | |
859 | 707 | auto basic_params = new algor_basic_config_param_t; |
860 | 708 | { |
861 | - basic_params->algor_valid_rect.top_ = 0; | |
862 | - basic_params->algor_valid_rect.left_ = 0; | |
863 | - // basic_params->algor_valid_rect.width_ = 1920; | |
864 | - // basic_params->algor_valid_rect.height_ = 1080; | |
865 | - basic_params->algor_valid_rect.width_ = 2560; | |
866 | - basic_params->algor_valid_rect.height_ = 1440; | |
867 | 709 | basic_params->result_folder = "res/road_work"; |
868 | 710 | basic_params->result_folder_little = "res/road_work_little"; |
869 | 711 | } |
... | ... | @@ -876,7 +718,7 @@ void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_ty |
876 | 718 | |
877 | 719 | auto algor_params = new algor_config_param_road_work; |
878 | 720 | { |
879 | - algor_params->frame_stride = 1; | |
721 | + algor_params->frame_stride = 5; | |
880 | 722 | } |
881 | 723 | |
882 | 724 | auto basic_params = new algor_basic_config_param_t; |
... | ... | @@ -888,6 +730,155 @@ void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_ty |
888 | 730 | algor_init_params->basic_param = basic_params; |
889 | 731 | } break; |
890 | 732 | |
733 | + case algorithm_type_t::HUMAN_CROSSING_LINE: { | |
734 | + auto algor_params = new algor_config_param_illegal_crossing_line; | |
735 | + { | |
736 | + algor_params->p1.x_ = 827; | |
737 | + algor_params->p1.y_ = 321; | |
738 | + algor_params->p2.x_ = 1911; | |
739 | + algor_params->p2.y_ = 1072; | |
740 | + algor_params->conf_threshold = 0.6; | |
741 | + algor_params->minmum_width = 20; | |
742 | + algor_params->minmum_height = 20; | |
743 | + } | |
744 | + | |
745 | + auto basic_params = new algor_basic_config_param_t; | |
746 | + { | |
747 | + basic_params->result_folder = "res/human_cross_line"; | |
748 | + basic_params->result_folder_little = "res/human_cross_line_little"; | |
749 | + //共性算法适配测试用 | |
750 | + auto adapt_params = new universal_algor_adapt_param; | |
751 | + { | |
752 | + adapt_params->points_count = 4; // 0表示不生效 | |
753 | + adapt_params->points[0].x_ = 0; adapt_params->points[0].y_ = 0; | |
754 | + adapt_params->points[1].x_ = 1920; adapt_params->points[1].y_ = 0; | |
755 | + adapt_params->points[2].x_ = 1920; adapt_params->points[2].y_ = 1080; | |
756 | + adapt_params->points[3].x_ = 0; adapt_params->points[3].y_ = 1080; | |
757 | + } | |
758 | + basic_params->adapt_param = adapt_params; | |
759 | + } | |
760 | + | |
761 | + algor_init_params->algor_param = algor_params; | |
762 | + algor_init_params->basic_param = basic_params; | |
763 | + } break; | |
764 | + | |
765 | + case algorithm_type_t::HUMAN_CLIMB: { | |
766 | + auto algor_params = new algor_config_param_illegal_crossing_line; | |
767 | + { | |
768 | + algor_params->p1.x_ = 827; | |
769 | + algor_params->p1.y_ = 321; | |
770 | + algor_params->p2.x_ = 1911; | |
771 | + algor_params->p2.y_ = 1072; | |
772 | + algor_params->conf_threshold = 0.5; | |
773 | + algor_params->minmum_width = 20; | |
774 | + algor_params->minmum_height = 20; | |
775 | + } | |
776 | + | |
777 | + auto basic_params = new algor_basic_config_param_t; | |
778 | + { | |
779 | + basic_params->result_folder = "res/human_climb"; | |
780 | + basic_params->result_folder_little = "res/human_climb_little"; | |
781 | + | |
782 | + auto adapt_params = new universal_algor_adapt_param; | |
783 | + { | |
784 | + adapt_params->points_count = 4; // 0表示不生效 | |
785 | + adapt_params->points[0].x_ = 0; adapt_params->points[0].y_ = 0; | |
786 | + adapt_params->points[1].x_ = 1920; adapt_params->points[1].y_ = 0; | |
787 | + adapt_params->points[2].x_ = 1920; adapt_params->points[2].y_ = 1080; | |
788 | + adapt_params->points[3].x_ = 0; adapt_params->points[3].y_ = 1080; | |
789 | + } | |
790 | + basic_params->adapt_param = adapt_params; | |
791 | + } | |
792 | + | |
793 | + algor_init_params->algor_param = algor_params; | |
794 | + algor_init_params->basic_param = basic_params; | |
795 | + } break; | |
796 | + | |
797 | + case algorithm_type_t::VEHICLE_ILLEGAL_CROSSING_LINE: { | |
798 | + auto algor_params = new algor_config_param_illegal_crossing_line; | |
799 | + { | |
800 | + algor_params->p1.x_ = 827; | |
801 | + algor_params->p1.y_ = 321; | |
802 | + algor_params->p2.x_ = 1911; | |
803 | + algor_params->p2.y_ = 1072; | |
804 | + algor_params->minmum_width = 10; | |
805 | + algor_params->minmum_height = 10; | |
806 | + } | |
807 | + | |
808 | + auto basic_params = new algor_basic_config_param_t; | |
809 | + { | |
810 | + basic_params->result_folder = "res/vehicle_cross_line"; | |
811 | + basic_params->result_folder_little = "res/vehicle_cross_line_little"; | |
812 | + auto adapt_params = new universal_algor_adapt_param; | |
813 | + { | |
814 | + adapt_params->points_count = 4; // 0表示不生效 | |
815 | + adapt_params->points[0].x_ = 0; adapt_params->points[0].y_ = 0; | |
816 | + adapt_params->points[1].x_ = 1920; adapt_params->points[1].y_ = 0; | |
817 | + adapt_params->points[2].x_ = 1920; adapt_params->points[2].y_ = 1080; | |
818 | + adapt_params->points[3].x_ = 0; adapt_params->points[3].y_ = 1080; | |
819 | + } | |
820 | + basic_params->adapt_param = adapt_params; | |
821 | + } | |
822 | + | |
823 | + algor_init_params->algor_param = algor_params; | |
824 | + algor_init_params->basic_param = basic_params; | |
825 | + } break; | |
826 | + | |
827 | + case algorithm_type_t::HUMAN_LINGER: { | |
828 | + auto algor_params = new algor_config_param_behavior; | |
829 | + { | |
830 | + algor_params->duration = 50; //帧 | |
831 | + algor_params->minmum_width = 20; | |
832 | + algor_params->minmum_height = 20; | |
833 | + algor_params->conf_threshold = 0.5; | |
834 | + } | |
835 | + | |
836 | + auto basic_params = new algor_basic_config_param_t; | |
837 | + { | |
838 | + basic_params->result_folder = "res/human_linger"; | |
839 | + basic_params->result_folder_little = "res/human_linger_little"; | |
840 | + | |
841 | + auto adapt_params = new universal_algor_adapt_param; | |
842 | + { | |
843 | + adapt_params->points_count = 4; // 0表示不生效 | |
844 | + adapt_params->points[0].x_ = 505; adapt_params->points[0].y_ = 481; | |
845 | + adapt_params->points[1].x_ = 741; adapt_params->points[1].y_ = 881; | |
846 | + adapt_params->points[2].x_ = 1911; adapt_params->points[2].y_ = 667; | |
847 | + adapt_params->points[3].x_ = 1484; adapt_params->points[3].y_ = 410; | |
848 | + } | |
849 | + basic_params->adapt_param = adapt_params; | |
850 | + } | |
851 | + | |
852 | + algor_init_params->algor_param = algor_params; | |
853 | + algor_init_params->basic_param = basic_params; | |
854 | + } break; | |
855 | + case algorithm_type_t::VEHICLE_ILLEGAL_PARKING: { | |
856 | + auto algor_params = new algor_config_param_behavior; | |
857 | + { | |
858 | + algor_params->duration = 25; //帧 | |
859 | + algor_params->minmum_width = 10; | |
860 | + algor_params->minmum_height = 10; | |
861 | + } | |
862 | + | |
863 | + auto basic_params = new algor_basic_config_param_t; | |
864 | + { | |
865 | + basic_params->result_folder = "res/vehicle_parking"; | |
866 | + basic_params->result_folder_little = "res/vehicle_parking_little"; | |
867 | + auto adapt_params = new universal_algor_adapt_param; | |
868 | + { | |
869 | + adapt_params->points_count = 4; // 0表示不生效 | |
870 | + adapt_params->points[0].x_ = 505; adapt_params->points[0].y_ = 481; | |
871 | + adapt_params->points[1].x_ = 741; adapt_params->points[1].y_ = 881; | |
872 | + adapt_params->points[2].x_ = 1911; adapt_params->points[2].y_ = 667; | |
873 | + adapt_params->points[3].x_ = 1484; adapt_params->points[3].y_ = 410; | |
874 | + } | |
875 | + basic_params->adapt_param = adapt_params; | |
876 | + } | |
877 | + | |
878 | + algor_init_params->algor_param = algor_params; | |
879 | + algor_init_params->basic_param = basic_params; | |
880 | + } break; | |
881 | + | |
891 | 882 | default: { |
892 | 883 | if (algor_init_params != nullptr) { |
893 | 884 | delete algor_init_params; |
... | ... | @@ -899,9 +890,9 @@ void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_ty |
899 | 890 | |
900 | 891 | tparam.algor_config_params[idx].algor_type = algor_type; |
901 | 892 | tparam.algor_config_params[idx].algor_init_config_param = algor_init_params; |
902 | - | |
903 | 893 | } |
904 | 894 | |
895 | + | |
905 | 896 | static long long get_cur_time(){ |
906 | 897 | chrono::time_point<chrono::system_clock, chrono::milliseconds> tpMicro |
907 | 898 | = chrono::time_point_cast<chrono::milliseconds>(chrono::system_clock::now()); |
... | ... | @@ -1017,6 +1008,15 @@ string createTask(void *handle, std::vector<algorithm_type_t> algor_vec, int gi, |
1017 | 1008 | case 32: |
1018 | 1009 | tparam.ipc_url = "/data/share/data/141_74.avi"; |
1019 | 1010 | break; |
1011 | + case 33: | |
1012 | + tparam.ipc_url = "/data/share/data/human_gather.mp4"; | |
1013 | + break; | |
1014 | + case 34: | |
1015 | + tparam.ipc_url = "/data/share/data/12.mp4"; | |
1016 | + break; | |
1017 | + case 35: | |
1018 | + tparam.ipc_url = "/data/share/data/铁路文化宫-门口1_20D40580_1607648331.avi"; | |
1019 | + break; | |
1020 | 1020 | default: |
1021 | 1021 | tparam.ipc_url = "/opt/share/data/Street.uvf"; |
1022 | 1022 | break; |
... | ... | @@ -1219,12 +1219,21 @@ void test_gpu(int gpuID){ |
1219 | 1219 | 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, |
1220 | 1220 | 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, |
1221 | 1221 | algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND, algorithm_type_t::VEHICLE_NOTDECELERATION}; |
1222 | - // std::vector<algorithm_type_t> algor_vec3 = {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, | |
1223 | - // algorithm_type_t::NONMOTOR_VEHICLE_REFIT, algorithm_type_t::PERSON_RUNNING_REDLIGHTS, algorithm_type_t::NONMOTOR_RUNNING_REDLIGHTS}; | |
1222 | + | |
1224 | 1223 | 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, |
1225 | 1224 | algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND}; |
1226 | - | |
1227 | 1225 | |
1226 | + std::vector<algorithm_type_t> algor_vec_human = {algorithm_type_t::HUMAN_SNAPSHOT, algorithm_type_t::VIDEO_TIMING_SNAPSHOT, algorithm_type_t::FACE_SNAPSHOT, algorithm_type_t::HUMAN_GATHER, algorithm_type_t::HUMAN_REGION_GATHER | |
1227 | + ,algorithm_type_t::HUMAN_DENSITY,algorithm_type_t::HUMAN_LINGER, algorithm_type_t::HUMAN_REGION_FAST_MOVING, algorithm_type_t::HUMAN_REGION_DISMISS, algorithm_type_t::HUMAN_CLIMB, algorithm_type_t::HUMAN_CROSSING_LINE | |
1228 | + , algorithm_type_t::HUMAN_LEAVE_REGION}; | |
1229 | + | |
1230 | + std::vector<algorithm_type_t> algor_vec_car = {algorithm_type_t::VEHICLE_SNAPSHOT, algorithm_type_t::VEHICLE_TRESPASS, algorithm_type_t::VEHICLE_GATHER, algorithm_type_t::VEHICLE_ILLEGAL_PARKING | |
1231 | + ,algorithm_type_t::VEHICLE_ILLEGAL_CROSSING_LINE}; | |
1232 | + | |
1233 | + std::vector<algorithm_type_t> algor_wenhuagong = {algorithm_type_t::NONMOTOR_VEHICLE_SNAPSHOT, algorithm_type_t::VEHICLE_TRESPASS,algorithm_type_t::VEHICLE_SNAPSHOT,algorithm_type_t::VEHICLE_GATHER,algorithm_type_t::VEHICLE_ILLEGAL_PARKING,algorithm_type_t::VEHICLE_ILLEGAL_CROSSING_LINE | |
1234 | + ,algorithm_type_t::HUMAN_GATHER, algorithm_type_t::FACE_SNAPSHOT, algorithm_type_t::HUMAN_LEAVE_REGION, algorithm_type_t::HUMAN_REGION_DISMISS, algorithm_type_t::HUMAN_REGION_FAST_MOVING, algorithm_type_t::HUMAN_SNAPSHOT, algorithm_type_t::HUMAN_REGION_GATHER, algorithm_type_t::HUMAN_DENSITY, algorithm_type_t::HUMAN_CROSSING_LINE, algorithm_type_t::HUMAN_CLIMB, algorithm_type_t::HUMAN_LINGER | |
1235 | + }; | |
1236 | + | |
1228 | 1237 | // int repeat_num = 1000; |
1229 | 1238 | // createTask(handle, algor_vec2, 0, false); |
1230 | 1239 | // createTask(handle, algor_vec2, 2, false); |
... | ... | @@ -1254,7 +1263,10 @@ void test_gpu(int gpuID){ |
1254 | 1263 | // createTask(handle, algor_vec2, 24, false); |
1255 | 1264 | // createTask(handle, algor_vec2, 30, false); |
1256 | 1265 | // createTask(handle, algor_vec2, 31, false); |
1257 | - createTask(handle, algor_vec2, 32, false); | |
1266 | + | |
1267 | + // createTask(handle, algor_vec_human, 33, false); | |
1268 | + | |
1269 | + createTask(handle, algor_wenhuagong, 35, false); | |
1258 | 1270 | |
1259 | 1271 | // int task_index = 0; |
1260 | 1272 | // while (true) | ... | ... |
src/helpers/img_util.cpp
0 → 100644
1 | +#include "img_util.h" | |
2 | +#include "opencv2/opencv.hpp" | |
3 | + | |
4 | +namespace common { | |
5 | + | |
6 | +bool isInPolygon(const sy_point* point_array, int point_count, const sy_point& center) { | |
7 | + | |
8 | + std::vector<cv::Point> polygon; | |
9 | + for (size_t i = 0; i < point_count; i++) | |
10 | + { | |
11 | + polygon.push_back(cv::Point(point_array[i].x_, point_array[i].y_)); | |
12 | + } | |
13 | + | |
14 | + if (polygon.size() <= 0) | |
15 | + { | |
16 | + return false; | |
17 | + } | |
18 | + | |
19 | + // 定义一个点 | |
20 | + cv::Point pt(center.x_, center.y_); | |
21 | + | |
22 | + // 使用pointPolygonTest函数判断点是否在多边形内 | |
23 | + double sign = cv::pointPolygonTest(polygon, pt, false); | |
24 | + if (sign > 0) | |
25 | + { | |
26 | + return true; | |
27 | + } | |
28 | + | |
29 | + return false; | |
30 | +} | |
31 | + | |
32 | +void save_result(int height, int width, sy_point* point_array, int point_count, std::vector<sy_point> vec_pt) { | |
33 | + cv::Mat image = cv::Mat::zeros(height, width, CV_8UC3); | |
34 | + | |
35 | + // 定义一个多边形的顶点数组(例如一个五边形) | |
36 | + std::vector<cv::Point> polyPoints; | |
37 | + for (size_t i = 0; i < point_count; i++) | |
38 | + { | |
39 | + polyPoints.push_back(cv::Point(point_array[i].x_, point_array[i].y_)); | |
40 | + } | |
41 | + | |
42 | + // 绘制多边形边界,颜色为绿色,线宽 2 | |
43 | + const cv::Point* pts = &polyPoints[0]; | |
44 | + int npts = (int)polyPoints.size(); | |
45 | + cv::polylines(image, &pts, &npts, 1, true, cv::Scalar(0, 255, 0), 2); | |
46 | + | |
47 | + for (size_t i = 0; i < vec_pt.size(); i++) | |
48 | + { | |
49 | + cv::circle(image, cv::Point(vec_pt[i].x_, vec_pt[i].y_), 2, cv::Scalar(0, 255, 255), -1); | |
50 | + } | |
51 | + | |
52 | + cv::imwrite("gahter.jpg", image); | |
53 | + | |
54 | +} | |
55 | + | |
56 | +} | |
0 | 57 | \ No newline at end of file | ... | ... |
src/helpers/img_util.h
0 → 100644
1 | +#ifndef __HELPERS_IMG_TUIL_H__ | |
2 | +#define __HELPERS_IMG_TUIL_H__ | |
3 | + | |
4 | + | |
5 | +#include "../common/sy_common.h" | |
6 | +#include <vector> | |
7 | + | |
8 | +namespace common { | |
9 | + | |
10 | +bool isInPolygon(const sy_point* point_array, int point_count, const sy_point& center); | |
11 | + | |
12 | +void save_result(int height, int width, sy_point* point_array, int point_count, std::vector<sy_point> vec_pt); | |
13 | +} | |
14 | + | |
15 | +#endif | |
0 | 16 | \ No newline at end of file | ... | ... |
src/reprocessing_module/mq_manager.cpp
... | ... | @@ -47,10 +47,10 @@ namespace mq |
47 | 47 | |
48 | 48 | bool status; |
49 | 49 | if (!(status = task_status_to_mq_handle_[key]->sync_publish(msg))) |
50 | - LOG_ERROR("rbMQ publish {} failed", msg); | |
50 | + LOG_ERROR("rbMQ publish failed:{}", msg); | |
51 | 51 | else |
52 | 52 | if (verbose) |
53 | - LOG_DEBUG("rbMQ publish {} successful", msg); | |
53 | + LOG_DEBUG("rbMQ publish successful:{}", msg); | |
54 | 54 | return status; |
55 | 55 | } |
56 | 56 | ... | ... |
src/reprocessing_module/save_snapshot_reprocessing.cpp
... | ... | @@ -110,11 +110,8 @@ void save_snapshot_reprocessing::save_img_process() { |
110 | 110 | VPCUtil::vpc_img_release(cur_image.img_info); |
111 | 111 | |
112 | 112 | #ifdef POST_USE_RABBITMQ |
113 | - // LOG_INFO("mq publish process in: {}", cur_image.json_str); | |
114 | 113 | if (bSaved && callback_ != nullptr && cur_image.json_str.length() > 0) { |
115 | - // LOG_INFO("mq publish process begin"); | |
116 | 114 | callback_(cur_image.json_str.c_str()); |
117 | - LOG_INFO("mq publish process end: {} ", cur_image.json_str); | |
118 | 115 | } |
119 | 116 | #endif |
120 | 117 | ... | ... |
src/reprocessing_module/snapshot_reprocessing.cpp
... | ... | @@ -3,6 +3,7 @@ |
3 | 3 | #include "../common/logger.hpp" |
4 | 4 | #include "../ai_platform/mvpt_process_assist.h" |
5 | 5 | #include "../decoder/interface/DeviceMemory.hpp" |
6 | +#include "../helpers/img_util.h" | |
6 | 7 | |
7 | 8 | |
8 | 9 | snapshot_reprocessing::snapshot_reprocessing(int devId) |
... | ... | @@ -49,6 +50,16 @@ vector<multi_obj_data_t> snapshot_reprocessing::get_vehicle_snapshot(vector<Devi |
49 | 50 | if (algor_config_param.count(task_id) && algor_config_param[task_id].vehicle_algors.count(algorithm_type_t::VEHICLE_SNAPSHOT)) |
50 | 51 | { |
51 | 52 | task_param_manager::algo_param_type_t_* cur_task_params = algor_param[task_id][algorithm_type_t::VEHICLE_SNAPSHOT]; |
53 | + if (!cur_task_params || !cur_task_params->basic_param || !cur_task_params->basic_param->adapt_param) | |
54 | + { | |
55 | + continue; | |
56 | + } | |
57 | + | |
58 | + // 多边形区域 | |
59 | + auto adapt_param = cur_task_params->basic_param->adapt_param; | |
60 | + if (adapt_param->points_count <= 0) { | |
61 | + continue; | |
62 | + } | |
52 | 63 | |
53 | 64 | // 同一目标间隔多少帧保存 |
54 | 65 | int snap_frame_interval = ((algor_config_param_snapshot*)cur_task_params->algor_param)->snap_frame_interval; |
... | ... | @@ -61,9 +72,14 @@ vector<multi_obj_data_t> snapshot_reprocessing::get_vehicle_snapshot(vector<Devi |
61 | 72 | if(snap_frame_interval > 0 && det_obj.num % snap_frame_interval >= skip_frame){ |
62 | 73 | continue; |
63 | 74 | } |
75 | + | |
76 | + sy_point center; | |
77 | + center.x_ = (det_obj.left + det_obj.right) * 0.5; | |
78 | + center.y_ = det_obj.bottom; | |
79 | + | |
64 | 80 | int type_index = det_obj.index; |
65 | 81 | if ((type_index == 4 || type_index == 5 || type_index == 6 || type_index ==7 || type_index ==8) |
66 | - && snapshot_legal_inarea(cur_task_params->basic_param->algor_valid_rect, det_obj.left, det_obj.top, det_obj.right, det_obj.bottom)) | |
82 | + && common::isInPolygon(adapt_param->points, adapt_param->points_count, center)) | |
67 | 83 | { |
68 | 84 | video_object_info obj_info; |
69 | 85 | obj_info.top = det_obj.top; |
... | ... | @@ -202,6 +218,30 @@ void snapshot_reprocessing::update_bestsnapshot(vector<DeviceMemory*> vec_devMem |
202 | 218 | index = total_snapshot_info[new_obj].index.index; |
203 | 219 | } |
204 | 220 | |
221 | + algorithm_type_t algor_type; | |
222 | + if (index ==0) algor_type = algorithm_type_t::HUMAN_SNAPSHOT; | |
223 | + if (index ==1 || index ==2 || index ==3) algor_type = algorithm_type_t::NONMOTOR_VEHICLE_SNAPSHOT; | |
224 | + if (index ==4 || index ==5 || index ==6 || index ==7 || index ==8) algor_type = algorithm_type_t::VEHICLE_SNAPSHOT; | |
225 | + if (!(algor_config_param.count(task_id) && algor_param.count(task_id) && algor_param[task_id].count(algor_type))) | |
226 | + continue; | |
227 | + task_param_manager::algo_param_type_t_* cur_task_params = algor_param[task_id][algor_type]; | |
228 | + if (!cur_task_params || !cur_task_params->basic_param || !cur_task_params->basic_param->adapt_param) { | |
229 | + continue; | |
230 | + } | |
231 | + | |
232 | + // 多边形区域 | |
233 | + auto adapt_param = cur_task_params->basic_param->adapt_param; | |
234 | + if (adapt_param->points_count <= 0) { | |
235 | + continue; | |
236 | + } | |
237 | + | |
238 | + sy_point center; | |
239 | + center.x_ = (obj_info.left + obj_info.right) * 0.5; | |
240 | + center.y_ = obj_info.bottom; | |
241 | + if (!common::isInPolygon(adapt_param->points, adapt_param->points_count, center)) { | |
242 | + continue; | |
243 | + } | |
244 | + | |
205 | 245 | int cur_real_width = (obj_info.right - obj_info.left); |
206 | 246 | int cur_real_height = (obj_info.bottom - obj_info.top); |
207 | 247 | int cur_real_index = obj_info.index; |
... | ... | @@ -220,17 +260,6 @@ void snapshot_reprocessing::update_bestsnapshot(vector<DeviceMemory*> vec_devMem |
220 | 260 | { |
221 | 261 | /* manager insert new object. */ |
222 | 262 | /* 判断目标合法 */ |
223 | - algorithm_type_t algor_type; | |
224 | - if (index ==0) algor_type = algorithm_type_t::HUMAN_SNAPSHOT; | |
225 | - if (index ==1 || index ==2 || index ==3) algor_type = algorithm_type_t::NONMOTOR_VEHICLE_SNAPSHOT; | |
226 | - if (index ==4 || index ==5 || index ==6 || index ==7 || index ==8) algor_type = algorithm_type_t::VEHICLE_SNAPSHOT; | |
227 | - if (!(algor_config_param.count(task_id) && algor_param.count(task_id) && algor_param[task_id].count(algor_type))) | |
228 | - continue; | |
229 | - task_param_manager::algo_param_type_t_* cur_task_params = algor_param[task_id][algor_type]; | |
230 | - if (!snapshot_legal_inarea(cur_task_params->basic_param->algor_valid_rect,obj_info.left, obj_info.top, obj_info.right, obj_info.bottom)){ | |
231 | - continue; | |
232 | - } | |
233 | - | |
234 | 263 | if(!snapshot_legal_minarea(index, cur_real_width, cur_real_height)){ |
235 | 264 | continue; |
236 | 265 | } |
... | ... | @@ -265,15 +294,6 @@ void snapshot_reprocessing::update_bestsnapshot(vector<DeviceMemory*> vec_devMem |
265 | 294 | } else { |
266 | 295 | total_snapshot_info[new_obj].last_area = (obj_info.right - obj_info.left) * (obj_info.bottom - obj_info.top); |
267 | 296 | |
268 | - algorithm_type_t algor_type; | |
269 | - if (index ==0) algor_type = algorithm_type_t::HUMAN_SNAPSHOT; | |
270 | - if (index ==1 || index ==2 || index ==3) algor_type = algorithm_type_t::NONMOTOR_VEHICLE_SNAPSHOT; | |
271 | - if (index ==4 || index ==5 || index ==6 || index ==7 || index ==8) algor_type = algorithm_type_t::VEHICLE_SNAPSHOT; | |
272 | - if (!(algor_config_param.count(task_id) && algor_param.count(task_id) && algor_param[task_id].count(algor_type))) | |
273 | - continue; | |
274 | - task_param_manager::algo_param_type_t_* cur_task_params = algor_param[task_id][algor_type]; | |
275 | - if (!snapshot_legal_inarea(cur_task_params->basic_param->algor_valid_rect,obj_info.left, obj_info.top, obj_info.right, obj_info.bottom)) | |
276 | - continue; | |
277 | 297 | //--------------------------------------------------------------- |
278 | 298 | if (!best_snapshot_judge_algor(new_obj, total_snapshot_info[new_obj], obj_info.left, obj_info.top, |
279 | 299 | cur_real_width, cur_real_height, frame_width, frame_height)) |
... | ... | @@ -590,6 +610,31 @@ int snapshot_reprocessing::update_face_bestsnapshot(vector<DeviceMemory*> vec_de |
590 | 610 | det_objinfo obj_info = ol_det_result[idx].obj[c]; |
591 | 611 | OBJ_KEY new_obj = { task_id, obj_info.id }; |
592 | 612 | |
613 | + if (obj_info.confidence < 0.6) | |
614 | + continue; | |
615 | + //--------------------------------------------- | |
616 | + //230327 增加指定区域过滤------------------------------------------ | |
617 | + if (!(algor_config_param.count(task_id) && algor_param.count(task_id) && algor_param[task_id].count(algorithm_type_t::FACE_SNAPSHOT))) | |
618 | + continue; | |
619 | + | |
620 | + task_param_manager::algo_param_type_t_* cur_task_params = algor_param[task_id][algorithm_type_t::FACE_SNAPSHOT]; | |
621 | + if (!cur_task_params || !cur_task_params->basic_param || !cur_task_params->basic_param->adapt_param) { | |
622 | + continue; | |
623 | + } | |
624 | + | |
625 | + auto adapt_param = cur_task_params->basic_param->adapt_param; | |
626 | + if (adapt_param->points_count <= 0) { | |
627 | + continue; | |
628 | + } | |
629 | + | |
630 | + //增加指定区域过滤------------------------------------------ | |
631 | + sy_point center; | |
632 | + center.x_ = (obj_info.left + obj_info.right) * 0.5; | |
633 | + center.y_ = obj_info.bottom; | |
634 | + if (!common::isInPolygon(adapt_param->points, adapt_param->points_count, center)) { | |
635 | + continue; | |
636 | + } | |
637 | + | |
593 | 638 | int cur_real_width = (obj_info.right - obj_info.left); |
594 | 639 | int cur_real_height = (obj_info.bottom - obj_info.top); |
595 | 640 | int cur_real_index = obj_info.index; |
... | ... | @@ -604,17 +649,6 @@ int snapshot_reprocessing::update_face_bestsnapshot(vector<DeviceMemory*> vec_de |
604 | 649 | continue; |
605 | 650 | } |
606 | 651 | |
607 | - // added by zsh 221024 人脸质量过滤------------- | |
608 | - if (obj_info.confidence < 0.6) | |
609 | - continue; | |
610 | - //--------------------------------------------- | |
611 | - //230327 增加指定区域过滤------------------------------------------ | |
612 | - if (!(algor_config_param.count(task_id) && algor_param.count(task_id) && algor_param[task_id].count(algorithm_type_t::FACE_SNAPSHOT))) | |
613 | - continue; | |
614 | - task_param_manager::algo_param_type_t_* cur_task_params = algor_param[task_id][algorithm_type_t::FACE_SNAPSHOT]; | |
615 | - if (!snapshot_legal_inarea(cur_task_params->basic_param->algor_valid_rect,obj_info.left, | |
616 | - obj_info.top, obj_info.right, obj_info.bottom)) | |
617 | - continue; | |
618 | 652 | //--------------------------------------------------------------- |
619 | 653 | |
620 | 654 | LOG_DEBUG(" {}: {}",task_id, obj_info.id); |
... | ... | @@ -665,17 +699,6 @@ int snapshot_reprocessing::update_face_bestsnapshot(vector<DeviceMemory*> vec_de |
665 | 699 | } |
666 | 700 | else |
667 | 701 | { |
668 | - // added by zsh 221024 人脸质量过滤------------- | |
669 | - if (obj_info.confidence < 0.6) | |
670 | - continue; | |
671 | - //--------------------------------------------- | |
672 | - //230327 指定区域过滤------------------------------------------ | |
673 | - if (!(algor_config_param.count(task_id) && algor_param.count(task_id) && algor_param[task_id].count(algorithm_type_t::FACE_SNAPSHOT))) | |
674 | - continue; | |
675 | - task_param_manager::algo_param_type_t_* cur_task_params = algor_param[task_id][algorithm_type_t::FACE_SNAPSHOT]; | |
676 | - if (!snapshot_legal_inarea(cur_task_params->basic_param->algor_valid_rect,obj_info.left, obj_info.top, obj_info.right, obj_info.bottom)) | |
677 | - continue; | |
678 | - | |
679 | 702 | // 最佳快照判断 |
680 | 703 | if (!best_face_snapshot_judge_algor_v2(new_obj, total_face_snapshot_info[new_obj], obj_info.left, obj_info.top, |
681 | 704 | cur_real_width, cur_real_height, frame_width, frame_height, obj_info.roll, obj_info.yaw, obj_info.pitch )) | ... | ... |
src/util/JpegUtil.cpp
... | ... | @@ -86,7 +86,7 @@ bool JpegUtil::jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_nam |
86 | 86 | // 8. 申请输出内存,申请Device内存encodeOutBufferDev_,存放编码后的输出数据 |
87 | 87 | uint32_t outBufferSize= 0; |
88 | 88 | int ret = acldvppJpegPredictEncSize(encodeInputDesc_, jpegeConfig_, &outBufferSize); |
89 | - if (ret != ACL_SUCCESS) { | |
89 | + if (ret != ACL_SUCCESS || outBufferSize <= 0) { | |
90 | 90 | LOG_ERROR("acldvppJpegPredictEncSize failed!"); |
91 | 91 | return false; |
92 | 92 | } | ... | ... |
src/helpers/common_tool.cpp renamed to src/util/common_tool.cpp
src/helpers/common_tool.h renamed to src/util/common_tool.h