Commit 5fc0b8091e2c37bb4440e42e5587ffa6f4a95839
1 parent
86d2e175
完善demo
Showing
1 changed file
with
64 additions
and
18 deletions
src/demo/main.cpp
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | |
7 | 7 | using namespace std; |
8 | 8 | |
9 | -void show_result(std::vector<AnalysisResult> r); | |
9 | +void show_result(std::vector<AnalysisResult> r, vector<string> vec_path); | |
10 | 10 | |
11 | 11 | int main() { |
12 | 12 | |
... | ... | @@ -20,7 +20,7 @@ int main() { |
20 | 20 | string log_path = param.log_path + "/main.log"; |
21 | 21 | |
22 | 22 | set_default_logger(LogLevel(param.log_level), "PicAnalysis", log_path.c_str(), param.log_mem, param.log_days); |
23 | - | |
23 | + | |
24 | 24 | int ret = village_pic_init(&vaHandle, param); |
25 | 25 | |
26 | 26 | // vector<string> vec_path; |
... | ... | @@ -34,12 +34,12 @@ int main() { |
34 | 34 | |
35 | 35 | vector<string> vec_path; |
36 | 36 | { |
37 | - string path = "./img/test_all1.jpg"; | |
37 | + string path = "./img/test_motor4.jpg"; | |
38 | 38 | vec_path.push_back(path); |
39 | 39 | } |
40 | 40 | |
41 | 41 | std::vector<AnalysisResult> result = village_pic_analysis_file(vaHandle, vec_path); |
42 | - show_result(result); | |
42 | + show_result(result, vec_path); | |
43 | 43 | |
44 | 44 | village_pic_release(&vaHandle); |
45 | 45 | |
... | ... | @@ -48,13 +48,17 @@ int main() { |
48 | 48 | |
49 | 49 | static string shot_type[] = {"head", "rear", "motor", "tricycle", "body", "body_nova", "6-行人"}; |
50 | 50 | static string vehicle_type[] = {"person 人", " bike 自行车", "motor 摩托车", "tricycle 三轮车", "car 汽车", "bigbus 大巴", "lorry 货车", "tractor 拖拉机", "midibus 面包/中巴"}; |
51 | -static string plate_status[] = {"全部遮挡", " 无车牌", " 正常车牌", " 部分遮挡"}; | |
51 | +static string plate_status[] = {"无车牌", " 正常车牌", " 遮挡车牌"}; | |
52 | 52 | static string plate_type[] = {"0-单排蓝色 ", "1-单排黄色 ", "2-单排白色 ", "3-单排黑色", " 4-双排黄色 ", "5-双排白色 ", "6-新能源黄绿色 ", "7-新能源白绿色"}; |
53 | 53 | static string human_color[] = {"棕", "橙", "灰", "白", "粉", "紫", "红", "绿", "蓝", "银", "青", "黄", "黑","多色", "其他"}; |
54 | 54 | static string line_cls[] = {"未知", "黄实线", " 白实线", "白虚线", "黄虚线", "车道中线"}; |
55 | 55 | static string seg_cls[] = {"未知","行车道/机动车道", "非机动车道", "应急车道", "导流线", "人行横道", "禁停区域", "十字路口区域", "农村道路"}; |
56 | 56 | |
57 | -void show_result(std::vector<AnalysisResult> result){ | |
57 | +uint8_t seg_colors[][3] = { {0, 0, 0}, {0, 255, 255}, {128, 255, 0}, {255, 128, 0}, {128, 0, 255}, {255, 0, 128}, {0, 128, 255}, {0, 255, 128}, {128, 255, 255}}; | |
58 | + | |
59 | +void show_result(std::vector<AnalysisResult> result, vector<string> vec_path){ | |
60 | + | |
61 | + cv::Mat image = cv::imread(vec_path[0]); | |
58 | 62 | |
59 | 63 | for (size_t i = 0; i < result.size(); i++) |
60 | 64 | { |
... | ... | @@ -64,18 +68,59 @@ void show_result(std::vector<AnalysisResult> result){ |
64 | 68 | auto plate_info = info[j].vehicle_plate_det_recg_res; |
65 | 69 | std::vector<pendant_info> pendant_res = info[j].vehicle_pendant_det_res; |
66 | 70 | |
71 | + cv::Rect rc; | |
72 | + rc.x = info[j].vehicle_body_detect_res.rect.left_; | |
73 | + rc.y = info[j].vehicle_body_detect_res.rect.top_; | |
74 | + rc.width = info[j].vehicle_body_detect_res.rect.width_; | |
75 | + rc.height = info[j].vehicle_body_detect_res.rect.height_; | |
76 | + | |
77 | + const cv::Scalar color(seg_colors[j][0], seg_colors[j][1], seg_colors[j][2]); | |
78 | + cv::rectangle(image, rc, color); | |
79 | + | |
80 | + auto taken_info = info[j].manned_res; | |
81 | + for (size_t k= 0; k < taken_info.hs_count; k++) | |
82 | + { | |
83 | + cv::Rect rc; | |
84 | + rc.x = taken_info.hs_rect[k].rect.left_; | |
85 | + rc.y = taken_info.hs_rect[k].rect.top_; | |
86 | + rc.width = taken_info.hs_rect[k].rect.width_; | |
87 | + rc.height = taken_info.hs_rect[k].rect.height_; | |
88 | + | |
89 | + const cv::Scalar color(255, 255, 255); | |
90 | + cv::rectangle(image, rc, color); | |
91 | + } | |
92 | + | |
93 | + | |
94 | + LOG_INFO("-------------------------------------------{}---------------------------------------------", j); | |
67 | 95 | LOG_INFO("位置特征"); |
68 | 96 | 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 | 97 | LOG_INFO(" 拍摄方向:{}", shot_type[info[j].type]); |
70 | 98 | 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]); | |
99 | + if (info[j].vpt_type > 0) | |
100 | + { | |
101 | + LOG_INFO("车辆特征"); | |
102 | + if (plate_info.stain_vp_result.type >= 0 && plate_info.stain_vp_result.type <= 2) { | |
103 | + LOG_INFO(" 号牌状态:{}", plate_status[plate_info.stain_vp_result.type]); | |
104 | + }else { | |
105 | + LOG_INFO(" 号牌状态:未知"); | |
106 | + } | |
107 | + | |
108 | + LOG_INFO(" 号牌位置:{},{},{},{}", plate_info.rect.left_, plate_info.rect.top_, plate_info.rect.width_, plate_info.rect.height_ ); | |
109 | + if (plate_info.type >= 0) { | |
110 | + LOG_INFO(" 号牌种类:{} {}", plate_type[plate_info.type], plate_info.type); | |
111 | + } else { | |
112 | + LOG_INFO(" 号牌种类:未知", plate_type[plate_info.type], plate_info.type); | |
113 | + } | |
114 | + 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); | |
115 | + LOG_INFO(" 号牌可信度:{}", plate_info.detect_score); | |
116 | + 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); | |
117 | + LOG_INFO(" 车辆类型分类:{}", vehicle_type[info[j].vpt_type]); | |
118 | + } else { | |
119 | + LOG_INFO("行人特征"); | |
120 | + LOG_INFO(" 上衣颜色:{}", human_color[info[j].human_upper_color]); | |
121 | + LOG_INFO(" 下衣颜色:{}", human_color[info[j].human_lower_color]); | |
122 | + } | |
123 | + | |
79 | 124 | if (pendant_res.size() > 0) |
80 | 125 | { |
81 | 126 | LOG_INFO("驾乘人员特征"); |
... | ... | @@ -87,11 +132,9 @@ void show_result(std::vector<AnalysisResult> result){ |
87 | 132 | LOG_INFO(" 衣着颜色:{}", human_color[one_pendant.iColor]); |
88 | 133 | } |
89 | 134 | } |
90 | - LOG_INFO("行人特征"); | |
91 | - LOG_INFO(" 上衣颜色:{}", human_color[info[j].human_upper_color]); | |
92 | - LOG_INFO(" 下衣颜色:{}", human_color[info[j].human_lower_color]); | |
135 | + | |
93 | 136 | LOG_INFO("违法行为特征"); |
94 | - LOG_INFO(" 不戴头盔:{} 置信度:{}", info[j].mta_res.motor_driver_helmeted.status, info[j].mta_res.motor_driver_helmeted.confidence); | |
137 | + LOG_INFO(" 不戴头盔:{} 置信度:{}", info[j].mta_res.motor_driver_helmeted.status, info[j].mta_res.motor_driver_helmeted.confidence); | |
95 | 138 | LOG_INFO(" 违法载人:{}", info[j].motor_manned); |
96 | 139 | LOG_INFO(" 加装雨棚:{} {}", info[j].rainshed, info[j].rainshed_prob); |
97 | 140 | LOG_INFO(" 使用手机:{} {}", info[j].phoning, info[j].phoning_prob); |
... | ... | @@ -127,4 +170,7 @@ void show_result(std::vector<AnalysisResult> result){ |
127 | 170 | LOG_INFO(" 车道点集:{}", str_line); |
128 | 171 | } |
129 | 172 | } |
173 | + | |
174 | + cv::imwrite("./show_result.jpg", image); | |
175 | + image.release(); | |
130 | 176 | } |
131 | 177 | \ No newline at end of file | ... | ... |