diff --git a/src/PicAnalysis.cpp b/src/PicAnalysis.cpp index fac6a9a..2f6b79b 100644 --- a/src/PicAnalysis.cpp +++ b/src/PicAnalysis.cpp @@ -156,7 +156,6 @@ vector PicAnalysis::va_result2AnalysisResult(va_result* result, info.manned_res = result_info.manned_res ; info.type = result_info.type ; info.vpt_type = result_info.vpt_type ; - info.rainshed = result_info.rainshed ; auto pendant_result = result_info.vehicle_pendant_det_res; for (size_t j = 0; j < pendant_result.count; j++) diff --git a/src/ai_engine_module/HumanAnalysis.h b/src/ai_engine_module/HumanAnalysis.h index ee7a996..7746796 100644 --- a/src/ai_engine_module/HumanAnalysis.h +++ b/src/ai_engine_module/HumanAnalysis.h @@ -4,8 +4,8 @@ // static std::string up_color[] = { "黑", "白", "灰", "红", "蓝", "黄", "绿", "多色", "其他" }; struct BodyColorInfo{ - int upper_body_color; - int lower_body_color; + int upper_body_color{14}; + int lower_body_color{14}; }; class HumanAnalysis diff --git a/src/ai_engine_module/HumanCarAnalysis.h b/src/ai_engine_module/HumanCarAnalysis.h index 38034f1..fcadb1f 100644 --- a/src/ai_engine_module/HumanCarAnalysis.h +++ b/src/ai_engine_module/HumanCarAnalysis.h @@ -15,8 +15,8 @@ struct HumanCarResult { float weibo_prob; int up_wear; // 0 – (T恤/背心) , 1 - (衬衫) , 2 - (毛衣) , 3 - (羽绒服) , 4 – (大衣/风衣) , 5 – (外套/夹克/西服) , 6 - (连衣裙) , 7 - (无上衣) , 8 – (其他) float up_wear_prob; - int up_color; // 0 – (黑) , 1 - (白) , 2 - (红) , 3 - (黄) , 4 – (蓝) , 5 – (绿) , 6 – (灰) , 7 – (多色) , 8 – (其他) - float up_color_prob; + int up_color{14}; // 0 – (黑) , 1 - (白) , 2 - (红) , 3 - (黄) , 4 – (蓝) , 5 – (绿) , 6 – (灰) , 7 – (多色) , 8 – (其他) + float up_color_prob{0.0}; int up_tex; // 0 – (纯色) , 1 - (碎花) , 2 - (条纹) , 3 - (格子) , 4 – (其他) float up_tex_prob; int bag; // 0 – (无包) , 1 - (背包) @@ -27,8 +27,8 @@ struct HumanCarResult { float age_prob; int carColor; // 0 – (黑) , 1 - (白) , 2 - (红) , 3 - (黄) , 4 – (蓝) , 5 – (绿) , 6 – (灰/银) , 7 – (多色) , 8 – (其他) float carColor_prob; - int orient; // 0 – (正面) , 1 - (背面) , 2 - (侧面) - float orient_prob; + int orient{0}; // 0 – (正面) , 1 - (背面) , 2 - (侧面) + float orient_prob{0.0}; int dasan; // 0 – (无) , 1 - (有) float dasan_prob; int take; // 0 – (无) , 1 - (有) diff --git a/src/ai_engine_module/MotorPhoneAnalysis.h b/src/ai_engine_module/MotorPhoneAnalysis.h index f2eb306..edcf0f2 100644 --- a/src/ai_engine_module/MotorPhoneAnalysis.h +++ b/src/ai_engine_module/MotorPhoneAnalysis.h @@ -1,8 +1,8 @@ #include "include.h" struct MotorPhoneResult { - int phoning; - float prob; + int phoning{0}; + float prob{0.0}; }; class MotorPhoneAnalysis diff --git a/src/ai_engine_module/MotorRainshedAnalysis.h b/src/ai_engine_module/MotorRainshedAnalysis.h index dec2388..fb7379f 100644 --- a/src/ai_engine_module/MotorRainshedAnalysis.h +++ b/src/ai_engine_module/MotorRainshedAnalysis.h @@ -1,8 +1,8 @@ #include "include.h" struct MotorRainshedResult { - int rainshed; - float prob; + int rainshed{1}; + float prob{0.0}; }; class MotorRainshedAnalysis diff --git a/src/ai_engine_module/RoadSegAnalysis.cpp b/src/ai_engine_module/RoadSegAnalysis.cpp index 91f1ca4..c256085 100644 --- a/src/ai_engine_module/RoadSegAnalysis.cpp +++ b/src/ai_engine_module/RoadSegAnalysis.cpp @@ -80,22 +80,18 @@ std::vector RoadSegAnalysis::detect(vector vec_img){ return vec_road; } -// void test(){ -// cv::Mat image(cv::Size(640, 360), CV_8UC3, cv::Scalar(0, 0, 0)); - -// for (int i = 0; i < poly_masks.size(); ++i) { -// SegInfo seg_info; -// seg_info.seg_type = region_classes[i]; -// seg_info.vec_pt = poly_masks[i]; - -// int k = seg_info.seg_type; -// const cv::Scalar color(seg_colors[k][0], seg_colors[k][1], seg_colors[k][2]); -// polylines(image, seg_info.vec_pt, true, color, 3, cv::LINE_AA); -// } - -// cv::imwrite("./road.jpg", image); -// image.release(); -// } +void test(vector vec_type, std::vector vec_pt, std::string file_name){ + cv::Mat image(cv::Size(640, 360), CV_8UC3, cv::Scalar(0, 0, 0)); + + for (int i = 0; i < vec_type.size(); ++i) { + int k = vec_type[i]; + const cv::Scalar color(seg_colors[k][0], seg_colors[k][1], seg_colors[k][2]); + polylines(image, vec_pt, true, color, 3, cv::LINE_AA); + } + + cv::imwrite(file_name, image); + image.release(); +} RoadInfo RoadSegAnalysis::parse_road(rs_result one_result, sy_img src) { diff --git a/src/ai_engine_module/motor_phone_det.h b/src/ai_engine_module/motor_phone_det.h index 8f9e372..6b80ec7 100755 --- a/src/ai_engine_module/motor_phone_det.h +++ b/src/ai_engine_module/motor_phone_det.h @@ -28,18 +28,18 @@ extern "C" typedef struct motor_phone_info //结果结构体 { - int left; - int top; - int right; - int bottom; + int left{0}; + int top{0}; + int right{0}; + int bottom{0}; int index; - double confidence; // 置信度 + double confidence{0.0}; // 置信度 }motor_phone_info; typedef struct motor_phone_result { motor_phone_info objinfo[MAX_OBJ_COUNT]; - int objcount; + int objcount{0}; }; typedef struct motor_phone_param diff --git a/src/demo/main.cpp b/src/demo/main.cpp index 468749e..ad57214 100644 --- a/src/demo/main.cpp +++ b/src/demo/main.cpp @@ -1,9 +1,13 @@ #include "../village_pic_interface.h" #include #include +#include +#include "../utils/logger.hpp" using namespace std; +void show_result(std::vector r); + int main() { void *vaHandle = NULL; @@ -12,20 +16,115 @@ int main() { param.dev_id = 0; param.sdk_path = "."; param.log_level = 1; + + string log_path = param.log_path + "/main.log"; + + set_default_logger(LogLevel(param.log_level), "PicAnalysis", log_path.c_str(), param.log_mem, param.log_days); + int ret = village_pic_init(&vaHandle, param); + // vector vec_path; + // size_t i = 0; + // // for (i = 1; i < 8; i++) + // { + // string path = "./img/test_road"; + // path = path + to_string(i) + ".jpg"; + // vec_path.push_back(path); + // } + vector vec_path; - size_t i = 3; - // for (i = 1; i < 8; i++) { - string path = "./img/test_phone"; - path = path + to_string(i) + ".jpg"; + string path = "./img/test_all1.jpg"; vec_path.push_back(path); } - village_pic_analysis_file(vaHandle, vec_path); + std::vector result = village_pic_analysis_file(vaHandle, vec_path); + show_result(result); village_pic_release(&vaHandle); return 0; +} + +static string shot_type[] = {"head", "rear", "motor", "tricycle", "body", "body_nova", "6-行人"}; +static string vehicle_type[] = {"person 人", " bike 自行车", "motor 摩托车", "tricycle 三轮车", "car 汽车", "bigbus 大巴", "lorry 货车", "tractor 拖拉机", "midibus 面包/中巴"}; +static string plate_status[] = {"全部遮挡", " 无车牌", " 正常车牌", " 部分遮挡"}; +static string plate_type[] = {"0-单排蓝色 ", "1-单排黄色 ", "2-单排白色 ", "3-单排黑色", " 4-双排黄色 ", "5-双排白色 ", "6-新能源黄绿色 ", "7-新能源白绿色"}; +static string human_color[] = {"棕", "橙", "灰", "白", "粉", "紫", "红", "绿", "蓝", "银", "青", "黄", "黑","多色", "其他"}; +static string line_cls[] = {"未知", "黄实线", " 白实线", "白虚线", "黄虚线", "车道中线"}; +static string seg_cls[] = {"未知","行车道/机动车道", "非机动车道", "应急车道", "导流线", "人行横道", "禁停区域", "十字路口区域", "农村道路"}; + +void show_result(std::vector result){ + + for (size_t i = 0; i < result.size(); i++) + { + std::vector info = result[i].info; + for (size_t j = 0; j < info.size(); j++) + { + auto plate_info = info[j].vehicle_plate_det_recg_res; + std::vector pendant_res = info[j].vehicle_pendant_det_res; + + LOG_INFO("位置特征"); + 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_); + LOG_INFO(" 拍摄方向:{}", shot_type[info[j].type]); + LOG_INFO("目标类型:{}", vehicle_type[info[j].vpt_type]); + LOG_INFO("车辆特征"); + LOG_INFO(" 号牌状态:{}", plate_status[plate_info.stain_vp_result.type]); + LOG_INFO(" 号牌位置:{},{},{},{}", plate_info.rect.left_, plate_info.rect.top_, plate_info.rect.width_, plate_info.rect.height_ ); + LOG_INFO(" 号牌种类:{}", plate_type[plate_info.type]); + 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); + LOG_INFO(" 号牌可信度:{}", plate_info.detect_score); + 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); + LOG_INFO(" 车辆类型分类:{}", vehicle_type[info[j].vpt_type]); + if (pendant_res.size() > 0) + { + LOG_INFO("驾乘人员特征"); + for (size_t k = 0; k < pendant_res.size(); k++) + { + auto one_pendant = pendant_res[k]; + LOG_INFO(" 位置信息:{},{},{},{}", one_pendant.rect.left_, one_pendant.rect.top_, one_pendant.rect.width_, one_pendant.rect.height_ ); + LOG_INFO(" 可信度:{}", one_pendant.confidence); + LOG_INFO(" 衣着颜色:{}", human_color[one_pendant.iColor]); + } + } + LOG_INFO("行人特征"); + LOG_INFO(" 上衣颜色:{}", human_color[info[j].human_upper_color]); + LOG_INFO(" 下衣颜色:{}", human_color[info[j].human_lower_color]); + LOG_INFO("违法行为特征"); + LOG_INFO(" 不戴头盔:{} 置信度:{}", info[j].mta_res.motor_driver_helmeted.status, info[j].mta_res.motor_driver_helmeted.confidence); + LOG_INFO(" 违法载人:{}", info[j].motor_manned); + LOG_INFO(" 加装雨棚:{} {}", info[j].rainshed, info[j].rainshed_prob); + LOG_INFO(" 使用手机:{} {}", info[j].phoning, info[j].phoning_prob); + LOG_INFO(" 逆行:{}", info[j].reverse_driving); + LOG_INFO(" 货厢载人:{}", info[j].truck_manned); + LOG_INFO(" 违反禁止标线 压实线:{} 压导流线:{}", info[j].cross_line, info[j].cross_diversion_line); + } + + LOG_INFO("标线信息"); + std::vector vec_line = result[i].vec_line; + for (size_t i = 0; i < vec_line.size(); i++) + { + LineInfo one_line = vec_line[i]; + LOG_INFO(" 标线类型:{}", line_cls[one_line.line_type]); + string str_line = ""; + for (size_t j = 0; j < one_line.vec_pt.size(); j++) + { + str_line += to_string(one_line.vec_pt[j].x)+","+to_string(one_line.vec_pt[j].y) + "_"; + } + LOG_INFO(" 标线点集:{}", str_line); + } + + std::vector vec_road = result[i].vec_road; + for (size_t i = 0; i < vec_road.size(); i++) + { + SegInfo one_seg = vec_road[i]; + LOG_INFO(" 车道类型:{}", seg_cls[one_seg.seg_type]); + string str_line = ""; + for (size_t j = 0; j < one_seg.vec_pt.size(); j++) + { + str_line += to_string(one_seg.vec_pt[j].x)+","+to_string(one_seg.vec_pt[j].y) + "_"; + } + LOG_INFO(" 车道点集:{}", str_line); + } + } } \ No newline at end of file diff --git a/src/village_inc.h b/src/village_inc.h index 113c63e..20b1098 100644 --- a/src/village_inc.h +++ b/src/village_inc.h @@ -49,33 +49,33 @@ typedef struct VehicleInfo { manned_result manned_res; - int type; + int type{-1}; - int vpt_type; // person 人;bike 自行车 ; motor 摩托车;tricycle 三轮车;car 汽车; bigbus 大巴;lorry 货车;tractor 拖拉机;midibus 面包/中巴 - int rainshed; //是否安装雨棚, 0 有雨棚 1 无雨棚 - float rainshed_prob; + int vpt_type{0}; // person 人;bike 自行车 ; motor 摩托车;tricycle 三轮车;car 汽车; bigbus 大巴;lorry 货车;tractor 拖拉机;midibus 面包/中巴 + int rainshed{1}; //是否安装雨棚, 0 有雨棚 1 无雨棚 + float rainshed_prob{0.0}; int truck_manned{0}; int motor_manned{0}; - int human_upper_color; - int human_lower_color; + int human_upper_color{14}; + int human_lower_color{14}; - int reverse_driving; // 0 正常行驶 1 逆行 -1 未知 - int phoning; // 骑车打电话 1 为是,其他为否 - float phoning_prob; + int reverse_driving{-1}; // 0 正常行驶 1 逆行 -1 未知 + int phoning{0}; // 骑车打电话 1 为是,其他为否 + float phoning_prob{0.0}; - int cross_line; // 压实线, 1 黄实线 2 白实线 -1 其他 - int cross_diversion_line; // 压导流线 1 压了 -1 未压 + int cross_line{-1}; // 压实线 1 黄实线 2 白实线 -1 其他 + int cross_diversion_line{-1}; // 压导流线 1 压了 -1 未压 } VehicleInfo; struct LineInfo{ - int line_type; + int line_type{0}; // {"未知", "黄实线", " 白实线", "白虚线", "黄虚线", "车道中线"}; std::vector vec_pt; }; struct SegInfo { - int seg_type; + int seg_type{0}; // {"未知","行车道/机动车道", "非机动车道", "应急车道", "导流线", "人行横道", "禁停区域", "十字路口区域", "农村道路"}; std::vector vec_pt; };