Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
67f2e074
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,发现更多精彩内容 >>
提交
67f2e074
编写于
10月 31, 2018
作者:
Y
Yajia Zhang
提交者:
Jiangtao Hu
12月 13, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
prediction: added bounding rectangle class in mlp_train
上级
e4e05b32
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
130 addition
and
0 deletion
+130
-0
modules/tools/prediction/mlp_train/common/bounding_rectangle.py
...s/tools/prediction/mlp_train/common/bounding_rectangle.py
+70
-0
modules/tools/prediction/mlp_train/common/rotation2d.py
modules/tools/prediction/mlp_train/common/rotation2d.py
+14
-0
modules/tools/prediction/mlp_train/common/util.py
modules/tools/prediction/mlp_train/common/util.py
+22
-0
modules/tools/prediction/mlp_train/common/vector2d.py
modules/tools/prediction/mlp_train/common/vector2d.py
+24
-0
未找到文件。
modules/tools/prediction/mlp_train/common/bounding_rectangle.py
0 → 100644
浏览文件 @
67f2e074
from
vector2d
import
Vector2
from
rotation2d
import
*
from
util
import
segment_overlap
class
BoundingRectangle
:
def
__init__
(
self
,
x
,
y
,
theta
,
length
,
width
):
self
.
vertices
=
[
None
]
*
4
dx
=
0.5
*
length
dy
=
0.5
*
width
cos_theta
=
cos
(
theta
)
sin_theta
=
sin
(
theta
)
self
.
vertices
[
0
]
=
rotate_fast
(
Vector2
(
dx
,
-
dy
),
cos_theta
,
sin_theta
)
self
.
vertices
[
1
]
=
rotate_fast
(
Vector2
(
dx
,
dy
),
cos_theta
,
sin_theta
)
self
.
vertices
[
2
]
=
rotate_fast
(
Vector2
(
-
dx
,
dy
),
cos_theta
,
sin_theta
)
self
.
vertices
[
3
]
=
rotate_fast
(
Vector2
(
-
dx
,
-
dy
),
cos_theta
,
sin_theta
)
for
i
in
range
(
4
):
self
.
vertices
[
i
].
x
+=
x
self
.
vertices
[
i
].
y
+=
y
def
overlap
(
self
,
rect
):
for
i
in
range
(
4
):
v0
=
self
.
vertices
[
i
]
v1
=
self
.
vertices
[(
i
+
1
)
%
4
]
range_self
=
self
.
project
(
v0
,
v1
)
range_other
=
rect
.
project
(
v0
,
v1
)
if
segment_overlap
(
range_self
[
0
],
range_self
[
1
],
range_other
[
0
],
range_other
[
1
])
==
False
:
return
False
for
i
in
range
(
4
):
v0
=
rect
.
vertices
[
i
]
v1
=
rect
.
vertices
[(
i
+
1
)
%
4
]
range_self
=
self
.
project
(
v0
,
v1
)
range_other
=
rect
.
project
(
v0
,
v1
)
if
segment_overlap
(
range_self
[
0
],
range_self
[
1
],
range_other
[
0
],
range_other
[
1
])
==
False
:
return
False
return
True
def
project
(
self
,
p0
,
p1
):
v
=
p1
.
subtract
(
p0
)
n
=
v
.
norm
()
rmin
=
float
(
"inf"
)
rmax
=
float
(
"-inf"
)
for
i
in
range
(
4
):
t
=
self
.
vertices
[
i
].
subtract
(
p0
)
r
=
t
.
dot
(
v
)
/
n
if
r
<
rmin
:
rmin
=
r
if
r
>
rmax
:
rmax
=
r
return
[
rmin
,
rmax
]
def
print_vertices
(
self
):
for
i
in
range
(
4
):
print
(
str
(
self
.
vertices
[
i
].
x
)
+
"
\t
"
+
str
(
self
.
vertices
[
i
].
y
)
+
"
\n
"
)
modules/tools/prediction/mlp_train/common/rotation2d.py
0 → 100644
浏览文件 @
67f2e074
from
math
import
cos
,
sin
from
vector2d
import
Vector2
def
rotate
(
v
,
theta
):
cos_theta
=
cos
(
theta
)
sin_theta
=
sin
(
theta
)
return
rotate_fast
(
v
,
cos_theta
,
sin_theta
)
def
rotate_fast
(
v
,
cos_theta
,
sin_theta
):
x
=
cos_theta
*
v
.
x
-
sin_theta
*
v
.
y
y
=
sin_theta
*
v
.
x
+
cos_theta
*
v
.
y
return
Vector2
(
x
,
y
)
modules/tools/prediction/mlp_train/common/util.py
0 → 100644
浏览文件 @
67f2e074
def
segment_overlap
(
a
,
b
,
x
,
y
):
if
b
<
x
or
a
>
y
:
return
False
return
True
def
vector_projection_overlap
(
p0
,
p1
,
p2
,
p3
):
v
=
p1
.
subtract
(
p0
)
n_square
=
v
.
norm_square
()
v0
=
p2
.
subtract
(
p0
)
v1
=
p3
.
subtract
(
p0
)
t0
=
v0
.
dot
(
v
)
t1
=
v1
.
dot
(
v
)
if
t0
>
t1
:
t
=
t0
t0
=
t1
t1
=
t
return
segment_overlap
(
t0
,
t1
,
0.0
,
n_square
)
modules/tools/prediction/mlp_train/common/vector2d.py
0 → 100644
浏览文件 @
67f2e074
from
math
import
sqrt
class
Vector2
:
def
__init__
(
self
,
x
,
y
):
self
.
x
=
x
self
.
y
=
y
def
add
(
self
,
v
):
return
Vector2
(
self
.
x
+
v
.
x
,
self
.
y
+
v
.
y
)
def
subtract
(
self
,
v
):
return
Vector2
(
self
.
x
-
v
.
x
,
self
.
y
-
v
.
y
)
def
dot
(
self
,
v
):
return
self
.
x
*
v
.
x
+
self
.
y
*
v
.
y
def
norm
(
self
):
return
sqrt
(
self
.
x
*
self
.
x
+
self
.
y
*
self
.
y
)
def
norm_square
(
self
):
return
self
.
x
*
self
.
x
+
self
.
y
*
self
.
y
def
print_point
(
self
):
print
(
str
(
self
.
x
)
+
"
\t
"
+
str
(
self
.
y
)
+
"
\n
"
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录