Commit b1547dfc0a6ad372a3e873595b088011a532c854
1 parent
5f46b9cf
设置初始值,避免异常值影响
Showing
9 changed files
with
145 additions
and
51 deletions
src/PicAnalysis.cpp
... | ... | @@ -156,7 +156,6 @@ vector<AnalysisResult> PicAnalysis::va_result2AnalysisResult(va_result* result, |
156 | 156 | info.manned_res = result_info.manned_res ; |
157 | 157 | info.type = result_info.type ; |
158 | 158 | info.vpt_type = result_info.vpt_type ; |
159 | - info.rainshed = result_info.rainshed ; | |
160 | 159 | |
161 | 160 | auto pendant_result = result_info.vehicle_pendant_det_res; |
162 | 161 | for (size_t j = 0; j < pendant_result.count; j++) | ... | ... |
src/ai_engine_module/HumanAnalysis.h
... | ... | @@ -4,8 +4,8 @@ |
4 | 4 | |
5 | 5 | // static std::string up_color[] = { "黑", "白", "灰", "红", "蓝", "黄", "绿", "多色", "其他" }; |
6 | 6 | struct BodyColorInfo{ |
7 | - int upper_body_color; | |
8 | - int lower_body_color; | |
7 | + int upper_body_color{14}; | |
8 | + int lower_body_color{14}; | |
9 | 9 | }; |
10 | 10 | |
11 | 11 | class HumanAnalysis | ... | ... |
src/ai_engine_module/HumanCarAnalysis.h
... | ... | @@ -15,8 +15,8 @@ struct HumanCarResult { |
15 | 15 | float weibo_prob; |
16 | 16 | int up_wear; // 0 – (T恤/背心) , 1 - (衬衫) , 2 - (毛衣) , 3 - (羽绒服) , 4 – (大衣/风衣) , 5 – (外套/夹克/西服) , 6 - (连衣裙) , 7 - (无上衣) , 8 – (其他) |
17 | 17 | float up_wear_prob; |
18 | - int up_color; // 0 – (黑) , 1 - (白) , 2 - (红) , 3 - (黄) , 4 – (蓝) , 5 – (绿) , 6 – (灰) , 7 – (多色) , 8 – (其他) | |
19 | - float up_color_prob; | |
18 | + int up_color{14}; // 0 – (黑) , 1 - (白) , 2 - (红) , 3 - (黄) , 4 – (蓝) , 5 – (绿) , 6 – (灰) , 7 – (多色) , 8 – (其他) | |
19 | + float up_color_prob{0.0}; | |
20 | 20 | int up_tex; // 0 – (纯色) , 1 - (碎花) , 2 - (条纹) , 3 - (格子) , 4 – (其他) |
21 | 21 | float up_tex_prob; |
22 | 22 | int bag; // 0 – (无包) , 1 - (背包) |
... | ... | @@ -27,8 +27,8 @@ struct HumanCarResult { |
27 | 27 | float age_prob; |
28 | 28 | int carColor; // 0 – (黑) , 1 - (白) , 2 - (红) , 3 - (黄) , 4 – (蓝) , 5 – (绿) , 6 – (灰/银) , 7 – (多色) , 8 – (其他) |
29 | 29 | float carColor_prob; |
30 | - int orient; // 0 – (正面) , 1 - (背面) , 2 - (侧面) | |
31 | - float orient_prob; | |
30 | + int orient{0}; // 0 – (正面) , 1 - (背面) , 2 - (侧面) | |
31 | + float orient_prob{0.0}; | |
32 | 32 | int dasan; // 0 – (无) , 1 - (有) |
33 | 33 | float dasan_prob; |
34 | 34 | int take; // 0 – (无) , 1 - (有) | ... | ... |
src/ai_engine_module/MotorPhoneAnalysis.h
src/ai_engine_module/MotorRainshedAnalysis.h
src/ai_engine_module/RoadSegAnalysis.cpp
... | ... | @@ -80,22 +80,18 @@ std::vector<RoadInfo> RoadSegAnalysis::detect(vector<sy_img> vec_img){ |
80 | 80 | return vec_road; |
81 | 81 | } |
82 | 82 | |
83 | -// void test(){ | |
84 | -// cv::Mat image(cv::Size(640, 360), CV_8UC3, cv::Scalar(0, 0, 0)); | |
85 | - | |
86 | -// for (int i = 0; i < poly_masks.size(); ++i) { | |
87 | -// SegInfo seg_info; | |
88 | -// seg_info.seg_type = region_classes[i]; | |
89 | -// seg_info.vec_pt = poly_masks[i]; | |
90 | - | |
91 | -// int k = seg_info.seg_type; | |
92 | -// const cv::Scalar color(seg_colors[k][0], seg_colors[k][1], seg_colors[k][2]); | |
93 | -// polylines(image, seg_info.vec_pt, true, color, 3, cv::LINE_AA); | |
94 | -// } | |
95 | - | |
96 | -// cv::imwrite("./road.jpg", image); | |
97 | -// image.release(); | |
98 | -// } | |
83 | +void test(vector<int> vec_type, std::vector<cv::Point> vec_pt, std::string file_name){ | |
84 | + cv::Mat image(cv::Size(640, 360), CV_8UC3, cv::Scalar(0, 0, 0)); | |
85 | + | |
86 | + for (int i = 0; i < vec_type.size(); ++i) { | |
87 | + int k = vec_type[i]; | |
88 | + const cv::Scalar color(seg_colors[k][0], seg_colors[k][1], seg_colors[k][2]); | |
89 | + polylines(image, vec_pt, true, color, 3, cv::LINE_AA); | |
90 | + } | |
91 | + | |
92 | + cv::imwrite(file_name, image); | |
93 | + image.release(); | |
94 | +} | |
99 | 95 | |
100 | 96 | RoadInfo RoadSegAnalysis::parse_road(rs_result one_result, sy_img src) |
101 | 97 | { | ... | ... |
src/ai_engine_module/motor_phone_det.h
... | ... | @@ -28,18 +28,18 @@ extern "C" |
28 | 28 | |
29 | 29 | typedef struct motor_phone_info //结果结构体 |
30 | 30 | { |
31 | - int left; | |
32 | - int top; | |
33 | - int right; | |
34 | - int bottom; | |
31 | + int left{0}; | |
32 | + int top{0}; | |
33 | + int right{0}; | |
34 | + int bottom{0}; | |
35 | 35 | int index; |
36 | - double confidence; // 置信度 | |
36 | + double confidence{0.0}; // 置信度 | |
37 | 37 | }motor_phone_info; |
38 | 38 | |
39 | 39 | typedef struct motor_phone_result |
40 | 40 | { |
41 | 41 | motor_phone_info objinfo[MAX_OBJ_COUNT]; |
42 | - int objcount; | |
42 | + int objcount{0}; | |
43 | 43 | }; |
44 | 44 | |
45 | 45 | typedef struct motor_phone_param | ... | ... |
src/demo/main.cpp
1 | 1 | #include "../village_pic_interface.h" |
2 | 2 | #include <vector> |
3 | 3 | #include <string> |
4 | +#include <iostream> | |
5 | +#include "../utils/logger.hpp" | |
4 | 6 | |
5 | 7 | using namespace std; |
6 | 8 | |
9 | +void show_result(std::vector<AnalysisResult> r); | |
10 | + | |
7 | 11 | int main() { |
8 | 12 | |
9 | 13 | void *vaHandle = NULL; |
... | ... | @@ -12,20 +16,115 @@ int main() { |
12 | 16 | param.dev_id = 0; |
13 | 17 | param.sdk_path = "."; |
14 | 18 | param.log_level = 1; |
19 | + | |
20 | + string log_path = param.log_path + "/main.log"; | |
21 | + | |
22 | + set_default_logger(LogLevel(param.log_level), "PicAnalysis", log_path.c_str(), param.log_mem, param.log_days); | |
23 | + | |
15 | 24 | int ret = village_pic_init(&vaHandle, param); |
16 | 25 | |
26 | + // vector<string> vec_path; | |
27 | + // size_t i = 0; | |
28 | + // // for (i = 1; i < 8; i++) | |
29 | + // { | |
30 | + // string path = "./img/test_road"; | |
31 | + // path = path + to_string(i) + ".jpg"; | |
32 | + // vec_path.push_back(path); | |
33 | + // } | |
34 | + | |
17 | 35 | vector<string> vec_path; |
18 | - size_t i = 3; | |
19 | - // for (i = 1; i < 8; i++) | |
20 | 36 | { |
21 | - string path = "./img/test_phone"; | |
22 | - path = path + to_string(i) + ".jpg"; | |
37 | + string path = "./img/test_all1.jpg"; | |
23 | 38 | vec_path.push_back(path); |
24 | 39 | } |
25 | 40 | |
26 | - village_pic_analysis_file(vaHandle, vec_path); | |
41 | + std::vector<AnalysisResult> result = village_pic_analysis_file(vaHandle, vec_path); | |
42 | + show_result(result); | |
27 | 43 | |
28 | 44 | village_pic_release(&vaHandle); |
29 | 45 | |
30 | 46 | return 0; |
47 | +} | |
48 | + | |
49 | +static string shot_type[] = {"head", "rear", "motor", "tricycle", "body", "body_nova", "6-行人"}; | |
50 | +static string vehicle_type[] = {"person 人", " bike 自行车", "motor 摩托车", "tricycle 三轮车", "car 汽车", "bigbus 大巴", "lorry 货车", "tractor 拖拉机", "midibus 面包/中巴"}; | |
51 | +static string plate_status[] = {"全部遮挡", " 无车牌", " 正常车牌", " 部分遮挡"}; | |
52 | +static string plate_type[] = {"0-单排蓝色 ", "1-单排黄色 ", "2-单排白色 ", "3-单排黑色", " 4-双排黄色 ", "5-双排白色 ", "6-新能源黄绿色 ", "7-新能源白绿色"}; | |
53 | +static string human_color[] = {"棕", "橙", "灰", "白", "粉", "紫", "红", "绿", "蓝", "银", "青", "黄", "黑","多色", "其他"}; | |
54 | +static string line_cls[] = {"未知", "黄实线", " 白实线", "白虚线", "黄虚线", "车道中线"}; | |
55 | +static string seg_cls[] = {"未知","行车道/机动车道", "非机动车道", "应急车道", "导流线", "人行横道", "禁停区域", "十字路口区域", "农村道路"}; | |
56 | + | |
57 | +void show_result(std::vector<AnalysisResult> result){ | |
58 | + | |
59 | + for (size_t i = 0; i < result.size(); i++) | |
60 | + { | |
61 | + std::vector<VehicleInfo> info = result[i].info; | |
62 | + for (size_t j = 0; j < info.size(); j++) | |
63 | + { | |
64 | + auto plate_info = info[j].vehicle_plate_det_recg_res; | |
65 | + std::vector<pendant_info> pendant_res = info[j].vehicle_pendant_det_res; | |
66 | + | |
67 | + LOG_INFO("位置特征"); | |
68 | + LOG_INFO(" 车辆位置:{},{},{},{}", info[j].vehicle_body_detect_res.rect.left_ ,info[j].vehicle_body_detect_res.rect.top_, info[j].vehicle_body_detect_res.rect.width_, info[j].vehicle_body_detect_res.rect.height_); | |
69 | + LOG_INFO(" 拍摄方向:{}", shot_type[info[j].type]); | |
70 | + LOG_INFO("目标类型:{}", vehicle_type[info[j].vpt_type]); | |
71 | + LOG_INFO("车辆特征"); | |
72 | + LOG_INFO(" 号牌状态:{}", plate_status[plate_info.stain_vp_result.type]); | |
73 | + LOG_INFO(" 号牌位置:{},{},{},{}", plate_info.rect.left_, plate_info.rect.top_, plate_info.rect.width_, plate_info.rect.height_ ); | |
74 | + LOG_INFO(" 号牌种类:{}", plate_type[plate_info.type]); | |
75 | + LOG_INFO(" 号牌号码:{}{}{}{}{}{}{}{}", plate_info.recg[0].character, plate_info.recg[1].character, plate_info.recg[2].character, plate_info.recg[3].character, plate_info.recg[4].character, plate_info.recg[5].character, plate_info.recg[6].character, plate_info.recg[7].character); | |
76 | + LOG_INFO(" 号牌可信度:{}", plate_info.detect_score); | |
77 | + LOG_INFO(" 每位号牌可信度:{}:{} {}:{} {}:{} {}:{} {}:{} {}:{} {}:{} {}:{}", plate_info.recg[0].character, plate_info.recg[0].maxprob, plate_info.recg[1].character, plate_info.recg[1].maxprob, plate_info.recg[2].character, plate_info.recg[2].maxprob, plate_info.recg[3].character, plate_info.recg[3].maxprob, plate_info.recg[4].character, plate_info.recg[4].maxprob, plate_info.recg[5].character, plate_info.recg[5].maxprob, plate_info.recg[6].character, plate_info.recg[6].maxprob, plate_info.recg[7].character, plate_info.recg[7].maxprob); | |
78 | + LOG_INFO(" 车辆类型分类:{}", vehicle_type[info[j].vpt_type]); | |
79 | + if (pendant_res.size() > 0) | |
80 | + { | |
81 | + LOG_INFO("驾乘人员特征"); | |
82 | + for (size_t k = 0; k < pendant_res.size(); k++) | |
83 | + { | |
84 | + auto one_pendant = pendant_res[k]; | |
85 | + LOG_INFO(" 位置信息:{},{},{},{}", one_pendant.rect.left_, one_pendant.rect.top_, one_pendant.rect.width_, one_pendant.rect.height_ ); | |
86 | + LOG_INFO(" 可信度:{}", one_pendant.confidence); | |
87 | + LOG_INFO(" 衣着颜色:{}", human_color[one_pendant.iColor]); | |
88 | + } | |
89 | + } | |
90 | + LOG_INFO("行人特征"); | |
91 | + LOG_INFO(" 上衣颜色:{}", human_color[info[j].human_upper_color]); | |
92 | + LOG_INFO(" 下衣颜色:{}", human_color[info[j].human_lower_color]); | |
93 | + LOG_INFO("违法行为特征"); | |
94 | + LOG_INFO(" 不戴头盔:{} 置信度:{}", info[j].mta_res.motor_driver_helmeted.status, info[j].mta_res.motor_driver_helmeted.confidence); | |
95 | + LOG_INFO(" 违法载人:{}", info[j].motor_manned); | |
96 | + LOG_INFO(" 加装雨棚:{} {}", info[j].rainshed, info[j].rainshed_prob); | |
97 | + LOG_INFO(" 使用手机:{} {}", info[j].phoning, info[j].phoning_prob); | |
98 | + LOG_INFO(" 逆行:{}", info[j].reverse_driving); | |
99 | + LOG_INFO(" 货厢载人:{}", info[j].truck_manned); | |
100 | + LOG_INFO(" 违反禁止标线 压实线:{} 压导流线:{}", info[j].cross_line, info[j].cross_diversion_line); | |
101 | + } | |
102 | + | |
103 | + LOG_INFO("标线信息"); | |
104 | + std::vector<LineInfo> vec_line = result[i].vec_line; | |
105 | + for (size_t i = 0; i < vec_line.size(); i++) | |
106 | + { | |
107 | + LineInfo one_line = vec_line[i]; | |
108 | + LOG_INFO(" 标线类型:{}", line_cls[one_line.line_type]); | |
109 | + string str_line = ""; | |
110 | + for (size_t j = 0; j < one_line.vec_pt.size(); j++) | |
111 | + { | |
112 | + str_line += to_string(one_line.vec_pt[j].x)+","+to_string(one_line.vec_pt[j].y) + "_"; | |
113 | + } | |
114 | + LOG_INFO(" 标线点集:{}", str_line); | |
115 | + } | |
116 | + | |
117 | + std::vector<SegInfo> vec_road = result[i].vec_road; | |
118 | + for (size_t i = 0; i < vec_road.size(); i++) | |
119 | + { | |
120 | + SegInfo one_seg = vec_road[i]; | |
121 | + LOG_INFO(" 车道类型:{}", seg_cls[one_seg.seg_type]); | |
122 | + string str_line = ""; | |
123 | + for (size_t j = 0; j < one_seg.vec_pt.size(); j++) | |
124 | + { | |
125 | + str_line += to_string(one_seg.vec_pt[j].x)+","+to_string(one_seg.vec_pt[j].y) + "_"; | |
126 | + } | |
127 | + LOG_INFO(" 车道点集:{}", str_line); | |
128 | + } | |
129 | + } | |
31 | 130 | } |
32 | 131 | \ No newline at end of file | ... | ... |
src/village_inc.h
... | ... | @@ -49,33 +49,33 @@ typedef struct VehicleInfo { |
49 | 49 | |
50 | 50 | manned_result manned_res; |
51 | 51 | |
52 | - int type; | |
52 | + int type{-1}; | |
53 | 53 | |
54 | - int vpt_type; // person 人;bike 自行车 ; motor 摩托车;tricycle 三轮车;car 汽车; bigbus 大巴;lorry 货车;tractor 拖拉机;midibus 面包/中巴 | |
55 | - int rainshed; //是否安装雨棚, 0 有雨棚 1 无雨棚 | |
56 | - float rainshed_prob; | |
54 | + int vpt_type{0}; // person 人;bike 自行车 ; motor 摩托车;tricycle 三轮车;car 汽车; bigbus 大巴;lorry 货车;tractor 拖拉机;midibus 面包/中巴 | |
55 | + int rainshed{1}; //是否安装雨棚, 0 有雨棚 1 无雨棚 | |
56 | + float rainshed_prob{0.0}; | |
57 | 57 | int truck_manned{0}; |
58 | 58 | int motor_manned{0}; |
59 | 59 | |
60 | - int human_upper_color; | |
61 | - int human_lower_color; | |
60 | + int human_upper_color{14}; | |
61 | + int human_lower_color{14}; | |
62 | 62 | |
63 | - int reverse_driving; // 0 正常行驶 1 逆行 -1 未知 | |
64 | - int phoning; // 骑车打电话 1 为是,其他为否 | |
65 | - float phoning_prob; | |
63 | + int reverse_driving{-1}; // 0 正常行驶 1 逆行 -1 未知 | |
64 | + int phoning{0}; // 骑车打电话 1 为是,其他为否 | |
65 | + float phoning_prob{0.0}; | |
66 | 66 | |
67 | - int cross_line; // 压实线, 1 黄实线 2 白实线 -1 其他 | |
68 | - int cross_diversion_line; // 压导流线 1 压了 -1 未压 | |
67 | + int cross_line{-1}; // 压实线 1 黄实线 2 白实线 -1 其他 | |
68 | + int cross_diversion_line{-1}; // 压导流线 1 压了 -1 未压 | |
69 | 69 | |
70 | 70 | } VehicleInfo; |
71 | 71 | |
72 | 72 | struct LineInfo{ |
73 | - int line_type; | |
73 | + int line_type{0}; // {"未知", "黄实线", " 白实线", "白虚线", "黄虚线", "车道中线"}; | |
74 | 74 | std::vector<cv::Point> vec_pt; |
75 | 75 | }; |
76 | 76 | |
77 | 77 | struct SegInfo { |
78 | - int seg_type; | |
78 | + int seg_type{0}; // {"未知","行车道/机动车道", "非机动车道", "应急车道", "导流线", "人行横道", "禁停区域", "十字路口区域", "农村道路"}; | |
79 | 79 | std::vector<cv::Point> vec_pt; |
80 | 80 | }; |
81 | 81 | ... | ... |