Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
b7dcb39c
A
apollo
项目概览
Pinoxchio
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
b7dcb39c
编写于
4月 10, 2018
作者:
D
Dong Li
提交者:
Jiangtao Hu
4月 10, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perception: fix lint problems in cuda_util
上级
3dc12c8c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
117 addition
and
138 deletion
+117
-138
modules/perception/cuda_util/BUILD
modules/perception/cuda_util/BUILD
+0
-3
modules/perception/cuda_util/network.cc
modules/perception/cuda_util/network.cc
+0
-0
modules/perception/cuda_util/region_output.cc
modules/perception/cuda_util/region_output.cc
+117
-111
modules/perception/cuda_util/undistortion.cc
modules/perception/cuda_util/undistortion.cc
+0
-0
modules/perception/cuda_util/util.cc
modules/perception/cuda_util/util.cc
+0
-24
未找到文件。
modules/perception/cuda_util/BUILD
浏览文件 @
b7dcb39c
...
...
@@ -17,13 +17,10 @@ genrule(
"CMakeLists.txt"
,
"block_uf.cu"
,
"connected_component_gpu.cu"
,
"network.cc"
,
"network.cu"
,
"region_output.cc"
,
"region_output.cu"
,
"undistortion.cc"
,
"undistortion.cu"
,
"util.cc"
,
"util.cu"
,
],
outs
=
[
"build/libcuda_util.so"
],
...
...
modules/perception/cuda_util/network.cc
已删除
100644 → 0
浏览文件 @
3dc12c8c
modules/perception/cuda_util/region_output.cc
浏览文件 @
b7dcb39c
...
...
@@ -14,145 +14,151 @@
* limitations under the License.
*****************************************************************************/
#include "region_output.h"
#include "
modules/perception/cuda_util/
region_output.h"
#include <algorithm>
#include <map>
#include <vector>
#include <opencv2/opencv.hpp>
#include "boost/iterator/counting_iterator.hpp"
#include "opencv2/opencv.hpp"
namespace
apollo
{
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
)
{
if
(
bbox2
.
xmin
>
bbox1
.
xmax
||
bbox2
.
xmax
<
bbox1
.
xmin
||
bbox2
.
ymin
>
bbox1
.
ymax
||
bbox2
.
ymax
<
bbox1
.
ymin
)
{
// Return [0, 0, 0, 0] if there is no intersection.
intersect_bbox
->
xmin
=
0
;
intersect_bbox
->
ymin
=
0
;
intersect_bbox
->
xmax
=
0
;
intersect_bbox
->
ymax
=
0
;
}
else
{
intersect_bbox
->
xmin
=
std
::
max
(
bbox1
.
xmin
,
bbox2
.
xmin
);
intersect_bbox
->
ymin
=
std
::
max
(
bbox1
.
ymin
,
bbox2
.
ymin
);
intersect_bbox
->
xmax
=
std
::
min
(
bbox1
.
xmax
,
bbox2
.
xmax
);
intersect_bbox
->
ymax
=
std
::
min
(
bbox1
.
ymax
,
bbox2
.
ymax
);
}
if
(
bbox2
.
xmin
>
bbox1
.
xmax
||
bbox2
.
xmax
<
bbox1
.
xmin
||
bbox2
.
ymin
>
bbox1
.
ymax
||
bbox2
.
ymax
<
bbox1
.
ymin
)
{
// Return [0, 0, 0, 0] if there is no intersection.
intersect_bbox
->
xmin
=
0
;
intersect_bbox
->
ymin
=
0
;
intersect_bbox
->
xmax
=
0
;
intersect_bbox
->
ymax
=
0
;
}
else
{
intersect_bbox
->
xmin
=
std
::
max
(
bbox1
.
xmin
,
bbox2
.
xmin
);
intersect_bbox
->
ymin
=
std
::
max
(
bbox1
.
ymin
,
bbox2
.
ymin
);
intersect_bbox
->
xmax
=
std
::
min
(
bbox1
.
xmax
,
bbox2
.
xmax
);
intersect_bbox
->
ymax
=
std
::
min
(
bbox1
.
ymax
,
bbox2
.
ymax
);
}
}
float
get_bbox_size
(
const
NormalizedBBox
&
bbox
)
{
if
(
bbox
.
xmax
<
bbox
.
xmin
||
bbox
.
ymax
<
bbox
.
ymin
)
{
// If bbox is invalid (e.g. xmax < xmin or ymax < ymin), return 0.
return
0
;
if
(
bbox
.
xmax
<
bbox
.
xmin
||
bbox
.
ymax
<
bbox
.
ymin
)
{
// If bbox is invalid (e.g. xmax < xmin or ymax < ymin), return 0.
return
0
;
}
else
{
if
(
bbox
.
size
>=
0
)
{
return
bbox
.
size
;
}
else
{
if
(
bbox
.
size
>=
0
)
{
return
bbox
.
size
;
}
else
{
float
width
=
bbox
.
xmax
-
bbox
.
xmin
;
float
height
=
bbox
.
ymax
-
bbox
.
ymin
;
return
width
*
height
;
}
float
width
=
bbox
.
xmax
-
bbox
.
xmin
;
float
height
=
bbox
.
ymax
-
bbox
.
ymin
;
return
width
*
height
;
}
}
}
float
get_jaccard_overlap
(
const
NormalizedBBox
&
bbox1
,
const
NormalizedBBox
&
bbox2
)
{
NormalizedBBox
intersect_bbox
;
get_intersect_bbox
(
bbox1
,
bbox2
,
&
intersect_bbox
);
float
intersect_width
=
0.
f
;
float
intersect_height
=
0.
f
;
intersect_width
=
intersect_bbox
.
xmax
-
intersect_bbox
.
xmin
;
intersect_height
=
intersect_bbox
.
ymax
-
intersect_bbox
.
ymin
;
if
(
intersect_width
>
0
&&
intersect_height
>
0
)
{
float
intersect_size
=
intersect_width
*
intersect_height
;
float
bbox1_size
=
get_bbox_size
(
bbox1
);
float
bbox2_size
=
get_bbox_size
(
bbox2
);
return
intersect_size
/
(
bbox1_size
+
bbox2_size
-
intersect_size
);
}
else
{
return
0.
;
}
float
get_jaccard_overlap
(
const
NormalizedBBox
&
bbox1
,
const
NormalizedBBox
&
bbox2
)
{
NormalizedBBox
intersect_bbox
;
get_intersect_bbox
(
bbox1
,
bbox2
,
&
intersect_bbox
);
float
intersect_width
=
0.
f
;
float
intersect_height
=
0.
f
;
intersect_width
=
intersect_bbox
.
xmax
-
intersect_bbox
.
xmin
;
intersect_height
=
intersect_bbox
.
ymax
-
intersect_bbox
.
ymin
;
if
(
intersect_width
>
0
&&
intersect_height
>
0
)
{
float
intersect_size
=
intersect_width
*
intersect_height
;
float
bbox1_size
=
get_bbox_size
(
bbox1
);
float
bbox2_size
=
get_bbox_size
(
bbox2
);
return
intersect_size
/
(
bbox1_size
+
bbox2_size
-
intersect_size
);
}
else
{
return
0.
;
}
}
void
get_max_score_index
(
const
std
::
vector
<
float
>
&
scores
,
const
float
threshold
,
const
int
top_k
,
std
::
vector
<
std
::
pair
<
float
,
int
>
>
*
score_index_vec
)
{
// Generate index score pairs.
for
(
int
i
=
0
;
i
<
static_cast
<
int
>
(
scores
.
size
());
++
i
)
{
if
(
scores
[
i
]
>
threshold
)
{
score_index_vec
->
push_back
(
std
::
make_pair
(
scores
[
i
],
i
));
}
void
get_max_score_index
(
const
std
::
vector
<
float
>
&
scores
,
const
float
threshold
,
const
int
top_k
,
std
::
vector
<
std
::
pair
<
float
,
int
>
>
*
score_index_vec
)
{
// Generate index score pairs.
for
(
int
i
=
0
;
i
<
static_cast
<
int
>
(
scores
.
size
());
++
i
)
{
if
(
scores
[
i
]
>
threshold
)
{
score_index_vec
->
push_back
(
std
::
make_pair
(
scores
[
i
],
i
));
}
}
// Sort the score pair according to the scores in descending order
std
::
stable_sort
(
score_index_vec
->
begin
(),
score_index_vec
->
end
(),
sort_score_pair_descend
<
int
>
);
// Sort the score pair according to the scores in descending order
std
::
stable_sort
(
score_index_vec
->
begin
(),
score_index_vec
->
end
(),
sort_score_pair_descend
<
int
>
);
// Keep top_k scores if needed.
if
(
top_k
>
-
1
&&
top_k
<
static_cast
<
int
>
(
score_index_vec
->
size
()))
{
score_index_vec
->
resize
(
top_k
);
}
// Keep top_k scores if needed.
if
(
top_k
>
-
1
&&
top_k
<
static_cast
<
int
>
(
score_index_vec
->
size
()))
{
score_index_vec
->
resize
(
top_k
);
}
}
void
apply_nms_fast
(
const
std
::
vector
<
NormalizedBBox
>
&
bboxes
,
const
std
::
vector
<
float
>
&
scores
,
const
float
score_threshold
,
const
float
nms_threshold
,
const
float
eta
,
const
int
top_k
,
const
std
::
vector
<
float
>
&
scores
,
const
float
score_threshold
,
const
float
nms_threshold
,
const
float
eta
,
const
int
top_k
,
std
::
vector
<
int
>
*
indices
)
{
// Sanity check.
CHECK_EQ
(
bboxes
.
size
(),
scores
.
size
())
<<
"bboxes and scores have different size."
;
// Get top_k scores (with corresponding indices).
std
::
vector
<
std
::
pair
<
float
,
int
>
>
score_index_vec
;
get_max_score_index
(
scores
,
score_threshold
,
top_k
,
&
score_index_vec
);
// Do nms.
float
adaptive_threshold
=
nms_threshold
;
indices
->
clear
();
while
(
score_index_vec
.
size
()
!=
0
)
{
const
int
idx
=
score_index_vec
.
front
().
second
;
bool
keep
=
true
;
for
(
int
k
=
0
;
k
<
static_cast
<
int
>
(
indices
->
size
());
++
k
)
{
if
(
keep
)
{
const
int
kept_idx
=
(
*
indices
)[
k
];
float
overlap
=
get_jaccard_overlap
(
bboxes
[
idx
],
bboxes
[
kept_idx
]);
keep
=
overlap
<=
adaptive_threshold
;
}
else
{
break
;
}
}
if
(
keep
)
{
indices
->
push_back
(
idx
);
}
score_index_vec
.
erase
(
score_index_vec
.
begin
());
if
(
keep
&&
eta
<
1
&&
adaptive_threshold
>
0.5
)
{
adaptive_threshold
*=
eta
;
}
// Sanity check.
CHECK_EQ
(
bboxes
.
size
(),
scores
.
size
())
<<
"bboxes and scores have different size."
;
// Get top_k scores (with corresponding indices).
std
::
vector
<
std
::
pair
<
float
,
int
>
>
score_index_vec
;
get_max_score_index
(
scores
,
score_threshold
,
top_k
,
&
score_index_vec
);
// Do nms.
float
adaptive_threshold
=
nms_threshold
;
indices
->
clear
();
while
(
score_index_vec
.
size
()
!=
0
)
{
const
int
idx
=
score_index_vec
.
front
().
second
;
bool
keep
=
true
;
for
(
int
k
=
0
;
k
<
static_cast
<
int
>
(
indices
->
size
());
++
k
)
{
if
(
keep
)
{
const
int
kept_idx
=
(
*
indices
)[
k
];
float
overlap
=
get_jaccard_overlap
(
bboxes
[
idx
],
bboxes
[
kept_idx
]);
keep
=
overlap
<=
adaptive_threshold
;
}
else
{
break
;
}
}
if
(
keep
)
{
indices
->
push_back
(
idx
);
}
score_index_vec
.
erase
(
score_index_vec
.
begin
());
if
(
keep
&&
eta
<
1
&&
adaptive_threshold
>
0.5
)
{
adaptive_threshold
*=
eta
;
}
}
}
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
)
{
for
(
int
i
=
0
;
i
<
static_cast
<
int
>
(
indices_ref
->
size
());
i
++
)
{
int
ref_idx
=
indices_ref
->
at
(
i
);
NormalizedBBox
&
bbox_ref
=
bboxes
[
ref_idx
];
for
(
std
::
vector
<
int
>::
iterator
it
=
indices_target
->
begin
();
it
!=
indices_target
->
end
();)
{
int
target_idx
=
*
it
;
NormalizedBBox
&
bbox_target
=
bboxes
[
target_idx
];
NormalizedBBox
intersection
;
get_intersect_bbox
(
bbox_ref
,
bbox_target
,
&
intersection
);
intersection
.
size
=
get_bbox_size
(
intersection
);
bbox_target
.
size
=
get_bbox_size
(
bbox_target
);
bbox_ref
.
size
=
get_bbox_size
(
bbox_ref
);
if
(
intersection
.
size
>
bbox_target
.
size
*
scale
&&
bbox_target
.
ymax
<=
bbox_ref
.
ymax
)
{
it
=
indices_target
->
erase
(
it
);
}
else
{
it
++
;
}
}
for
(
int
i
=
0
;
i
<
static_cast
<
int
>
(
indices_ref
->
size
());
i
++
)
{
int
ref_idx
=
indices_ref
->
at
(
i
);
NormalizedBBox
&
bbox_ref
=
bboxes
[
ref_idx
];
for
(
std
::
vector
<
int
>::
iterator
it
=
indices_target
->
begin
();
it
!=
indices_target
->
end
();)
{
int
target_idx
=
*
it
;
NormalizedBBox
&
bbox_target
=
bboxes
[
target_idx
];
NormalizedBBox
intersection
;
get_intersect_bbox
(
bbox_ref
,
bbox_target
,
&
intersection
);
intersection
.
size
=
get_bbox_size
(
intersection
);
bbox_target
.
size
=
get_bbox_size
(
bbox_target
);
bbox_ref
.
size
=
get_bbox_size
(
bbox_ref
);
if
(
intersection
.
size
>
bbox_target
.
size
*
scale
&&
bbox_target
.
ymax
<=
bbox_ref
.
ymax
)
{
it
=
indices_target
->
erase
(
it
);
}
else
{
it
++
;
}
}
}
}
}
//namespace apollo
}
//namespace perception
}
// namespace perception
}
// namespace apollo
modules/perception/cuda_util/undistortion.cc
已删除
100644 → 0
浏览文件 @
3dc12c8c
modules/perception/cuda_util/util.cc
已删除
100644 → 0
浏览文件 @
3dc12c8c
/******************************************************************************
* 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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录