提交 b7dcb39c 编写于 作者: D Dong Li 提交者: Jiangtao Hu

perception: fix lint problems in cuda_util

上级 3dc12c8c
...@@ -17,13 +17,10 @@ genrule( ...@@ -17,13 +17,10 @@ genrule(
"CMakeLists.txt", "CMakeLists.txt",
"block_uf.cu", "block_uf.cu",
"connected_component_gpu.cu", "connected_component_gpu.cu",
"network.cc",
"network.cu", "network.cu",
"region_output.cc", "region_output.cc",
"region_output.cu", "region_output.cu",
"undistortion.cc",
"undistortion.cu", "undistortion.cu",
"util.cc",
"util.cu", "util.cu",
], ],
outs = ["build/libcuda_util.so"], outs = ["build/libcuda_util.so"],
......
...@@ -14,17 +14,20 @@ ...@@ -14,17 +14,20 @@
* limitations under the License. * limitations under the License.
*****************************************************************************/ *****************************************************************************/
#include "region_output.h" #include "modules/perception/cuda_util/region_output.h"
#include <algorithm>
#include <map> #include <map>
#include <vector> #include <vector>
#include <opencv2/opencv.hpp>
#include "boost/iterator/counting_iterator.hpp" #include "boost/iterator/counting_iterator.hpp"
#include "opencv2/opencv.hpp"
namespace apollo { namespace apollo {
namespace perception { namespace perception {
void get_intersect_bbox(const NormalizedBBox &bbox1, const NormalizedBBox &bbox2, void get_intersect_bbox(const NormalizedBBox &bbox1,
const NormalizedBBox &bbox2,
NormalizedBBox *intersect_bbox) { NormalizedBBox *intersect_bbox) {
if (bbox2.xmin > bbox1.xmax || bbox2.xmax < bbox1.xmin || if (bbox2.xmin > bbox1.xmax || bbox2.xmax < bbox1.xmin ||
bbox2.ymin > bbox1.ymax || bbox2.ymax < bbox1.ymin) { bbox2.ymin > bbox1.ymax || bbox2.ymax < bbox1.ymin) {
...@@ -52,12 +55,12 @@ float get_bbox_size(const NormalizedBBox &bbox) { ...@@ -52,12 +55,12 @@ float get_bbox_size(const NormalizedBBox &bbox) {
float width = bbox.xmax - bbox.xmin; float width = bbox.xmax - bbox.xmin;
float height = bbox.ymax - bbox.ymin; float height = bbox.ymax - bbox.ymin;
return width * height; return width * height;
} }
} }
} }
float get_jaccard_overlap(const NormalizedBBox &bbox1, const NormalizedBBox &bbox2) { float get_jaccard_overlap(const NormalizedBBox &bbox1,
const NormalizedBBox &bbox2) {
NormalizedBBox intersect_bbox; NormalizedBBox intersect_bbox;
get_intersect_bbox(bbox1, bbox2, &intersect_bbox); get_intersect_bbox(bbox1, bbox2, &intersect_bbox);
float intersect_width = 0.f; float intersect_width = 0.f;
...@@ -75,8 +78,9 @@ float get_jaccard_overlap(const NormalizedBBox &bbox1, const NormalizedBBox &bbo ...@@ -75,8 +78,9 @@ float get_jaccard_overlap(const NormalizedBBox &bbox1, const NormalizedBBox &bbo
} }
} }
void get_max_score_index(const std::vector<float> &scores, const float threshold, void get_max_score_index(const std::vector<float> &scores,
const int top_k, std::vector<std::pair<float, int> > *score_index_vec) { const float threshold, const int top_k,
std::vector<std::pair<float, int> > *score_index_vec) {
// Generate index score pairs. // Generate index score pairs.
for (int i = 0; i < static_cast<int>(scores.size()); ++i) { for (int i = 0; i < static_cast<int>(scores.size()); ++i) {
if (scores[i] > threshold) { if (scores[i] > threshold) {
...@@ -94,8 +98,9 @@ void get_max_score_index(const std::vector<float> &scores, const float threshold ...@@ -94,8 +98,9 @@ void get_max_score_index(const std::vector<float> &scores, const float threshold
} }
} }
void apply_nms_fast(const std::vector<NormalizedBBox> &bboxes, void apply_nms_fast(const std::vector<NormalizedBBox> &bboxes,
const std::vector<float> &scores, const float score_threshold, const std::vector<float> &scores,
const float nms_threshold, const float eta, const int top_k, const float score_threshold, const float nms_threshold,
const float eta, const int top_k,
std::vector<int> *indices) { std::vector<int> *indices) {
// Sanity check. // Sanity check.
CHECK_EQ(bboxes.size(), scores.size()) CHECK_EQ(bboxes.size(), scores.size())
...@@ -130,9 +135,9 @@ void apply_nms_fast(const std::vector<NormalizedBBox> &bboxes, ...@@ -130,9 +135,9 @@ void apply_nms_fast(const std::vector<NormalizedBBox> &bboxes,
} }
} }
void cross_class_merge(std::vector<int> *indices_ref, std::vector<int> *indices_target, void cross_class_merge(std::vector<int> *indices_ref,
std::vector<int> *indices_target,
std::vector<NormalizedBBox> bboxes, float scale) { std::vector<NormalizedBBox> bboxes, float scale) {
for (int i = 0; i < static_cast<int>(indices_ref->size()); i++) { for (int i = 0; i < static_cast<int>(indices_ref->size()); i++) {
int ref_idx = indices_ref->at(i); int ref_idx = indices_ref->at(i);
NormalizedBBox &bbox_ref = bboxes[ref_idx]; NormalizedBBox &bbox_ref = bboxes[ref_idx];
...@@ -145,7 +150,8 @@ void cross_class_merge(std::vector<int> *indices_ref, std::vector<int> *indices_ ...@@ -145,7 +150,8 @@ void cross_class_merge(std::vector<int> *indices_ref, std::vector<int> *indices_
intersection.size = get_bbox_size(intersection); intersection.size = get_bbox_size(intersection);
bbox_target.size = get_bbox_size(bbox_target); bbox_target.size = get_bbox_size(bbox_target);
bbox_ref.size = get_bbox_size(bbox_ref); bbox_ref.size = get_bbox_size(bbox_ref);
if (intersection.size > bbox_target.size * scale && bbox_target.ymax <= bbox_ref.ymax) { if (intersection.size > bbox_target.size * scale &&
bbox_target.ymax <= bbox_ref.ymax) {
it = indices_target->erase(it); it = indices_target->erase(it);
} else { } else {
it++; it++;
...@@ -154,5 +160,5 @@ void cross_class_merge(std::vector<int> *indices_ref, std::vector<int> *indices_ ...@@ -154,5 +160,5 @@ void cross_class_merge(std::vector<int> *indices_ref, std::vector<int> *indices_
} }
} }
} //namespace apollo } // namespace perception
} //namespace perception } // namespace apollo
/******************************************************************************
* Copyright 2017 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.
*****************************************************************************/
#include "util.h"
namespace apollo {
namespace perception {
} // namespace perception
} // namespace apollo
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册