From f258e1c87c836ea676927b08d0afb214ea48f1f0 Mon Sep 17 00:00:00 2001 From: cmhu <2657262686@qq.com> Date: Mon, 13 Jan 2025 18:52:49 +0800 Subject: [PATCH] 添加非机动车驾乘信息 --- src/PicAnalysis.cpp | 15 +++++++++++++++ src/ai_engine_module/HumanCarAnalysis.cpp | 18 +++++++++++++++++- src/ai_engine_module/HumanCarAnalysis.h | 8 +++++++- src/ai_engine_module/include.h | 3 +++ src/village_inc.h | 2 +- 5 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/PicAnalysis.cpp b/src/PicAnalysis.cpp index d1fc2ba..a0c7f66 100644 --- a/src/PicAnalysis.cpp +++ b/src/PicAnalysis.cpp @@ -328,12 +328,27 @@ vector PicAnalysis::analysis_img(vector vec_img){ result_info.phoning_prob = vec_phone_result[0].prob; } + int iColor = -1; std::vector vec_hcp_result = m_human_car_algorithm.detect(vec_motor_img); if (vec_hcp_result.size() > 0 && road_info.vec_direct.size() > 0) { int head_or_tail = vec_hcp_result[0].orient; if (head_or_tail == 0 || head_or_tail == 1) { result_info.reverse_driving = m_road_seg_algorithm.check_reverse_driving(road_info.vec_direct, vehicle_rect, src.width, src.height, head_or_tail); } + iColor = vec_hcp_result[0].up_color; + } + + int hs_num = result_info.manned_res.hs_count; + for (size_t i = 0; i < hs_num; i++) + { + pendant_info one_pendant; + one_pendant.confidence = result_info.manned_res.hs_rect[i].score; + one_pendant.rect = result_info.manned_res.hs_rect[i].rect; + one_pendant.index = 0; + one_pendant.iColor = iColor; + + result_info.vehicle_pendant_det_res.push_back(one_pendant); + } delete motor_data; diff --git a/src/ai_engine_module/HumanCarAnalysis.cpp b/src/ai_engine_module/HumanCarAnalysis.cpp index 9125318..89eb814 100644 --- a/src/ai_engine_module/HumanCarAnalysis.cpp +++ b/src/ai_engine_module/HumanCarAnalysis.cpp @@ -1,4 +1,8 @@ #include "HumanCarAnalysis.h" +#include "human_car_parsing.h" + +static std::vector STANDARD_COLOR_TABLE = {"棕", "橙", "灰", "白", "粉", "紫", "红", "绿", "蓝", "银", "青", "黄", "黑", "多色", "其他"}; +std::string human_car_color[] = {"黑" , "白" , "红", "黄", "蓝", "绿", "灰", "多色", "其他"}; HumanCarAnalysis::HumanCarAnalysis(/* args */) { @@ -28,6 +32,18 @@ int HumanCarAnalysis::init(int devId){ return SY_SUCCESS; } +int get_standard_color(int index) { + int index_standard = -1; + string str_color = human_car_color[index]; + for (size_t i = 0; i < STANDARD_COLOR_TABLE.size(); i++) { + if(STANDARD_COLOR_TABLE[i] == str_color) { + index_standard = i; + break; + } + } + return index_standard; +} + std::vector HumanCarAnalysis::detect(vector vec_img){ std::vector vec_result; @@ -63,7 +79,7 @@ std::vector HumanCarAnalysis::detect(vector vec_img){ one_result.weibo_prob = results[batchIdx].res_objs[3].res_prob; one_result.up_wear = results[batchIdx].res_objs[4].res_index; one_result.up_wear_prob = results[batchIdx].res_objs[4].res_prob; - one_result.up_color = results[batchIdx].res_objs[5].res_index; + one_result.up_color = get_standard_color(results[batchIdx].res_objs[5].res_index); one_result.up_color_prob = results[batchIdx].res_objs[5].res_prob; one_result.up_tex = results[batchIdx].res_objs[6].res_index; one_result.up_tex_prob = results[batchIdx].res_objs[6].res_prob; diff --git a/src/ai_engine_module/HumanCarAnalysis.h b/src/ai_engine_module/HumanCarAnalysis.h index 3b57967..c3c2dd6 100644 --- a/src/ai_engine_module/HumanCarAnalysis.h +++ b/src/ai_engine_module/HumanCarAnalysis.h @@ -1,5 +1,8 @@ +#ifndef __HUMAN_CAR_ANALYSIS_H__ +#define __HUMAN_CAR_ANALYSIS_H__ + + #include "include.h" -#include "human_car_parsing.h" struct HumanCarResult { int head; // 0 – (长发) , 1 - (短发) , 2 - (光头) , 3 -( 帽子), 4- (头盔), 5– (其他) @@ -50,3 +53,6 @@ private: aclrtContext ctx{nullptr}; }; + + +#endif // __HUMAN_CAR_ANALYSIS_H__ \ No newline at end of file diff --git a/src/ai_engine_module/include.h b/src/ai_engine_module/include.h index 0f10e1f..5b43049 100644 --- a/src/ai_engine_module/include.h +++ b/src/ai_engine_module/include.h @@ -21,10 +21,13 @@ #include #include #include +#include using namespace std; using namespace cv; +// static std::vector STANDARD_COLOR_TABLE = {"棕", "橙", "灰", "白", "粉", "紫", "红", "绿", "蓝", "银", "青", "黄", "黑", "多色", "其他"}; + #endif \ No newline at end of file diff --git a/src/village_inc.h b/src/village_inc.h index 4dcac5f..0785d34 100644 --- a/src/village_inc.h +++ b/src/village_inc.h @@ -17,7 +17,7 @@ typedef struct pendant_info int index; //���� 0-driver 1-face 2-belt 3-sunshield 4-tag 5-decoration 6-napkinbox 7-zhuanjt 8-callPhone 9-sunRoof 10-holder 11-smoke float confidence; int driver_copilot_info; - int iColor; //13类:"棕", "橙", "灰", "白", "粉", "紫", "红", "绿", "蓝", "银", "青", "黄", "黑" + int iColor; // "棕", "橙", "灰", "白", "粉", "紫", "红", "绿", "蓝", "银", "青", "黄", "黑", ,"多色", "其他" } pendant_info; typedef struct VehicleInfo { -- libgit2 0.21.4