提交 a54e3a76 编写于 作者: L luoqi06 提交者: Dong Li

Perception : fix compile warning and cleaning

上级 fba674f1
...@@ -54,9 +54,8 @@ std::vector<cv::Scalar> color_table = { ...@@ -54,9 +54,8 @@ std::vector<cv::Scalar> color_table = {
cv::Scalar(255, 255, 255), cv::Scalar(255, 255, 255),
}; };
bool load_visual_object_form_file( bool LoadVisualObjectFromFile(const std::string &file_name,
const std::string &file_name, std::vector<VisualObjectPtr> *visual_objects) {
std::vector<VisualObjectPtr> *visual_objects) {
FILE *fp = fopen(file_name.c_str(), "r"); FILE *fp = fopen(file_name.c_str(), "r");
if (!fp) { if (!fp) {
std::cout << "load file: " << file_name << " error!" << std::endl; std::cout << "load file: " << file_name << " error!" << std::endl;
...@@ -78,7 +77,7 @@ bool load_visual_object_form_file( ...@@ -78,7 +77,7 @@ bool load_visual_object_form_file(
double y2 = 0.0; double y2 = 0.0;
int ret = fscanf(fp, int ret = fscanf(fp,
"%s %lf %lf %f %lf %lf %lf %lf %f %f %f %f %f %f %f %f " "%s %lf %lf %f %lf %lf %lf %lf %f %f %f %f %f %f %f %f "
"%lf %lf", "%f %f",
type, &trash, &trash, &obj->alpha, &x1, &y1, &x2, &y2, type, &trash, &trash, &obj->alpha, &x1, &y1, &x2, &y2,
&obj->height, &obj->width, &obj->length, &obj->center.x(), &obj->height, &obj->width, &obj->length, &obj->center.x(),
&obj->center.y(), &obj->center.z(), &obj->theta, &obj->center.y(), &obj->center.z(), &obj->theta,
...@@ -87,7 +86,7 @@ bool load_visual_object_form_file( ...@@ -87,7 +86,7 @@ bool load_visual_object_form_file(
obj->upper_left[1] = y1 > 0 ? y1 : 0; obj->upper_left[1] = y1 > 0 ? y1 : 0;
obj->lower_right[0] = x2 < 1920 ? x2 : 1920; obj->lower_right[0] = x2 < 1920 ? x2 : 1920;
obj->lower_right[1] = y2 < 1080 ? y2 : 1080; obj->lower_right[1] = y2 < 1080 ? y2 : 1080;
obj->type = get_object_type(std::string(type)); obj->type = GetObjectType(std::string(type));
obj->type_probs[static_cast<int>(obj->type)] = obj->type_probs[static_cast<int>(obj->type)] =
static_cast<float>(obj->score); static_cast<float>(obj->score);
...@@ -99,8 +98,8 @@ bool load_visual_object_form_file( ...@@ -99,8 +98,8 @@ bool load_visual_object_form_file(
return true; return true;
} }
bool write_visual_object_to_file(const std::string &file_name, bool WriteVisualObjectToFile(const std::string &file_name,
std::vector<VisualObjectPtr> *visual_objects) { std::vector<VisualObjectPtr> *visual_objects) {
FILE *fp = fopen(file_name.c_str(), "w"); FILE *fp = fopen(file_name.c_str(), "w");
if (!fp) { if (!fp) {
std::cout << "write file: " << file_name << " error!" << std::endl; std::cout << "write file: " << file_name << " error!" << std::endl;
...@@ -108,7 +107,7 @@ bool write_visual_object_to_file(const std::string &file_name, ...@@ -108,7 +107,7 @@ bool write_visual_object_to_file(const std::string &file_name,
} }
for (auto &obj : *visual_objects) { for (auto &obj : *visual_objects) {
std::string type = get_type_text(obj->type); std::string type = GetTypeText(obj->type);
fprintf(fp, fprintf(fp,
"%s %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f " "%s %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f "
...@@ -123,8 +122,8 @@ bool write_visual_object_to_file(const std::string &file_name, ...@@ -123,8 +122,8 @@ bool write_visual_object_to_file(const std::string &file_name,
return true; return true;
} }
bool load_gt_form_file(const std::string &gt_path, bool LoadGTfromFile(const std::string &gt_path,
std::vector<VisualObjectPtr> *visual_objects) { std::vector<VisualObjectPtr> *visual_objects) {
std::ifstream gt_file(gt_path); std::ifstream gt_file(gt_path);
std::string line; std::string line;
...@@ -145,7 +144,7 @@ bool load_gt_form_file(const std::string &gt_path, ...@@ -145,7 +144,7 @@ bool load_gt_form_file(const std::string &gt_path,
// theta // theta
// position? // position?
obj->type = get_object_type(tokens[0]); obj->type = GetObjectType(tokens[0]);
// obj->alpha = std::stod(tokens[3]); // obj->alpha = std::stod(tokens[3]);
obj->alpha = std::stod(tokens[14]); obj->alpha = std::stod(tokens[14]);
...@@ -188,8 +187,8 @@ bool load_gt_form_file(const std::string &gt_path, ...@@ -188,8 +187,8 @@ bool load_gt_form_file(const std::string &gt_path,
return true; return true;
} }
void draw_visual_objects(const std::vector<VisualObjectPtr> &visual_objects, void DrawVisualObejcts(const std::vector<VisualObjectPtr> &visual_objects,
cv::Mat *img) { cv::Mat *img) {
for (const auto &obj : visual_objects) { for (const auto &obj : visual_objects) {
// 3D BBox // 3D BBox
#if 0 #if 0
...@@ -260,8 +259,8 @@ void draw_visual_objects(const std::vector<VisualObjectPtr> &visual_objects, ...@@ -260,8 +259,8 @@ void draw_visual_objects(const std::vector<VisualObjectPtr> &visual_objects,
} }
} }
void draw_gt_objects_text(const std::vector<VisualObjectPtr> &visual_objects, void DrawGTObjectsText(const std::vector<VisualObjectPtr> &visual_objects,
cv::Mat *img) { cv::Mat *img) {
for (const auto &obj : visual_objects) { for (const auto &obj : visual_objects) {
// 2D BBox // 2D BBox
int x1 = static_cast<int>(obj->upper_left[0]); int x1 = static_cast<int>(obj->upper_left[0]);
...@@ -288,7 +287,7 @@ void draw_gt_objects_text(const std::vector<VisualObjectPtr> &visual_objects, ...@@ -288,7 +287,7 @@ void draw_gt_objects_text(const std::vector<VisualObjectPtr> &visual_objects,
} }
} }
std::string get_type_text(ObjectType type) { std::string GetTypeText(ObjectType type) {
if (type == ObjectType::VEHICLE) { if (type == ObjectType::VEHICLE) {
return "car"; return "car";
} }
...@@ -302,7 +301,7 @@ std::string get_type_text(ObjectType type) { ...@@ -302,7 +301,7 @@ std::string get_type_text(ObjectType type) {
return "unknown"; return "unknown";
} }
ObjectType get_object_type(const std::string &type) { ObjectType GetObjectType(const std::string &type) {
std::string temp_type = type; std::string temp_type = type;
std::transform(temp_type.begin(), temp_type.end(), temp_type.begin(), std::transform(temp_type.begin(), temp_type.end(), temp_type.begin(),
(int (*)(int))std::tolower); (int (*)(int))std::tolower);
...@@ -343,8 +342,8 @@ ObjectType get_object_type(const std::string &type) { ...@@ -343,8 +342,8 @@ ObjectType get_object_type(const std::string &type) {
} }
} }
bool load_text_proto_message_file(const std::string& path, bool LoadTextProtoMessageFile(const std::string &path,
google::protobuf::Message* msg) { google::protobuf::Message *msg) {
if (msg == nullptr) { if (msg == nullptr) {
AERROR << "msg is a null pointer."; AERROR << "msg is a null pointer.";
return false; return false;
......
...@@ -86,20 +86,20 @@ inline void l2norm(float *feat_data, int feat_dim) { ...@@ -86,20 +86,20 @@ inline void l2norm(float *feat_data, int feat_dim) {
} }
} }
bool load_visual_object_form_file(const std::string &file_name, bool LoadVisualObjectFromFile(const std::string &file_name,
std::vector<VisualObjectPtr> *visual_objects); std::vector<VisualObjectPtr> *visual_objects);
bool write_visual_object_to_file(const std::string &file_name, bool WriteVisualObjectToFile(const std::string &file_name,
std::vector<VisualObjectPtr> *visual_objects); std::vector<VisualObjectPtr> *visual_objects);
bool load_gt_form_file(const std::string &gt_path, bool LoadGTfromFile(const std::string &gt_path,
std::vector<VisualObjectPtr> *visual_objects); std::vector<VisualObjectPtr> *visual_objects);
std::string get_type_text(ObjectType type); std::string GetTypeText(ObjectType type);
ObjectType get_object_type(const std::string &type_text); ObjectType GetObjectType(const std::string &type_text);
bool load_text_proto_message_file(const std::string& path, bool LoadTextProtoMessageFile(const std::string& path,
google::protobuf::Message* msg); google::protobuf::Message* msg);
} // namespace perception } // namespace perception
......
...@@ -52,7 +52,7 @@ bool YoloCameraDetector::Init(const CameraDetectorInitOptions &options) { ...@@ -52,7 +52,7 @@ bool YoloCameraDetector::Init(const CameraDetectorInitOptions &options) {
string yolo_config = string yolo_config =
apollo::common::util::GetAbsolutePath(yolo_root, "config.pt"); apollo::common::util::GetAbsolutePath(yolo_root, "config.pt");
load_text_proto_message_file(yolo_config, &yolo_param_); LoadTextProtoMessageFile(yolo_config, &yolo_param_);
load_intrinsic(options); load_intrinsic(options);
if (!init_cnn(yolo_root)) { if (!init_cnn(yolo_root)) {
return false; return false;
...@@ -186,7 +186,7 @@ bool YoloCameraDetector::init_cnn(const string &yolo_root) { ...@@ -186,7 +186,7 @@ bool YoloCameraDetector::init_cnn(const string &yolo_root) {
output_names.push_back(net_param.seg_blob()); output_names.push_back(net_param.seg_blob());
FeatureParam feat_param; FeatureParam feat_param;
load_text_proto_message_file(feature_file, &feat_param); LoadTextProtoMessageFile(feature_file, &feat_param);
for (auto extractor : feat_param.extractor()) { for (auto extractor : feat_param.extractor()) {
output_names.push_back(extractor.feat_blob()); output_names.push_back(extractor.feat_blob());
} }
......
...@@ -247,7 +247,7 @@ TEST(YoloCameraDetectorTest, input_tensor_test) { ...@@ -247,7 +247,7 @@ TEST(YoloCameraDetectorTest, input_tensor_test) {
adu::perception::yolo::YoloParam yolo_param; adu::perception::yolo::YoloParam yolo_param;
adu::perception::yolo::YoloParam origin_yolo_param; adu::perception::yolo::YoloParam origin_yolo_param;
load_text_proto_message_file(yolo_config, yolo_param); LoadTextProtoMessageFile(yolo_config, yolo_param);
origin_yolo_param.CopyFrom(yolo_param); origin_yolo_param.CopyFrom(yolo_param);
{ {
......
...@@ -40,9 +40,9 @@ TEST(YoloCameraTensorRTDetectorTest, yolo_camera_detector_test) { ...@@ -40,9 +40,9 @@ TEST(YoloCameraTensorRTDetectorTest, yolo_camera_detector_test) {
adu::perception::yolo::YoloParam origin_yolo_param; adu::perception::yolo::YoloParam origin_yolo_param;
int origin_gpu_flag = FLAGS_camera_detector_gpu; int origin_gpu_flag = FLAGS_camera_detector_gpu;
load_text_proto_message_file(yolo_test_config, yolo_param); LoadTextProtoMessageFile(yolo_test_config, yolo_param);
// roipooling feature extractor // roipooling feature extractor
load_text_proto_message_file(yolo_config, origin_yolo_param); LoadTextProtoMessageFile(yolo_config, origin_yolo_param);
{ {
yolo_param.mutable_model_param()->set_model_type(yolo::ModelType::TensorRT); yolo_param.mutable_model_param()->set_model_type(yolo::ModelType::TensorRT);
yolo_param.mutable_model_param()->set_proto_file("tensorrt.pt"); yolo_param.mutable_model_param()->set_proto_file("tensorrt.pt");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册