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

Perception : fix compile warning and cleaning

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