From 8c495cc96a825d0be2339760f5c10ca5ffc7eb4e Mon Sep 17 00:00:00 2001 From: Zhao Shuaihua Date: Tue, 7 Nov 2023 09:39:33 +0000 Subject: [PATCH] 增加实线掉头(515)功能 --- src/ai_engine_module/road_seg_correlation_algor.cpp | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- src/ai_engine_module/road_seg_correlation_algor.h | 38 +++++++++++++++++++++++++++++++++++++- src/ai_engine_module/road_seg_statistics.cpp | 2 +- src/ai_engine_module/road_seg_statistics.h | 3 ++- src/ai_platform/MultiSourceProcess.cpp | 5 +++-- src/ai_platform/task_param_manager.cpp | 3 +++ src/decoder/test_face.cpp | 317 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/decoder/test_face.cpp1 | 317 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/decoder/test_recoder.cpp | 248 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/demo/demo.cpp | 54 +++++++++++++++++++++++++++++++++++++----------------- 10 files changed, 771 insertions(+), 343 deletions(-) delete mode 100644 src/decoder/test_face.cpp create mode 100644 src/decoder/test_face.cpp1 create mode 100644 src/decoder/test_recoder.cpp diff --git a/src/ai_engine_module/road_seg_correlation_algor.cpp b/src/ai_engine_module/road_seg_correlation_algor.cpp index a8a2f59..cd4ca5d 100644 --- a/src/ai_engine_module/road_seg_correlation_algor.cpp +++ b/src/ai_engine_module/road_seg_correlation_algor.cpp @@ -20,6 +20,7 @@ namespace ai_engine_module algorithm_type_t::PERSON_CROSS, algorithm_type_t::NONMOTOR_WRONGDIRECTION, algorithm_type_t::VEHICLE_WRONGDIRECTION, + algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND, algorithm_type_t::VEHICLE_NOTGIVEWAY, }; @@ -237,6 +238,91 @@ namespace ai_engine_module return true; } } /*----------------------分割线---------------分割线--------------------*/ + // 获取轨迹起点/终点:去除离群点后取平均 + bool find_traceStartEnd(const vector& tracker_list, int check_frames, jxline& trace_line) { + int stcnt = 0, edcnt = 0; + float center_sum_x = 0, center_sum_y = 0, center_nsum_x = 0, center_nsum_y = 0; + for (int tmp = tracker_list.size()-check_frames; tmp < tracker_list.size()-check_frames+3; tmp++) { + center_sum_x += tracker_list[tmp].x_; + center_sum_y += tracker_list[tmp].y_; + } + float center_ave_x = center_sum_x / 3; float center_ave_y = center_sum_y / 3; + for (int tmp = tracker_list.size()-check_frames; tmp < tracker_list.size()-11; tmp++) { + if (abs(tracker_list[tmp].x_ - center_ave_x) > 300 || abs(tracker_list[tmp].y_ - center_ave_y) > 300) + continue; + center_nsum_x += tracker_list[tmp].x_; + center_nsum_y += tracker_list[tmp].y_; + stcnt += 1; + } + + float center_edsum_x = 0, center_edsum_y = 0, center_ednsum_x = 0, center_ednsum_y = 0; + for (int tmp = tracker_list.size()-3; tmp < tracker_list.size(); tmp++) { + center_edsum_x += tracker_list[tmp].x_; + center_edsum_y += tracker_list[tmp].y_; + } + float center_edave_x = center_edsum_x / 3; float center_edave_y = center_edsum_y / 3; + for (int tmp = tracker_list.size()-3; tmp < tracker_list.size(); tmp++) { + if (abs(tracker_list[tmp].x_ - center_edave_x) > 300 || abs(tracker_list[tmp].y_ - center_edave_y) > 300) + continue; + center_ednsum_x += tracker_list[tmp].x_; + center_ednsum_y += tracker_list[tmp].y_; + edcnt += 1; + } + + if (stcnt > 0 && edcnt > 0) { + trace_line.xa = center_nsum_x / stcnt; trace_line.ya = center_nsum_y / stcnt; + trace_line.xb = center_ednsum_x / edcnt; trace_line.yb = center_ednsum_y / edcnt; + float t_diff_x = trace_line.xb - trace_line.xa, t_diff_y = trace_line.yb - trace_line.ya; + float temp_dist = sqrt(t_diff_x * t_diff_x + t_diff_y * t_diff_y); + if (temp_dist > 50) return true; // 位移限制 + } + + return false; + } + + // 判断是否相交 + bool is_intersect(jxline myline1, jxline myline2) + { + // 快速排斥实验 + if (myline1.get_max_x() < myline2.get_min_x() || + myline2.get_max_x() < myline1.get_min_x() || + myline1.get_max_y() < myline2.get_min_y() || + myline2.get_max_y() < myline1.get_min_y()) + return false; + + // 跨立实验(叉积异号) + if (((((float)myline1.xa - (float)myline2.xa)*((float)myline2.yb - (float)myline2.ya) - ((float)myline1.ya - (float)myline2.ya)*((float)myline2.xb - (float)myline2.xa))* + (((float)myline1.xb - (float)myline2.xa)*((float)myline2.yb - (float)myline2.ya) - ((float)myline1.yb - (float)myline2.ya)*((float)myline2.xb - (float)myline2.xa))) > 0 || + ((((float)myline2.xa - (float)myline1.xa)*((float)myline1.yb - (float)myline1.ya) - ((float)myline2.ya - (float)myline1.ya)*((float)myline1.xb - (float)myline1.xa))* + (((float)myline2.xb - (float)myline1.xa)*((float)myline1.yb - (float)myline1.ya) - ((float)myline2.yb - (float)myline1.ya)*((float)myline1.xb - (float)myline1.xa))) > 0) + return false; + + return true; + } + + // 判断掉头:以轨迹中间为界,判断前后方向是否一致 + bool vTurnAround(const vector& tracker_list, int check_frames) { + int trackcnt = tracker_list.size(); + int half_check_frames = check_frames / 2; + tr_point p_start, p_end, p_half; + p_start.x = tracker_list[trackcnt-check_frames-1].x_; p_start.y = tracker_list[trackcnt-check_frames-1].y_; + p_end.x = tracker_list[trackcnt-1].x_; p_end.y = tracker_list[trackcnt-1].y_; + p_half.x = tracker_list[trackcnt-half_check_frames-1].x_; p_half.y = tracker_list[trackcnt-half_check_frames-1].y_; + // 车辆方向 + tr_point car_toward1, car_toward2; + car_toward1.x = p_half.x - p_start.x; car_toward1.y = p_half.y - p_start.y; + car_toward2.x = p_end.x - p_half.x; car_toward2.y = p_end.y - p_half.y; + + float temp_dist1 = sqrt(car_toward1.x * car_toward1.x + car_toward1.y * car_toward1.y); + float temp_dist2 = sqrt(car_toward2.x * car_toward2.x + car_toward2.y * car_toward2.y); + if (temp_dist1 < 40 || temp_dist2 < 40) return false; // 位移限制 + + int deg1 = atan2(car_toward1.y, car_toward1.x) * 180 / Pi; // 返回与x轴的夹角 + int deg2 = atan2(car_toward2.y, car_toward2.x) * 180 / Pi; + int deg_diff = abs(deg1 - deg2); + if (deg_diff < 135) { return false; } + else { return true; } + } vector Mbuild_area(vector args) { @@ -494,7 +580,8 @@ namespace ai_engine_module continue; stream_idx_and_algor_seq.algors.emplace(algor_type); - if (algor_type == algorithm_type_t::VEHICLE_WRONGDIRECTION || algor_type == algorithm_type_t::VEHICLE_NOTGIVEWAY) has_vehicle_algor = true; + if (algor_type == algorithm_type_t::VEHICLE_WRONGDIRECTION || algor_type == algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND || + algor_type == algorithm_type_t::VEHICLE_NOTGIVEWAY) has_vehicle_algor = true; } if (stream_idx_and_algor_seq.algors.empty()) @@ -591,7 +678,8 @@ namespace ai_engine_module auto fence_labels_ = fence_labels[flattened_idx_to_batch_idx[n]]; vector> vehiclelanes_regions; //机动车区域 - vector> crosswalk_regions; //人行道区域+十字路口区域 + vector> crosswalk_regions; //人行道+十字路口区域 + vector> solidlines; //黄实线+白实线 // printf("seg_labels.size:%d\n",seg_labels.size()); for (unsigned i = 0; i < seg_labels.size(); ++i) { const label_t label = static_cast(seg_labels[i]); @@ -603,6 +691,10 @@ namespace ai_engine_module vector cur_region(seg_regions[i].begin(),seg_regions[i].end()); crosswalk_regions.push_back(cur_region); } + if ((label == label_t::yellow_solidline || label == label_t::white_solidline)) { + vector cur_region(seg_regions[i].begin(),seg_regions[i].end()); + solidlines.push_back(cur_region); + } } vector> roadseg_fence_regions;//车道分割护栏区域 @@ -637,7 +729,7 @@ namespace ai_engine_module if ((algor_type == algorithm_type_t::NONMOTOR_IN_VEHICLELANE || algor_type == algorithm_type_t::NONMOTOR_CEOSSPARKLINE || algor_type == algorithm_type_t::NONMOTOR_WRONGDIRECTION) && !is_valid_nomotor(static_cast(det_result.box.cls))) continue; - if ((algor_type == algorithm_type_t::VEHICLE_WRONGDIRECTION || algor_type == algorithm_type_t::VEHICLE_NOTGIVEWAY) && !is_valid_car(static_cast(det_result.box.cls))) + if ((algor_type == algorithm_type_t::VEHICLE_WRONGDIRECTION || algor_type == algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND || algor_type == algorithm_type_t::VEHICLE_NOTGIVEWAY) && !is_valid_car(static_cast(det_result.box.cls))) continue; auto& e = id_to_mn_[obj_key]; @@ -716,6 +808,32 @@ namespace ai_engine_module if (!isalarm) continue; } + // 机动车实线掉头 + if (algor_type == algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND) { + bool isalarm = false; + int check_frames = 20; //4s 监控4s内的轨迹情况 + if (m_total_obj_info[trace_obj_key].center_points.size() > check_frames) { + jxline trace_line; + bool ret = find_traceStartEnd(m_total_obj_info[trace_obj_key].center_points, check_frames, trace_line); + if (ret) { + for (auto region : solidlines) { + vector tr_boxes = Mbuild_area(region); if (tr_boxes.size() < 2) continue; + for (int tmp_p = 0; tmp_p < tr_boxes.size() - 1; tmp_p++) { + jxline cur_line; + cur_line.xa = tr_boxes[tmp_p].x; cur_line.ya = tr_boxes[tmp_p].y; + cur_line.xb = tr_boxes[tmp_p + 1].x; cur_line.yb = tr_boxes[tmp_p + 1].y; + if (is_intersect(trace_line, cur_line)) { //压线 + bool cur_flag = vTurnAround(m_total_obj_info[trace_obj_key].center_points, check_frames);// 掉头 todo: 根据关键点判车头车尾朝向是否发生改变 + if (cur_flag) { isalarm = true; break; } + } + } + if (isalarm) break; + } + } + } + if (!isalarm) continue; + } + // 机动车不让行:针对人行道区域有行人,车辆不停车的情形 if (algor_type == algorithm_type_t::VEHICLE_NOTGIVEWAY) { bool isalarm = false; @@ -748,7 +866,8 @@ namespace ai_engine_module { if (++e.n_frame == algor_param->n || - algor_type == algorithm_type_t::NONMOTOR_CEOSSPARKLINE || algor_type == algorithm_type_t::PERSON_CROSS ) //部分功能当前版本暂不投票 + algor_type == algorithm_type_t::NONMOTOR_CEOSSPARKLINE || algor_type == algorithm_type_t::PERSON_CROSS || + algor_type == algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND ) //部分功能当前版本暂不投票 { results_data_t result; { diff --git a/src/ai_engine_module/road_seg_correlation_algor.h b/src/ai_engine_module/road_seg_correlation_algor.h index 29e6a15..bc48ca1 100644 --- a/src/ai_engine_module/road_seg_correlation_algor.h +++ b/src/ai_engine_module/road_seg_correlation_algor.h @@ -36,7 +36,10 @@ namespace ai_engine_module crosswalk = 5, //人行横道 no_parking_area = 6, //禁停区域 interestion_area = 7, //十字路口区域 - // green_belt_area = 8, //绿化带区域 + yellow_solidline = 8, //黄实线 + white_solidline = 9, //白实线 + white_dottedline = 10, //虚线 + yellow_dottedline = 11, //黄虚线 }; enum class fence_label_t { @@ -124,6 +127,39 @@ namespace ai_engine_module std::map id_to_mn_; std::map id_to_result_; }; + + class jxline + { + public: + int xa; + int ya; + int xb; + int yb; + jxline() {} + jxline(int xa, int ya, int xb, int yb) + { + this->xa = xa; + this->ya = ya; + this->xb = xb; + this->yb = yb; + } + int get_max_x() + { + return xa > xb ? xa : xb; + } + int get_min_x() + { + return xa > xb ? xb : xa; + } + int get_max_y() + { + return ya > yb ? ya : yb; + } + int get_min_y() + { + return ya > yb ? yb : ya; + } + }; } // namespace road_seg_correlation_process } // namespace ai_engine_module diff --git a/src/ai_engine_module/road_seg_statistics.cpp b/src/ai_engine_module/road_seg_statistics.cpp index 7bd7ea0..36caf1c 100644 --- a/src/ai_engine_module/road_seg_statistics.cpp +++ b/src/ai_engine_module/road_seg_statistics.cpp @@ -215,7 +215,7 @@ cv::Mat RoadSegProcess::seg_post_process(bool large_resolution, unsigned char *s for (int i = 0; i < lanes.size(); ++i) { int thickness = 4; for (int j = 0; j < lanes[i].size()-1; ++j) { - cv::line(mask_rmlane, lanes[i][j], lanes[i][j+1], cats[i], thickness); + cv::line(mask_rmlane, lanes[i][j], lanes[i][j+1], {seg_colors[cats[i]][0],seg_colors[cats[i]][1],seg_colors[cats[i]][2]}, thickness); // std::cout << lanes[i][j] << " " << lanes[i][j+1] << " " << cats[i] << std::endl; } } diff --git a/src/ai_engine_module/road_seg_statistics.h b/src/ai_engine_module/road_seg_statistics.h index e4c1dfe..08f23d2 100644 --- a/src/ai_engine_module/road_seg_statistics.h +++ b/src/ai_engine_module/road_seg_statistics.h @@ -77,7 +77,8 @@ private: int seg_num_seg = 7; //道路分割种类(不包含背景) int seg_min_region_area = 512; //1024 float seg_min_lane_score = 0.35; //230625 - uint8_t seg_colors[9][3] = { {0, 0, 0}, {255, 0, 0}, {0, 255, 0}, {0, 0, 255}, {0, 255, 128}, {128, 255, 255}, {255, 128, 255}, {255, 255, 128}, {60, 180, 0}}; + uint8_t seg_colors[13][3] = { {0, 0, 0}, {255, 0, 0}, {0, 255, 0}, {0, 0, 255}, {0, 255, 128}, {128, 255, 255}, {255, 128, 255}, {255, 255, 128}, {60, 180, 0}, {0, 60, 180}, + {0, 180, 60}, {60, 0, 180}, {180, 0, 60} }; uint8_t lane_colors[9][3] = { {0, 0, 0}, {255, 255, 0}, {255, 0, 255}, {0, 255, 255}, {128, 255, 0}, {255, 128, 0}, {128, 0, 255}, {255, 0, 128}, {0, 128, 255}}; }; diff --git a/src/ai_platform/MultiSourceProcess.cpp b/src/ai_platform/MultiSourceProcess.cpp index 7b81e89..3ae92f0 100755 --- a/src/ai_platform/MultiSourceProcess.cpp +++ b/src/ai_platform/MultiSourceProcess.cpp @@ -1647,7 +1647,8 @@ void CMultiSourceProcess::algorithm_roadseg_correlation_process(vector& algor_map->find(algorithm_type_t::PERSON_CROSS) != algor_map->end() || algor_map->find(algorithm_type_t::NONMOTOR_WRONGDIRECTION) != algor_map->end() || algor_map->find(algorithm_type_t::VEHICLE_WRONGDIRECTION) != algor_map->end() || - algor_map->find(algorithm_type_t::VEHICLE_NOTGIVEWAY) != algor_map->end() + algor_map->find(algorithm_type_t::VEHICLE_NOTGIVEWAY) != algor_map->end() || + algor_map->find(algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND) != algor_map->end() ) { m_RoadSegTaskMtx.lock(); @@ -1845,7 +1846,7 @@ void CMultiSourceProcess::village_snapshot(vector& vpt_interest_task_id, } vector roadseg_algor = {algorithm_type_t::PERSON_IN_VEHICLELANE, algorithm_type_t::PERSON_CROSS, algorithm_type_t::NONMOTOR_IN_VEHICLELANE, algorithm_type_t::NONMOTOR_CEOSSPARKLINE, - algorithm_type_t::NONMOTOR_WRONGDIRECTION, algorithm_type_t::VEHICLE_WRONGDIRECTION, algorithm_type_t::VEHICLE_NOTGIVEWAY }; + algorithm_type_t::NONMOTOR_WRONGDIRECTION, algorithm_type_t::VEHICLE_WRONGDIRECTION, algorithm_type_t::VEHICLE_NOTGIVEWAY, algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND }; for (size_t idx = 0; idx < roadseg_algor.size(); ++idx) { if (algor_param[task_id].count(roadseg_algor.at(idx))) { const auto &algor_other_params = task_other_params->find(roadseg_algor.at(idx)); diff --git a/src/ai_platform/task_param_manager.cpp b/src/ai_platform/task_param_manager.cpp index e2badde..ef2c88e 100755 --- a/src/ai_platform/task_param_manager.cpp +++ b/src/ai_platform/task_param_manager.cpp @@ -88,6 +88,9 @@ bool copy_algor_param_aux(const algorithm_type_t &algor_type, const std::string case algorithm_type_t::VEHICLE_NOTGIVEWAY: m_algor_config_params[task_id].vehicle_algors.insert(algor_type); goto _manned_param_copy; + case algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND: + m_algor_config_params[task_id].vehicle_algors.insert(algor_type); + goto _manned_param_copy; case algorithm_type_t::TRUCK_MANNED: { m_algor_config_params[task_id].vehicle_algors.insert(algor_type); _manned_param_copy : { diff --git a/src/decoder/test_face.cpp b/src/decoder/test_face.cpp deleted file mode 100644 index 1ef3eb2..0000000 --- a/src/decoder/test_face.cpp +++ /dev/null @@ -1,317 +0,0 @@ -#include "./interface/DecoderManager.h" -#include -#include -#include -#include - -#include "acl/acl.h" -#include "acl/ops/acl_dvpp.h" - -#include - -#include "../ai_engine_module/face_det_ai_engine.h" - -using namespace std; - -struct decode_cbk_userdata{ - string task_id; - void* opaque; - void* opaque1; -}; - -deque m_RgbDataList; -mutex m_DataListMtx; - -thread* m_pAlgorthimThread{nullptr}; -bool m_bfinish{false}; -int m_devId = 0; -const char* task_id = "test0"; -int skip_frame_ = 5; -int m_batch_size = 10; - -face_det_ai_engine m_face_det_ai_engine; - -aclrtContext ctx; - -void algorthim_process_thread(); -void algorthim_face_detect(vector vec_gpuMem); - -static long long get_cur_time_ms(){ - chrono::time_point tpMicro - = chrono::time_point_cast(chrono::system_clock::now()); - - return tpMicro.time_since_epoch().count(); -} - -static void post_decod_cbk(const void * userPtr, DeviceMemory* devFrame){ - do{ - if(m_bfinish){ - break; - } - m_DataListMtx.lock(); - if(m_RgbDataList.size() >= 30){ - m_DataListMtx.unlock(); - std::this_thread::sleep_for(std::chrono::milliseconds(3)); - continue; - } - m_RgbDataList.push_back(devFrame); - m_DataListMtx.unlock(); - break; - }while (true); -} - -static void decode_finished_cbk(const void * userPtr){ - decode_cbk_userdata* ptr = (decode_cbk_userdata*)userPtr; - if (ptr!= nullptr){ - printf("task finished: %s \n", ptr->task_id.c_str()); - } - delete ptr; - ptr = nullptr; -} - -int main(){ - - // 算法初始化 - string models_dir = "."; - - aclInit(nullptr); - aclrtSetDevice(m_devId); - - // 人脸检测初始化 - facedet_ai_engine_param fd_param; - char model_path_yolov5s[100]; - strcpy(model_path_yolov5s, (models_dir + "/models/face_detect/face_det_yolov5s_310p.om").c_str()); - fd_param.sdk_param.det_modelNames = model_path_yolov5s; - char model_path_ldmk[100]; - strcpy(model_path_ldmk, (models_dir + "/models/face_detect/face_ldmk_310p.om").c_str()); - fd_param.sdk_param.ldmk_modelNames = model_path_ldmk; - char model_path_pose[100]; - strcpy(model_path_pose, (models_dir + "/models/face_detect/face_pose_310p.om").c_str()); - fd_param.sdk_param.pose_modelNames = model_path_pose; - char model_path_score[100]; - strcpy(model_path_score, (models_dir + "/models/face_detect/face_score_310p.om").c_str()); - fd_param.sdk_param.score_modelNames = model_path_score; - char model_path_fuzzy[100]; - strcpy(model_path_fuzzy, (models_dir + "/models/face_detect/face_fuzzy_310p.om").c_str()); - fd_param.sdk_param.fuzzy_modelNames = model_path_fuzzy; - char model_path_occlusion[100]; - strcpy(model_path_occlusion, (models_dir + "/models/face_detect/face_occlusion_310p.om").c_str()); - fd_param.sdk_param.occlusion_modelNames = model_path_occlusion; - fd_param.sdk_param.thresld = 0.6; - fd_param.sdk_param.devId = m_devId; - fd_param.sdk_param.auth_license = "sy_tongtu_aiplatform_sdk_2023"; - fd_param.sdk_param.facial_fea_point_config = SY_CONFIG_OPEN; //是否启动关键点检测 - fd_param.sdk_param.pose_config = SY_CONFIG_OPEN; //是否启动姿态角 - fd_param.sdk_param.quality_config = SY_CONFIG_OPEN; //是否启动质量检测 - fd_param.sdk_param.score_config = SY_CONFIG_OPEN; //是否启动人脸置信度 //SY_CONFIG_OPEN SY_CONFIG_CLOSE - fd_param.sdk_param.max_result_count = 50; - int ret = m_face_det_ai_engine.init_ai_engine(fd_param); - if (ret < 0 ) { - printf("Init face detection failed"); - return ret; - } - - // facedet_ai_engine_param fd_param; - // fd_param.sdk_param.det_modelNames = "./models/face_detect/face_det_yolov5s_310p.om"; - // fd_param.sdk_param.ldmk_modelNames = "./models/face_detect/face_ldmk_310p.om"; - // fd_param.sdk_param.pose_modelNames = "./models/face_detect/face_pose_310p.om"; - // fd_param.sdk_param.score_modelNames = "./models/face_detect/face_score_310p.om"; - // fd_param.sdk_param.fuzzy_modelNames = "./models/face_detect/face_fuzzy_310p.om"; - // fd_param.sdk_param.occlusion_modelNames = "./models/face_detect/face_occlusion_310p.om"; - // fd_param.sdk_param.thresld = 0.6; - // fd_param.sdk_param.devId = m_devId; - // fd_param.sdk_param.auth_license = "sy_tongtu_aiplatform_sdk_2023"; - // fd_param.sdk_param.facial_fea_point_config = SY_CONFIG_OPEN; //是否启动关键点检测 - // fd_param.sdk_param.pose_config = SY_CONFIG_OPEN; //是否启动姿态角 - // fd_param.sdk_param.quality_config = SY_CONFIG_OPEN; //是否启动质量检测 - // fd_param.sdk_param.score_config = SY_CONFIG_OPEN; //是否启动人脸置信度 //SY_CONFIG_OPEN SY_CONFIG_CLOSE - // fd_param.sdk_param.max_result_count = 50; - // int ret = m_face_det_ai_engine.init_ai_engine(fd_param); - // if (ret < 0 ) { - // printf("Init face detection failed \n"); - // return ret; - // } - m_face_det_ai_engine.add_tracker(task_id, skip_frame_); // 跳帧数暂时写死 - - - // 创建解码任务 - DecoderManager* pDecManager = DecoderManager::getInstance(); - - MgrDecConfig config; - config.name = task_id; - config.cfg.uri = "/opt/share/data/caishenkezhan.mp4"; - config.cfg.post_decoded_cbk = post_decod_cbk; - config.cfg.decode_finished_cbk = decode_finished_cbk; - config.cfg.force_tcp = true; // rtsp用tcp - config.cfg.gpuid = to_string(m_devId); - config.cfg.skip_frame = skip_frame_; - - config.dec_type = DECODER_TYPE_DVPP; - - AbstractDecoder* dec = pDecManager->createDecoder(config); - if (!dec){ - printf("创建解码器失败 \n"); - return false; - } - - decode_cbk_userdata* userPtr = new decode_cbk_userdata; - userPtr->task_id = string(task_id); - pDecManager->setPostDecArg(config.name, userPtr); - pDecManager->setFinishedDecArg(config.name, userPtr); - - - int input_image_width = 0; - int input_image_height = 0; - pDecManager->getResolution(config.name, input_image_width, input_image_height); - - - // 创建算法线程 - m_pAlgorthimThread = new thread([](void* arg) { - algorthim_process_thread(); - return (void*)0; - } - , nullptr); - - pDecManager->startDecodeByName(config.name); - - while (getchar() != 'q'); -} - -void algorthim_process_thread(){ - - aclrtSetDevice(m_devId); - aclrtCreateContext(&ctx, m_devId); - - while (true){ - if(m_bfinish){ - break; - } - - vector vec_gpuMem; - m_DataListMtx.lock(); - while (!m_RgbDataList.empty()){ - DeviceMemory* gpuMem = m_RgbDataList.front(); - if(gpuMem->getMem() == nullptr){ - // 错误数据,直接删除 - delete gpuMem; - gpuMem = nullptr; - printf("mem is null \n"); - } else { - vec_gpuMem.push_back(gpuMem); - } - m_RgbDataList.pop_front(); - if(vec_gpuMem.size() >= m_batch_size){ - break; - } - } - m_DataListMtx.unlock(); - - if(vec_gpuMem.size() <= 0){ - std::this_thread::sleep_for(std::chrono::milliseconds(3)); - continue; - } - - aclrtSetCurrentContext(ctx); - algorthim_face_detect(vec_gpuMem); - - for(int i=0;i < vec_gpuMem.size(); i++){ - DeviceMemory* mem = vec_gpuMem[i]; - if(mem->getSize() <= 0){ - continue; - } - delete mem; - mem = nullptr; - } - vec_gpuMem.clear(); - - } - - aclrtDestroyContext(ctx); - - printf("algorthim_process_thread exit. \n"); -} - -void algorthim_face_detect(vector vec_gpuMem) { - - vector interest_task_list; - vector interest_imgs; - vector vec_vptMem; - - for (int i = 0; i < vec_gpuMem.size(); i++) { - DeviceMemory* mem = vec_gpuMem[i]; - - sy_img img; - img.w_ = mem->getWidth(); - img.h_ = mem->getHeight(); - img.c_ = mem->getChannel(); - img.data_ = mem->getMem(); - interest_imgs.push_back(img); - interest_task_list.push_back(mem->getId()); - vec_vptMem.push_back(mem); - } - - cv::Scalar color; - color[0]=0; - color[1]=0; - color[2]=255; - if (!interest_imgs.empty()) { - - unsigned image_size = interest_imgs.size(); - - // 人脸检测、跟踪 - std::vector facedet_result(image_size); - std::vector> face_deleteObjectID(image_size); - - int ret = m_face_det_ai_engine.ai_engine_process_batch(interest_task_list, interest_imgs.data(), facedet_result, face_deleteObjectID); - if(ret <= 0){ - printf("face detect error!!! \n"); - return; - } - - - - aclrtSetCurrentContext(ctx); - for(int idx=0; idx < vec_vptMem.size(); idx++){ - - DeviceMemory* memPtr = vec_vptMem[idx]; - string task_id = memPtr->getId(); - int channel = memPtr->getChannel(); - int height = memPtr->getHeight(); - int width = memPtr->getWidth(); - - if (0 == facedet_result[idx].obj_count) { - continue; - } - - int nSize = channel * height * width; - unsigned char* cpu_data = (unsigned char *)malloc(nSize * sizeof(unsigned char)); - aclError aclRet = aclrtMemcpy(cpu_data, nSize, memPtr->getMem(), nSize, ACL_MEMCPY_DEVICE_TO_HOST); - cv::Mat img_(height, width, CV_8UC3, cpu_data); - - for (int c = 0; c < facedet_result[idx].obj_count; c++) { - - det_objinfo obj_info = facedet_result[idx].obj[c]; - string str_obj_id = to_string(obj_info.id); - cv::rectangle(img_,cv::Point(obj_info.left,obj_info.top),cv::Point(obj_info.right,obj_info.bottom),color,2); - cv::putText(img_,str_obj_id.c_str(),cv::Point(obj_info.center_x,obj_info.center_y),cv::FONT_HERSHEY_SIMPLEX,2,cv::Scalar(0,0,255),4,8); - } - - string file_name = "./res/recode/" + task_id + "_" + to_string(memPtr->getFrameNb()) + ".jpg"; - bool bWrite = cv::imwrite(file_name, img_); - - free(cpu_data); - } - - - - - - for (int i = 0; i < face_deleteObjectID.size(); ++i){ - std::vector().swap(face_deleteObjectID[i]); - } - std::vector>().swap(face_deleteObjectID); - std::vector().swap(facedet_result); - } - - aclFinalize(); -} \ No newline at end of file diff --git a/src/decoder/test_face.cpp1 b/src/decoder/test_face.cpp1 new file mode 100644 index 0000000..1ef3eb2 --- /dev/null +++ b/src/decoder/test_face.cpp1 @@ -0,0 +1,317 @@ +#include "./interface/DecoderManager.h" +#include +#include +#include +#include + +#include "acl/acl.h" +#include "acl/ops/acl_dvpp.h" + +#include + +#include "../ai_engine_module/face_det_ai_engine.h" + +using namespace std; + +struct decode_cbk_userdata{ + string task_id; + void* opaque; + void* opaque1; +}; + +deque m_RgbDataList; +mutex m_DataListMtx; + +thread* m_pAlgorthimThread{nullptr}; +bool m_bfinish{false}; +int m_devId = 0; +const char* task_id = "test0"; +int skip_frame_ = 5; +int m_batch_size = 10; + +face_det_ai_engine m_face_det_ai_engine; + +aclrtContext ctx; + +void algorthim_process_thread(); +void algorthim_face_detect(vector vec_gpuMem); + +static long long get_cur_time_ms(){ + chrono::time_point tpMicro + = chrono::time_point_cast(chrono::system_clock::now()); + + return tpMicro.time_since_epoch().count(); +} + +static void post_decod_cbk(const void * userPtr, DeviceMemory* devFrame){ + do{ + if(m_bfinish){ + break; + } + m_DataListMtx.lock(); + if(m_RgbDataList.size() >= 30){ + m_DataListMtx.unlock(); + std::this_thread::sleep_for(std::chrono::milliseconds(3)); + continue; + } + m_RgbDataList.push_back(devFrame); + m_DataListMtx.unlock(); + break; + }while (true); +} + +static void decode_finished_cbk(const void * userPtr){ + decode_cbk_userdata* ptr = (decode_cbk_userdata*)userPtr; + if (ptr!= nullptr){ + printf("task finished: %s \n", ptr->task_id.c_str()); + } + delete ptr; + ptr = nullptr; +} + +int main(){ + + // 算法初始化 + string models_dir = "."; + + aclInit(nullptr); + aclrtSetDevice(m_devId); + + // 人脸检测初始化 + facedet_ai_engine_param fd_param; + char model_path_yolov5s[100]; + strcpy(model_path_yolov5s, (models_dir + "/models/face_detect/face_det_yolov5s_310p.om").c_str()); + fd_param.sdk_param.det_modelNames = model_path_yolov5s; + char model_path_ldmk[100]; + strcpy(model_path_ldmk, (models_dir + "/models/face_detect/face_ldmk_310p.om").c_str()); + fd_param.sdk_param.ldmk_modelNames = model_path_ldmk; + char model_path_pose[100]; + strcpy(model_path_pose, (models_dir + "/models/face_detect/face_pose_310p.om").c_str()); + fd_param.sdk_param.pose_modelNames = model_path_pose; + char model_path_score[100]; + strcpy(model_path_score, (models_dir + "/models/face_detect/face_score_310p.om").c_str()); + fd_param.sdk_param.score_modelNames = model_path_score; + char model_path_fuzzy[100]; + strcpy(model_path_fuzzy, (models_dir + "/models/face_detect/face_fuzzy_310p.om").c_str()); + fd_param.sdk_param.fuzzy_modelNames = model_path_fuzzy; + char model_path_occlusion[100]; + strcpy(model_path_occlusion, (models_dir + "/models/face_detect/face_occlusion_310p.om").c_str()); + fd_param.sdk_param.occlusion_modelNames = model_path_occlusion; + fd_param.sdk_param.thresld = 0.6; + fd_param.sdk_param.devId = m_devId; + fd_param.sdk_param.auth_license = "sy_tongtu_aiplatform_sdk_2023"; + fd_param.sdk_param.facial_fea_point_config = SY_CONFIG_OPEN; //是否启动关键点检测 + fd_param.sdk_param.pose_config = SY_CONFIG_OPEN; //是否启动姿态角 + fd_param.sdk_param.quality_config = SY_CONFIG_OPEN; //是否启动质量检测 + fd_param.sdk_param.score_config = SY_CONFIG_OPEN; //是否启动人脸置信度 //SY_CONFIG_OPEN SY_CONFIG_CLOSE + fd_param.sdk_param.max_result_count = 50; + int ret = m_face_det_ai_engine.init_ai_engine(fd_param); + if (ret < 0 ) { + printf("Init face detection failed"); + return ret; + } + + // facedet_ai_engine_param fd_param; + // fd_param.sdk_param.det_modelNames = "./models/face_detect/face_det_yolov5s_310p.om"; + // fd_param.sdk_param.ldmk_modelNames = "./models/face_detect/face_ldmk_310p.om"; + // fd_param.sdk_param.pose_modelNames = "./models/face_detect/face_pose_310p.om"; + // fd_param.sdk_param.score_modelNames = "./models/face_detect/face_score_310p.om"; + // fd_param.sdk_param.fuzzy_modelNames = "./models/face_detect/face_fuzzy_310p.om"; + // fd_param.sdk_param.occlusion_modelNames = "./models/face_detect/face_occlusion_310p.om"; + // fd_param.sdk_param.thresld = 0.6; + // fd_param.sdk_param.devId = m_devId; + // fd_param.sdk_param.auth_license = "sy_tongtu_aiplatform_sdk_2023"; + // fd_param.sdk_param.facial_fea_point_config = SY_CONFIG_OPEN; //是否启动关键点检测 + // fd_param.sdk_param.pose_config = SY_CONFIG_OPEN; //是否启动姿态角 + // fd_param.sdk_param.quality_config = SY_CONFIG_OPEN; //是否启动质量检测 + // fd_param.sdk_param.score_config = SY_CONFIG_OPEN; //是否启动人脸置信度 //SY_CONFIG_OPEN SY_CONFIG_CLOSE + // fd_param.sdk_param.max_result_count = 50; + // int ret = m_face_det_ai_engine.init_ai_engine(fd_param); + // if (ret < 0 ) { + // printf("Init face detection failed \n"); + // return ret; + // } + m_face_det_ai_engine.add_tracker(task_id, skip_frame_); // 跳帧数暂时写死 + + + // 创建解码任务 + DecoderManager* pDecManager = DecoderManager::getInstance(); + + MgrDecConfig config; + config.name = task_id; + config.cfg.uri = "/opt/share/data/caishenkezhan.mp4"; + config.cfg.post_decoded_cbk = post_decod_cbk; + config.cfg.decode_finished_cbk = decode_finished_cbk; + config.cfg.force_tcp = true; // rtsp用tcp + config.cfg.gpuid = to_string(m_devId); + config.cfg.skip_frame = skip_frame_; + + config.dec_type = DECODER_TYPE_DVPP; + + AbstractDecoder* dec = pDecManager->createDecoder(config); + if (!dec){ + printf("创建解码器失败 \n"); + return false; + } + + decode_cbk_userdata* userPtr = new decode_cbk_userdata; + userPtr->task_id = string(task_id); + pDecManager->setPostDecArg(config.name, userPtr); + pDecManager->setFinishedDecArg(config.name, userPtr); + + + int input_image_width = 0; + int input_image_height = 0; + pDecManager->getResolution(config.name, input_image_width, input_image_height); + + + // 创建算法线程 + m_pAlgorthimThread = new thread([](void* arg) { + algorthim_process_thread(); + return (void*)0; + } + , nullptr); + + pDecManager->startDecodeByName(config.name); + + while (getchar() != 'q'); +} + +void algorthim_process_thread(){ + + aclrtSetDevice(m_devId); + aclrtCreateContext(&ctx, m_devId); + + while (true){ + if(m_bfinish){ + break; + } + + vector vec_gpuMem; + m_DataListMtx.lock(); + while (!m_RgbDataList.empty()){ + DeviceMemory* gpuMem = m_RgbDataList.front(); + if(gpuMem->getMem() == nullptr){ + // 错误数据,直接删除 + delete gpuMem; + gpuMem = nullptr; + printf("mem is null \n"); + } else { + vec_gpuMem.push_back(gpuMem); + } + m_RgbDataList.pop_front(); + if(vec_gpuMem.size() >= m_batch_size){ + break; + } + } + m_DataListMtx.unlock(); + + if(vec_gpuMem.size() <= 0){ + std::this_thread::sleep_for(std::chrono::milliseconds(3)); + continue; + } + + aclrtSetCurrentContext(ctx); + algorthim_face_detect(vec_gpuMem); + + for(int i=0;i < vec_gpuMem.size(); i++){ + DeviceMemory* mem = vec_gpuMem[i]; + if(mem->getSize() <= 0){ + continue; + } + delete mem; + mem = nullptr; + } + vec_gpuMem.clear(); + + } + + aclrtDestroyContext(ctx); + + printf("algorthim_process_thread exit. \n"); +} + +void algorthim_face_detect(vector vec_gpuMem) { + + vector interest_task_list; + vector interest_imgs; + vector vec_vptMem; + + for (int i = 0; i < vec_gpuMem.size(); i++) { + DeviceMemory* mem = vec_gpuMem[i]; + + sy_img img; + img.w_ = mem->getWidth(); + img.h_ = mem->getHeight(); + img.c_ = mem->getChannel(); + img.data_ = mem->getMem(); + interest_imgs.push_back(img); + interest_task_list.push_back(mem->getId()); + vec_vptMem.push_back(mem); + } + + cv::Scalar color; + color[0]=0; + color[1]=0; + color[2]=255; + if (!interest_imgs.empty()) { + + unsigned image_size = interest_imgs.size(); + + // 人脸检测、跟踪 + std::vector facedet_result(image_size); + std::vector> face_deleteObjectID(image_size); + + int ret = m_face_det_ai_engine.ai_engine_process_batch(interest_task_list, interest_imgs.data(), facedet_result, face_deleteObjectID); + if(ret <= 0){ + printf("face detect error!!! \n"); + return; + } + + + + aclrtSetCurrentContext(ctx); + for(int idx=0; idx < vec_vptMem.size(); idx++){ + + DeviceMemory* memPtr = vec_vptMem[idx]; + string task_id = memPtr->getId(); + int channel = memPtr->getChannel(); + int height = memPtr->getHeight(); + int width = memPtr->getWidth(); + + if (0 == facedet_result[idx].obj_count) { + continue; + } + + int nSize = channel * height * width; + unsigned char* cpu_data = (unsigned char *)malloc(nSize * sizeof(unsigned char)); + aclError aclRet = aclrtMemcpy(cpu_data, nSize, memPtr->getMem(), nSize, ACL_MEMCPY_DEVICE_TO_HOST); + cv::Mat img_(height, width, CV_8UC3, cpu_data); + + for (int c = 0; c < facedet_result[idx].obj_count; c++) { + + det_objinfo obj_info = facedet_result[idx].obj[c]; + string str_obj_id = to_string(obj_info.id); + cv::rectangle(img_,cv::Point(obj_info.left,obj_info.top),cv::Point(obj_info.right,obj_info.bottom),color,2); + cv::putText(img_,str_obj_id.c_str(),cv::Point(obj_info.center_x,obj_info.center_y),cv::FONT_HERSHEY_SIMPLEX,2,cv::Scalar(0,0,255),4,8); + } + + string file_name = "./res/recode/" + task_id + "_" + to_string(memPtr->getFrameNb()) + ".jpg"; + bool bWrite = cv::imwrite(file_name, img_); + + free(cpu_data); + } + + + + + + for (int i = 0; i < face_deleteObjectID.size(); ++i){ + std::vector().swap(face_deleteObjectID[i]); + } + std::vector>().swap(face_deleteObjectID); + std::vector().swap(facedet_result); + } + + aclFinalize(); +} \ No newline at end of file diff --git a/src/decoder/test_recoder.cpp b/src/decoder/test_recoder.cpp new file mode 100644 index 0000000..d373aa8 --- /dev/null +++ b/src/decoder/test_recoder.cpp @@ -0,0 +1,248 @@ +#include "./interface/DecoderManager.h" +#include +#include +#include + +using namespace std; + +struct decode_cbk_userdata{ + string task_id; + void* opaque; + void* opaque1; +}; + +deque m_RgbDataList; +mutex m_DataListMtx; + +thread* m_pAlgorthimThread{nullptr}; +thread* m_recodeThread{nullptr}; +bool m_bfinish{false}; +int m_devId = 0; +const char* task_id = "test0"; +int skip_frame_ = 5; +int m_batch_size = 20; + +deque m_recoderinfo_queue; +mutex m_recoderinfo_queue_mtx; + +void algorthim_process_thread(); +void recode_thread(); +void algorthim_face_detect(vector vec_gpuMem); + +void test_recode_thread(); + +void post_decod_cbk(const void * userPtr, DeviceMemory* devFrame){ + do{ + if(m_bfinish){ + break; + } + m_DataListMtx.lock(); + if(m_RgbDataList.size() >= 30){ + m_DataListMtx.unlock(); + std::this_thread::sleep_for(std::chrono::milliseconds(3)); + continue; + } + m_RgbDataList.push_back(devFrame); + m_DataListMtx.unlock(); + break; + }while (true); +} + +void decode_finished_cbk(const void * userPtr){ + decode_cbk_userdata* ptr = (decode_cbk_userdata*)userPtr; + if (ptr!= nullptr){ + printf("task finished: %s \n", ptr->task_id.c_str()); + } + delete ptr; + ptr = nullptr; +} + +int main(){ + + // 创建解码任务 + DecoderManager* pDecManager = DecoderManager::getInstance(); + + MgrDecConfig config; + config.name = task_id; + config.cfg.uri = "/opt/cmhu/data/公安局老桥头_CVR15F89410_1465819864_1B.mp4"; + config.cfg.post_decoded_cbk = post_decod_cbk; + config.cfg.decode_finished_cbk = decode_finished_cbk; + config.cfg.force_tcp = true; // rtsp用tcp + config.cfg.gpuid = to_string(m_devId); + config.cfg.skip_frame = skip_frame_; + + config.dec_type = DECODER_TYPE_DVPP; + + AbstractDecoder* dec = pDecManager->createDecoder(config); + if (!dec){ + printf("创建解码器失败 \n"); + return false; + } + + decode_cbk_userdata* userPtr = new decode_cbk_userdata; + userPtr->task_id = string(task_id); + pDecManager->setPostDecArg(config.name, userPtr); + pDecManager->setFinishedDecArg(config.name, userPtr); + + + int input_image_width = 0; + int input_image_height = 0; + pDecManager->getResolution(config.name, input_image_width, input_image_height); + + + // 创建算法线程 + m_pAlgorthimThread = new thread([](void* arg) { + algorthim_process_thread(); + return (void*)0; + } + , nullptr); + + // m_recodeThread = new thread([](void* arg) { + // recode_thread(); + // return (void*)0; + // } + // , nullptr); + + m_recodeThread = new thread([](void* arg) { + test_recode_thread(); + return (void*)0; + } + , nullptr); + + pDecManager->startDecodeByName(config.name); + + while (getchar() != 'q'); +} + +void algorthim_process_thread(){ + + while (true){ + if(m_bfinish){ + break; + } + + vector vec_gpuMem; + m_DataListMtx.lock(); + while (!m_RgbDataList.empty()){ + DeviceMemory* gpuMem = m_RgbDataList.front(); + if(gpuMem->getMem() == nullptr){ + // 错误数据,直接删除 + delete gpuMem; + gpuMem = nullptr; + printf("mem is null \n"); + } else { + vec_gpuMem.push_back(gpuMem); + } + m_RgbDataList.pop_front(); + if(vec_gpuMem.size() >= m_batch_size){ + break; + } + } + m_DataListMtx.unlock(); + + if(vec_gpuMem.size() <= 0){ + std::this_thread::sleep_for(std::chrono::milliseconds(3)); + continue; + } + + algorthim_face_detect(vec_gpuMem); + + for(int i=0;i < vec_gpuMem.size(); i++){ + DeviceMemory* mem = vec_gpuMem[i]; + if(mem->getSize() <= 0){ + continue; + } + delete mem; + mem = nullptr; + } + vec_gpuMem.clear(); + + } + + printf("algorthim_process_thread exit. \n"); +} + +static int interval = 0; +static int obj_id = 0; + +void algorthim_face_detect(vector vec_gpuMem) { + interval ++ ; + + if(interval % 50 != 0) { + return; + } + + for(int i= 0; i < vec_gpuMem.size(); i++) { + DeviceMemory* mem = vec_gpuMem[i]; + string task_id = mem->getId(); + + RecoderInfo recoderInfo; + recoderInfo.task_id = task_id; + recoderInfo.object_id = std::to_string(obj_id); + recoderInfo.recoderPath = "./res/recode"; + recoderInfo.frame_nb = mem->getFrameNb(); + + m_recoderinfo_queue_mtx.lock(); + m_recoderinfo_queue.push_back(recoderInfo); + m_recoderinfo_queue_mtx.unlock(); + + obj_id++; + + } +} + +void test_recode_thread() { + unsigned long long frame_index = 0; + while(true) { + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + + DeviceMemory* mem = nullptr; + m_DataListMtx.lock(); + while (!m_RgbDataList.empty()){ + DeviceMemory* gpuMem = m_RgbDataList.front(); + if(gpuMem->getMem() == nullptr){ + // 错误数据,直接删除 + delete gpuMem; + gpuMem = nullptr; + printf("mem is null \n"); + } else { + frame_index ++ ; + if (frame_index % 50 == 0) { + RecoderInfo recoderInfo; + recoderInfo.task_id = gpuMem->getId(); + recoderInfo.object_id = std::to_string(obj_id); + recoderInfo.recoderPath = "./res/recode"; + recoderInfo.frame_nb = gpuMem->getFrameNb(); + + DecoderManager* pDecManager = DecoderManager::getInstance(); + pDecManager->doRecode(recoderInfo); + + obj_id++; + } + delete gpuMem; + gpuMem = nullptr; + } + m_RgbDataList.pop_front(); + } + m_DataListMtx.unlock(); + } +} + +void recode_thread() { + while(true) { + + m_recoderinfo_queue_mtx.lock(); + if(m_recoderinfo_queue.size() <= 0) { + m_recoderinfo_queue_mtx.unlock(); + std::this_thread::sleep_for(std::chrono::milliseconds(5)); + continue; + } + + RecoderInfo info = m_recoderinfo_queue.front(); + m_recoderinfo_queue.pop_front(); + m_recoderinfo_queue_mtx.unlock(); + + DecoderManager* pDecManager = DecoderManager::getInstance(); + pDecManager->doRecode(info); + } +} \ No newline at end of file diff --git a/src/demo/demo.cpp b/src/demo/demo.cpp index 8ee9f53..d92f286 100755 --- a/src/demo/demo.cpp +++ b/src/demo/demo.cpp @@ -396,6 +396,27 @@ void set_task_params(task_param &tparam, const unsigned &idx, const algorithm_ty algor_init_params->basic_param = basic_params; } break; + case algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND: { + auto algor_params = new algor_config_param_manned_incident; + { + algor_params->m = 10; + algor_params->n = 8; + algor_params->obj_confidence_threshold = 0.5f; + algor_params->obj_min_height = 40; + algor_params->obj_min_width = 40; + } + + auto basic_params = new algor_basic_config_param_t; + { + basic_params->video_folder = "res/video_recode"; + basic_params->result_folder = "res/vehicle_solid_turnaround"; + basic_params->result_folder_little = "res/vehicle_solid_turnaround_little"; + } + + algor_init_params->algor_param = algor_params; + algor_init_params->basic_param = basic_params; + } break; + case algorithm_type_t::FACE_SNAPSHOT: { auto basic_params = new algor_basic_config_param_t; @@ -1037,11 +1058,10 @@ void test_gpu(int gpuID){ std::vector algor_vec2 = {algorithm_type_t::NONMOTOR_VEHICLE_NOHELMET, algorithm_type_t::NONMOTOR_VEHICLE_OVERMAN, algorithm_type_t::TRICYCLE_MANNED, algorithm_type_t::TRUCK_MANNED, algorithm_type_t::NONMOTOR_VEHICLE_USEPHONE, 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, - 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}; - std::vector 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, - algorithm_type_t::NONMOTOR_VEHICLE_REFIT, algorithm_type_t::PERSON_RUNNING_REDLIGHTS, algorithm_type_t::NONMOTOR_RUNNING_REDLIGHTS}; - // std::vector algor_vec3 = {algorithm_type_t::NONMOTOR_VEHICLE_NOHELMET, algorithm_type_t::NONMOTOR_VEHICLE_OVERMAN, algorithm_type_t::TRICYCLE_MANNED, algorithm_type_t::NONMOTOR_VEHICLE_USEPHONE, - // algorithm_type_t::NONMOTOR_VEHICLE_REFIT}; + 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, algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND}; + // std::vector 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, + // algorithm_type_t::NONMOTOR_VEHICLE_REFIT, algorithm_type_t::PERSON_RUNNING_REDLIGHTS, algorithm_type_t::NONMOTOR_RUNNING_REDLIGHTS}; + std::vector algor_vec3 = {algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND}; /* int repeat_num = 1000; @@ -1063,18 +1083,18 @@ void test_gpu(int gpuID){ // createTask(handle, algor_vec, 1); // createTask(handle, algor_vec, 2); // createTask(handle, algor_vec, 3); - // createTask(handle, algor_vec3, 4); - createTask(handle, algor_vec2, 5); - createTask(handle, algor_vec2, 6); - createTask(handle, algor_vec2, 7); - createTask(handle, algor_vec2, 8); - createTask(handle, algor_vec2, 9); - createTask(handle, algor_vec2, 10); - createTask(handle, algor_vec2, 11); - createTask(handle, algor_vec2, 12); - createTask(handle, algor_vec2, 13); - createTask(handle, algor_vec2, 14); - createTask(handle, algor_vec2, 15); + createTask(handle, algor_vec3, 4); + createTask(handle, algor_vec3, 5); + createTask(handle, algor_vec3, 6); + createTask(handle, algor_vec3, 7); + createTask(handle, algor_vec3, 8); + createTask(handle, algor_vec3, 9); + createTask(handle, algor_vec3, 10); + // createTask(handle, algor_vec3, 11); + // createTask(handle, algor_vec3, 12); + // createTask(handle, algor_vec3, 13); + // createTask(handle, algor_vec3, 14); + // createTask(handle, algor_vec3, 15); // createTask(handle, algor_vec2, 16); // createTask(handle, algor_vec2, 17); // createTask(handle, algor_vec2, 18); -- libgit2 0.21.4