Commit f258e1c87c836ea676927b08d0afb214ea48f1f0
1 parent
a1a053f2
添加非机动车驾乘信息
Showing
5 changed files
with
43 additions
and
3 deletions
src/PicAnalysis.cpp
@@ -328,12 +328,27 @@ vector<AnalysisResult> PicAnalysis::analysis_img(vector<sy_img> vec_img){ | @@ -328,12 +328,27 @@ vector<AnalysisResult> PicAnalysis::analysis_img(vector<sy_img> vec_img){ | ||
328 | result_info.phoning_prob = vec_phone_result[0].prob; | 328 | result_info.phoning_prob = vec_phone_result[0].prob; |
329 | } | 329 | } |
330 | 330 | ||
331 | + int iColor = -1; | ||
331 | std::vector<HumanCarResult> vec_hcp_result = m_human_car_algorithm.detect(vec_motor_img); | 332 | std::vector<HumanCarResult> vec_hcp_result = m_human_car_algorithm.detect(vec_motor_img); |
332 | if (vec_hcp_result.size() > 0 && road_info.vec_direct.size() > 0) { | 333 | if (vec_hcp_result.size() > 0 && road_info.vec_direct.size() > 0) { |
333 | int head_or_tail = vec_hcp_result[0].orient; | 334 | int head_or_tail = vec_hcp_result[0].orient; |
334 | if (head_or_tail == 0 || head_or_tail == 1) { | 335 | if (head_or_tail == 0 || head_or_tail == 1) { |
335 | result_info.reverse_driving = m_road_seg_algorithm.check_reverse_driving(road_info.vec_direct, vehicle_rect, src.width, src.height, head_or_tail); | 336 | result_info.reverse_driving = m_road_seg_algorithm.check_reverse_driving(road_info.vec_direct, vehicle_rect, src.width, src.height, head_or_tail); |
336 | } | 337 | } |
338 | + iColor = vec_hcp_result[0].up_color; | ||
339 | + } | ||
340 | + | ||
341 | + int hs_num = result_info.manned_res.hs_count; | ||
342 | + for (size_t i = 0; i < hs_num; i++) | ||
343 | + { | ||
344 | + pendant_info one_pendant; | ||
345 | + one_pendant.confidence = result_info.manned_res.hs_rect[i].score; | ||
346 | + one_pendant.rect = result_info.manned_res.hs_rect[i].rect; | ||
347 | + one_pendant.index = 0; | ||
348 | + one_pendant.iColor = iColor; | ||
349 | + | ||
350 | + result_info.vehicle_pendant_det_res.push_back(one_pendant); | ||
351 | + | ||
337 | } | 352 | } |
338 | 353 | ||
339 | delete motor_data; | 354 | delete motor_data; |
src/ai_engine_module/HumanCarAnalysis.cpp
1 | #include "HumanCarAnalysis.h" | 1 | #include "HumanCarAnalysis.h" |
2 | +#include "human_car_parsing.h" | ||
3 | + | ||
4 | +static std::vector<std::string> STANDARD_COLOR_TABLE = {"棕", "橙", "灰", "白", "粉", "紫", "红", "绿", "蓝", "银", "青", "黄", "黑", "多色", "其他"}; | ||
5 | +std::string human_car_color[] = {"黑" , "白" , "红", "黄", "蓝", "绿", "灰", "多色", "其他"}; | ||
2 | 6 | ||
3 | HumanCarAnalysis::HumanCarAnalysis(/* args */) | 7 | HumanCarAnalysis::HumanCarAnalysis(/* args */) |
4 | { | 8 | { |
@@ -28,6 +32,18 @@ int HumanCarAnalysis::init(int devId){ | @@ -28,6 +32,18 @@ int HumanCarAnalysis::init(int devId){ | ||
28 | return SY_SUCCESS; | 32 | return SY_SUCCESS; |
29 | } | 33 | } |
30 | 34 | ||
35 | +int get_standard_color(int index) { | ||
36 | + int index_standard = -1; | ||
37 | + string str_color = human_car_color[index]; | ||
38 | + for (size_t i = 0; i < STANDARD_COLOR_TABLE.size(); i++) { | ||
39 | + if(STANDARD_COLOR_TABLE[i] == str_color) { | ||
40 | + index_standard = i; | ||
41 | + break; | ||
42 | + } | ||
43 | + } | ||
44 | + return index_standard; | ||
45 | +} | ||
46 | + | ||
31 | std::vector<HumanCarResult> HumanCarAnalysis::detect(vector<sy_img> vec_img){ | 47 | std::vector<HumanCarResult> HumanCarAnalysis::detect(vector<sy_img> vec_img){ |
32 | 48 | ||
33 | std::vector<HumanCarResult> vec_result; | 49 | std::vector<HumanCarResult> vec_result; |
@@ -63,7 +79,7 @@ std::vector<HumanCarResult> HumanCarAnalysis::detect(vector<sy_img> vec_img){ | @@ -63,7 +79,7 @@ std::vector<HumanCarResult> HumanCarAnalysis::detect(vector<sy_img> vec_img){ | ||
63 | one_result.weibo_prob = results[batchIdx].res_objs[3].res_prob; | 79 | one_result.weibo_prob = results[batchIdx].res_objs[3].res_prob; |
64 | one_result.up_wear = results[batchIdx].res_objs[4].res_index; | 80 | one_result.up_wear = results[batchIdx].res_objs[4].res_index; |
65 | one_result.up_wear_prob = results[batchIdx].res_objs[4].res_prob; | 81 | one_result.up_wear_prob = results[batchIdx].res_objs[4].res_prob; |
66 | - one_result.up_color = results[batchIdx].res_objs[5].res_index; | 82 | + one_result.up_color = get_standard_color(results[batchIdx].res_objs[5].res_index); |
67 | one_result.up_color_prob = results[batchIdx].res_objs[5].res_prob; | 83 | one_result.up_color_prob = results[batchIdx].res_objs[5].res_prob; |
68 | one_result.up_tex = results[batchIdx].res_objs[6].res_index; | 84 | one_result.up_tex = results[batchIdx].res_objs[6].res_index; |
69 | one_result.up_tex_prob = results[batchIdx].res_objs[6].res_prob; | 85 | one_result.up_tex_prob = results[batchIdx].res_objs[6].res_prob; |
src/ai_engine_module/HumanCarAnalysis.h
1 | +#ifndef __HUMAN_CAR_ANALYSIS_H__ | ||
2 | +#define __HUMAN_CAR_ANALYSIS_H__ | ||
3 | + | ||
4 | + | ||
1 | #include "include.h" | 5 | #include "include.h" |
2 | -#include "human_car_parsing.h" | ||
3 | 6 | ||
4 | struct HumanCarResult { | 7 | struct HumanCarResult { |
5 | int head; // 0 – (长发) , 1 - (短发) , 2 - (光头) , 3 -( 帽子), 4- (头盔), 5– (其他) | 8 | int head; // 0 – (长发) , 1 - (短发) , 2 - (光头) , 3 -( 帽子), 4- (头盔), 5– (其他) |
@@ -50,3 +53,6 @@ private: | @@ -50,3 +53,6 @@ private: | ||
50 | aclrtContext ctx{nullptr}; | 53 | aclrtContext ctx{nullptr}; |
51 | }; | 54 | }; |
52 | 55 | ||
56 | + | ||
57 | + | ||
58 | +#endif // __HUMAN_CAR_ANALYSIS_H__ | ||
53 | \ No newline at end of file | 59 | \ No newline at end of file |
src/ai_engine_module/include.h
@@ -21,10 +21,13 @@ | @@ -21,10 +21,13 @@ | ||
21 | #include <chrono> | 21 | #include <chrono> |
22 | #include <dirent.h> | 22 | #include <dirent.h> |
23 | #include <vector> | 23 | #include <vector> |
24 | +#include <string> | ||
24 | 25 | ||
25 | using namespace std; | 26 | using namespace std; |
26 | using namespace cv; | 27 | using namespace cv; |
27 | 28 | ||
28 | 29 | ||
30 | +// static std::vector<std::string> STANDARD_COLOR_TABLE = {"棕", "橙", "灰", "白", "粉", "紫", "红", "绿", "蓝", "银", "青", "黄", "黑", "多色", "其他"}; | ||
31 | + | ||
29 | 32 | ||
30 | #endif | 33 | #endif |
31 | \ No newline at end of file | 34 | \ No newline at end of file |
src/village_inc.h
@@ -17,7 +17,7 @@ typedef struct pendant_info | @@ -17,7 +17,7 @@ typedef struct pendant_info | ||
17 | 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 | 17 | 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 |
18 | float confidence; | 18 | float confidence; |
19 | int driver_copilot_info; | 19 | int driver_copilot_info; |
20 | - int iColor; //13类:"棕", "橙", "灰", "白", "粉", "紫", "红", "绿", "蓝", "银", "青", "黄", "黑" | 20 | + int iColor; // "棕", "橙", "灰", "白", "粉", "紫", "红", "绿", "蓝", "银", "青", "黄", "黑", ,"多色", "其他" |
21 | } pendant_info; | 21 | } pendant_info; |
22 | 22 | ||
23 | typedef struct VehicleInfo { | 23 | typedef struct VehicleInfo { |