Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
d10836d2
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,发现更多精彩内容 >>
提交
d10836d2
编写于
7月 18, 2019
作者:
H
Hongyi
提交者:
Kecheng Xu
7月 18, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Prediction: add drawing function for lanes and crosswalks
上级
3628a1b4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
85 addition
and
9 deletion
+85
-9
modules/prediction/common/semantic_map.cc
modules/prediction/common/semantic_map.cc
+77
-9
modules/prediction/common/semantic_map.h
modules/prediction/common/semantic_map.h
+8
-0
未找到文件。
modules/prediction/common/semantic_map.cc
浏览文件 @
d10836d2
...
...
@@ -16,6 +16,7 @@
#include "modules/prediction/common/semantic_map.h"
#include <cmath>
#include <string>
#include <vector>
...
...
@@ -98,11 +99,8 @@ void SemanticMap::DrawBaseMap(const double x, const double y) {
common
::
PointENU
center_point
=
common
::
util
::
MakePointENU
(
x
,
y
,
0.0
);
DrawRoads
(
center_point
);
DrawJunctions
(
center_point
);
std
::
vector
<
apollo
::
hdmap
::
CrosswalkInfoConstPtr
>
crosswalks
;
apollo
::
hdmap
::
HDMapUtil
::
BaseMap
().
GetCrosswalks
(
center_point
,
141.4
,
&
crosswalks
);
std
::
vector
<
apollo
::
hdmap
::
LaneInfoConstPtr
>
lanes
;
apollo
::
hdmap
::
HDMapUtil
::
BaseMap
().
GetLanes
(
center_point
,
141.4
,
&
lanes
);
DrawCrosswalks
(
center_point
);
DrawLanes
(
center_point
);
}
void
SemanticMap
::
DrawRoads
(
const
common
::
PointENU
&
center_point
,
...
...
@@ -113,13 +111,13 @@ void SemanticMap::DrawRoads(const common::PointENU& center_point,
for
(
const
auto
&
section
:
road
->
road
().
section
())
{
std
::
vector
<
cv
::
Point
>
polygon
;
for
(
const
auto
&
edge
:
section
.
boundary
().
outer_polygon
().
edge
())
{
if
(
edge
.
type
()
==
2
)
{
if
(
edge
.
type
()
==
2
)
{
// left edge
for
(
const
auto
&
segment
:
edge
.
curve
().
segment
())
{
for
(
const
auto
&
point
:
segment
.
line_segment
().
point
())
{
polygon
.
push_back
(
GetTransPoint
(
point
.
x
(),
point
.
y
()));
}
}
}
else
if
(
edge
.
type
()
==
3
)
{
}
else
if
(
edge
.
type
()
==
3
)
{
// right edge
for
(
const
auto
&
segment
:
edge
.
curve
().
segment
())
{
for
(
const
auto
&
point
:
segment
.
line_segment
().
point
())
{
polygon
.
insert
(
polygon
.
begin
(),
...
...
@@ -141,14 +139,84 @@ void SemanticMap::DrawJunctions(const common::PointENU& center_point,
&
junctions
);
for
(
const
auto
&
junction
:
junctions
)
{
std
::
vector
<
cv
::
Point
>
polygon
;
for
(
auto
&
polygon_point
:
junction
->
junction
().
polygon
().
point
())
{
polygon
.
push_back
(
GetTransPoint
(
polygon_point
.
x
(),
polygon_point
.
y
()));
for
(
const
auto
&
point
:
junction
->
junction
().
polygon
().
point
())
{
polygon
.
push_back
(
GetTransPoint
(
point
.
x
(),
point
.
y
()));
}
cv
::
fillPoly
(
base_img_
,
std
::
vector
<
std
::
vector
<
cv
::
Point
>>
({
polygon
}),
color
);
}
}
void
SemanticMap
::
DrawCrosswalks
(
const
common
::
PointENU
&
center_point
,
const
cv
::
Scalar
&
color
)
{
std
::
vector
<
apollo
::
hdmap
::
CrosswalkInfoConstPtr
>
crosswalks
;
apollo
::
hdmap
::
HDMapUtil
::
BaseMap
().
GetCrosswalks
(
center_point
,
141.4
,
&
crosswalks
);
for
(
const
auto
&
crosswalk
:
crosswalks
)
{
std
::
vector
<
cv
::
Point
>
polygon
;
for
(
const
auto
&
point
:
crosswalk
->
crosswalk
().
polygon
().
point
())
{
polygon
.
push_back
(
GetTransPoint
(
point
.
x
(),
point
.
y
()));
}
cv
::
fillPoly
(
base_img_
,
std
::
vector
<
std
::
vector
<
cv
::
Point
>>
({
polygon
}),
color
);
}
}
void
SemanticMap
::
DrawLanes
(
const
common
::
PointENU
&
center_point
,
const
cv
::
Scalar
&
color
)
{
std
::
vector
<
apollo
::
hdmap
::
LaneInfoConstPtr
>
lanes
;
apollo
::
hdmap
::
HDMapUtil
::
BaseMap
().
GetLanes
(
center_point
,
141.4
,
&
lanes
);
for
(
const
auto
&
lane
:
lanes
)
{
// Draw lane_central first
for
(
const
auto
&
segment
:
lane
->
lane
().
central_curve
().
segment
())
{
for
(
int
i
=
0
;
i
<
segment
.
line_segment
().
point_size
()
-
1
;
++
i
)
{
const
auto
&
p0
=
GetTransPoint
(
segment
.
line_segment
().
point
(
i
).
x
(),
segment
.
line_segment
().
point
(
i
).
y
());
const
auto
&
p1
=
GetTransPoint
(
segment
.
line_segment
().
point
(
i
+
1
).
x
(),
segment
.
line_segment
().
point
(
i
+
1
).
y
());
double
theta
=
atan2
(
segment
.
line_segment
().
point
(
i
+
1
).
y
()
-
segment
.
line_segment
().
point
(
i
).
y
(),
segment
.
line_segment
().
point
(
i
+
1
).
x
()
-
segment
.
line_segment
().
point
(
i
).
x
())
/
(
2
*
M_PI
);
double
H
=
theta
>=
0
?
theta
:
theta
+
1
;
cv
::
line
(
base_img_
,
p0
,
p1
,
HSVtoRGB
(
H
),
4
);
}
}
// Not drawing boundary for virtual city_driving lane
if
(
lane
->
lane
().
type
()
==
2
&&
lane
->
lane
().
left_boundary
().
virtual_
()
&&
lane
->
lane
().
right_boundary
().
virtual_
())
{
continue
;
}
// Draw lane's left_boundary
for
(
const
auto
&
segment
:
lane
->
lane
().
left_boundary
().
curve
().
segment
())
{
for
(
int
i
=
0
;
i
<
segment
.
line_segment
().
point_size
()
-
1
;
++
i
)
{
const
auto
&
p0
=
GetTransPoint
(
segment
.
line_segment
().
point
(
i
).
x
(),
segment
.
line_segment
().
point
(
i
).
y
());
const
auto
&
p1
=
GetTransPoint
(
segment
.
line_segment
().
point
(
i
+
1
).
x
(),
segment
.
line_segment
().
point
(
i
+
1
).
y
());
cv
::
line
(
base_img_
,
p0
,
p1
,
color
,
2
);
}
}
// Draw lane's right_boundary
for
(
const
auto
&
segment
:
lane
->
lane
().
right_boundary
().
curve
().
segment
())
{
for
(
int
i
=
0
;
i
<
segment
.
line_segment
().
point_size
()
-
1
;
++
i
)
{
const
auto
&
p0
=
GetTransPoint
(
segment
.
line_segment
().
point
(
i
).
x
(),
segment
.
line_segment
().
point
(
i
).
y
());
const
auto
&
p1
=
GetTransPoint
(
segment
.
line_segment
().
point
(
i
+
1
).
x
(),
segment
.
line_segment
().
point
(
i
+
1
).
y
());
cv
::
line
(
base_img_
,
p0
,
p1
,
color
,
2
);
}
}
}
}
cv
::
Scalar
SemanticMap
::
HSVtoRGB
(
double
H
,
double
S
,
double
V
)
{
// TODO(Hongyi): implement
return
cv
::
Scalar
(
255
,
255
,
255
);
}
void
SemanticMap
::
DrawRect
(
const
Feature
&
feature
,
const
cv
::
Scalar
&
color
,
cv
::
Mat
*
img
)
{
double
obs_l
=
feature
.
length
();
...
...
modules/prediction/common/semantic_map.h
浏览文件 @
d10836d2
...
...
@@ -52,6 +52,14 @@ class SemanticMap {
void
DrawJunctions
(
const
common
::
PointENU
&
center_point
,
const
cv
::
Scalar
&
color
=
cv
::
Scalar
(
128
,
128
,
128
));
void
DrawCrosswalks
(
const
common
::
PointENU
&
center_point
,
const
cv
::
Scalar
&
color
=
cv
::
Scalar
(
192
,
192
,
192
));
void
DrawLanes
(
const
common
::
PointENU
&
center_point
,
const
cv
::
Scalar
&
color
=
cv
::
Scalar
(
255
,
255
,
255
));
cv
::
Scalar
HSVtoRGB
(
double
H
=
1.0
,
double
S
=
1.0
,
double
V
=
1.0
);
void
DrawRect
(
const
Feature
&
feature
,
const
cv
::
Scalar
&
color
,
cv
::
Mat
*
img
);
void
DrawPoly
(
const
Feature
&
feature
,
const
cv
::
Scalar
&
color
,
cv
::
Mat
*
img
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录