From 9e33ae6f8de0c7640ec50d29206c74aeb20fa334 Mon Sep 17 00:00:00 2001 From: Calvin Miao Date: Wed, 17 Oct 2018 19:02:40 -0700 Subject: [PATCH] Perception: fixed misusing of logging --- modules/perception/base/BUILD | 1 + modules/perception/base/blob.h | 2 +- modules/perception/base/syncedmem.h | 2 +- modules/perception/camera/common/util.h | 109 ++++++++---------- .../camera/lib/obstacle/tracker/common/BUILD | 3 +- modules/perception/camera/test/BUILD | 3 +- .../camera/test/camera_common_undistortion.cc | 8 +- ...e_detector_denseline_lane_detector_test.cc | 5 +- .../camera_lib_traffic_light_tracker_test.cc | 3 +- 9 files changed, 58 insertions(+), 78 deletions(-) diff --git a/modules/perception/base/BUILD b/modules/perception/base/BUILD index 56a67997a8..e76ac370c2 100644 --- a/modules/perception/base/BUILD +++ b/modules/perception/base/BUILD @@ -45,6 +45,7 @@ cc_library( "blob.h", ], deps = [ + "//cybertron", ":common", ":syncedmem", ], diff --git a/modules/perception/base/blob.h b/modules/perception/base/blob.h index dc97ecef50..c2487b3ab1 100644 --- a/modules/perception/base/blob.h +++ b/modules/perception/base/blob.h @@ -19,7 +19,7 @@ #include #include -#include "glog/logging.h" +#include "cybertron/common/log.h" #include "modules/perception/base/syncedmem.h" namespace apollo { diff --git a/modules/perception/base/syncedmem.h b/modules/perception/base/syncedmem.h index 7d6d475c5d..a535b2efb5 100644 --- a/modules/perception/base/syncedmem.h +++ b/modules/perception/base/syncedmem.h @@ -18,7 +18,7 @@ #include #include -#include "glog/logging.h" +#include "cybertron/common/log.h" #include "modules/perception/base/common.h" namespace apollo { diff --git a/modules/perception/camera/common/util.h b/modules/perception/camera/common/util.h index 8bf2b1caef..46b70c553d 100644 --- a/modules/perception/camera/common/util.h +++ b/modules/perception/camera/common/util.h @@ -1,26 +1,25 @@ /****************************************************************************** -* Copyright 2018 The Apollo Authors. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*****************************************************************************/ + * Copyright 2018 The Apollo Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *****************************************************************************/ #pragma once -#include +#include #include -#include #include +#include #include -#include #include #include #include @@ -29,7 +28,8 @@ #include #include #include -#include "glog/logging.h" + +#include "cybertron/common/log.h" #include "modules/perception/base/blob.h" #include "modules/perception/base/image.h" #include "modules/perception/base/object.h" @@ -43,16 +43,14 @@ bool Equal(float x, float target, float eps = 1e-6); bool Equal(double x, double target, double eps = 1e-6); // @brief whether rect1 is covered by rect2 -template -bool IsCovered(const base::Rect &rect1, - const base::Rect &rect2, +template +bool IsCovered(const base::Rect &rect1, const base::Rect &rect2, float thresh) { base::RectF inter = rect1 & rect2; return inter.Area() / rect1.Area() > thresh; } -template -bool IsCoveredHorizon(const base::Rect &rect1, - const base::Rect &rect2, +template +bool IsCoveredHorizon(const base::Rect &rect1, const base::Rect &rect2, float thresh) { base::RectF inter = rect1 & rect2; if (inter.Area() > 0) { @@ -60,9 +58,8 @@ bool IsCoveredHorizon(const base::Rect &rect1, } return false; } -template -bool IsCoveredVertical(const base::Rect &rect1, - const base::Rect &rect2, +template +bool IsCoveredVertical(const base::Rect &rect1, const base::Rect &rect2, float thresh) { base::RectF inter = rect1 & rect2; if (inter.Area() > 0) { @@ -71,7 +68,7 @@ bool IsCoveredVertical(const base::Rect &rect1, return false; } -template +template bool Contain(const std::vector &array, const T &element) { for (const auto &item : array) { if (item == element) { @@ -81,33 +78,26 @@ bool Contain(const std::vector &array, const T &element) { return false; } -template -bool OutOfValidRegion(const base::BBox2D box, - const T width, - const T height, +template +bool OutOfValidRegion(const base::BBox2D box, const T width, const T height, const T border_size = 0) { if (box.xmin < border_size || box.ymin < border_size) { return true; } - if (box.xmax + border_size > width || - box.ymax + border_size > height) { + if (box.xmax + border_size > width || box.ymax + border_size > height) { return true; } return false; } -template -bool OutOfValidRegion(const base::Rect rect, - const T width, - const T height, +template +bool OutOfValidRegion(const base::Rect rect, const T width, const T height, const T border_size = 0) { base::BBox2D box(rect); return OutOfValidRegion(box, width, height, border_size); } -template -void RefineBox(const base::Rect &box_in, - const T width, - const T height, +template +void RefineBox(const base::Rect &box_in, const T width, const T height, base::Rect *box_out) { if (!box_out) { return; @@ -129,10 +119,11 @@ void RefineBox(const base::Rect &box_in, box_out->y = 0; box_out->height = 0; } - box_out->width = (box_out->x + box_out->width <= width) ? box_out->width : - width - box_out->x; - box_out->height = (box_out->y + box_out->height <= height) ? box_out->height : - height - box_out->y; + box_out->width = (box_out->x + box_out->width <= width) ? box_out->width + : width - box_out->x; + box_out->height = (box_out->y + box_out->height <= height) + ? box_out->height + : height - box_out->y; if (box_out->width < 0) { box_out->width = 0; } @@ -141,10 +132,8 @@ void RefineBox(const base::Rect &box_in, } } -template -void RefineBox(const base::BBox2D &box_in, - const T width, - const T height, +template +void RefineBox(const base::BBox2D &box_in, const T width, const T height, base::BBox2D *box_out) { if (!box_out) { return; @@ -157,21 +146,18 @@ void RefineBox(const base::BBox2D &box_in, bool LoadAnchors(const std::string &path, std::vector *anchors); bool LoadTypes(const std::string &path, std::vector *types); -bool LoadExpand(const std::string &path, - std::vector *expands); +bool LoadExpand(const std::string &path, std::vector *expands); bool ResizeCPU(const base::Blob &src_gpu, - std::shared_ptr > dst, - int stepwidth, + std::shared_ptr> dst, int stepwidth, int start_axis); - void GetCybertronWorkRoot(std::string *work_root); void FillObjectPolygonFromBBox3D(base::Object *object_ptr); -template -void CalculateMeanAndVariance(const std::vector &data, - T* mean, T* variance) { +template +void CalculateMeanAndVariance(const std::vector &data, T *mean, + T *variance) { if (!mean || !variance) { return; } @@ -184,11 +170,10 @@ void CalculateMeanAndVariance(const std::vector &data, *mean = sum / data.size(); std::vector diff(data.size()); - std::transform(data.begin(), data.end(), diff.begin(), [mean](T x) { - return x - *mean; - }); + std::transform(data.begin(), data.end(), diff.begin(), + [mean](T x) { return x - *mean; }); T sum_of_diff_sqrs = std::inner_product(diff.begin(), diff.end(), - diff.begin(), static_cast(0)); + diff.begin(), static_cast(0)); *variance = sum_of_diff_sqrs / data.size(); } diff --git a/modules/perception/camera/lib/obstacle/tracker/common/BUILD b/modules/perception/camera/lib/obstacle/tracker/common/BUILD index 2a7dcbe4f3..7ce0a5d7e0 100644 --- a/modules/perception/camera/lib/obstacle/tracker/common/BUILD +++ b/modules/perception/camera/lib/obstacle/tracker/common/BUILD @@ -14,8 +14,7 @@ cuda_library( deps = [ "@cuda", "//cybertron", - "//modules/perception/camera/common:common", - "//modules/perception/inference/utils:inference_util_lib", + "//modules/perception/camera/common:camera_frame", "//modules/perception/inference/utils:inference_gemm_lib", ], ) diff --git a/modules/perception/camera/test/BUILD b/modules/perception/camera/test/BUILD index 787c54b4a4..18e5df0ff2 100644 --- a/modules/perception/camera/test/BUILD +++ b/modules/perception/camera/test/BUILD @@ -385,7 +385,7 @@ # "-lopencv_highgui", # ], # deps = [ -# "//external:gflags", +# "//cybertron", # "//modules/perception/camera/lib/lane/detector/denseline:denseline_lane_detector", # "//modules/perception/base:base", # "//modules/perception/common/io:io_util", @@ -712,6 +712,7 @@ # "-lcaffe", # ], # deps = [ +# "//cybertron", # "//modules/perception/base:distortion_model", # "//modules/perception/common/io:io_util", # "//modules/perception/camera/lib/traffic_light/tracker:semantic_decision", diff --git a/modules/perception/camera/test/camera_common_undistortion.cc b/modules/perception/camera/test/camera_common_undistortion.cc index d8bcec3d7f..77088b6046 100644 --- a/modules/perception/camera/test/camera_common_undistortion.cc +++ b/modules/perception/camera/test/camera_common_undistortion.cc @@ -14,19 +14,14 @@ * limitations under the License. *****************************************************************************/ #include "modules/perception/camera/test/camera_common_undistortion.h" -#include -#include +#include #include #include - #include #include - #include -// #include "cybertron/common/log.h" - namespace apollo { namespace perception { namespace camera { @@ -169,7 +164,6 @@ int ImageGpuPreprocessHandler::load_camera_intrinsics( << "File not exists: " << intrinsics_path; YAML::Node node = YAML::LoadFile(intrinsics_path); if (node.IsNull()) { - // AINFO << "Load " << intrinsics_path << " failed! please check!"; return -1; } D->resize(node["D"].size()); diff --git a/modules/perception/camera/test/camera_lib_lane_detector_denseline_lane_detector_test.cc b/modules/perception/camera/test/camera_lib_lane_detector_denseline_lane_detector_test.cc index 28962cdf34..f3db6b41fc 100644 --- a/modules/perception/camera/test/camera_lib_lane_detector_denseline_lane_detector_test.cc +++ b/modules/perception/camera/test/camera_lib_lane_detector_denseline_lane_detector_test.cc @@ -13,13 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ + #include #include #include #include + +#include "cybertron/common/log.h" #include "modules/perception/camera/lib/lane/detector/denseline/denseline_lane_detector.h" -#include "glog/logging.h" -#include "gflags/gflags.h" #include "modules/perception/base/distortion_model.h" #include "modules/perception/common/io/io_util.h" diff --git a/modules/perception/camera/test/camera_lib_traffic_light_tracker_test.cc b/modules/perception/camera/test/camera_lib_traffic_light_tracker_test.cc index 06a057a662..8da620d528 100644 --- a/modules/perception/camera/test/camera_lib_traffic_light_tracker_test.cc +++ b/modules/perception/camera/test/camera_lib_traffic_light_tracker_test.cc @@ -18,9 +18,8 @@ #include #include "gtest/gtest.h" -#include "glog/logging.h" -#include "gflags/gflags.h" +#include "cybertron/common/log.h" #include "modules/perception/base/distortion_model.h" #include "modules/perception/common/io/io_util.h" #include "modules/perception/camera/lib/traffic_light/tracker/semantic_decision.h" -- GitLab