Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
mmdetection3d
Commits
3035516f
Commit
3035516f
authored
May 08, 2020
by
zhangwenwei
Browse files
Unittest cover base_box3d
parent
0f85fae5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
+18
-2
tests/test_box3d.py
tests/test_box3d.py
+18
-2
No files found.
tests/test_box3d.py
View file @
3035516f
...
@@ -7,6 +7,12 @@ from mmdet3d.core.bbox import (Box3DMode, CameraInstance3DBoxes,
...
@@ -7,6 +7,12 @@ from mmdet3d.core.bbox import (Box3DMode, CameraInstance3DBoxes,
def
test_lidar_boxes3d
():
def
test_lidar_boxes3d
():
# test empty initialization
empty_boxes
=
[]
boxes
=
LiDARInstance3DBoxes
(
empty_boxes
)
assert
boxes
.
tensor
.
shape
[
0
]
==
0
assert
boxes
.
tensor
.
shape
[
1
]
==
7
# Test init with numpy array
# Test init with numpy array
np_boxes
=
np
.
array
(
np_boxes
=
np
.
array
(
[[
1.7802081
,
2.516249
,
-
1.7501148
,
1.75
,
3.39
,
1.65
,
1.48
],
[[
1.7802081
,
2.516249
,
-
1.7501148
,
1.75
,
3.39
,
1.65
,
1.48
],
...
@@ -15,6 +21,12 @@ def test_lidar_boxes3d():
...
@@ -15,6 +21,12 @@ def test_lidar_boxes3d():
boxes_1
=
LiDARInstance3DBoxes
(
np_boxes
)
boxes_1
=
LiDARInstance3DBoxes
(
np_boxes
)
assert
torch
.
allclose
(
boxes_1
.
tensor
,
torch
.
from_numpy
(
np_boxes
))
assert
torch
.
allclose
(
boxes_1
.
tensor
,
torch
.
from_numpy
(
np_boxes
))
# test properties
assert
boxes_1
.
volume
.
size
(
0
)
==
2
assert
(
boxes_1
.
center
==
boxes_1
.
bottom_center
).
all
()
assert
repr
(
boxes
)
==
(
'LiDARInstance3DBoxes(
\n
tensor([], size=(0, 7)))'
)
# test init with torch.Tensor
# test init with torch.Tensor
th_boxes
=
torch
.
tensor
(
th_boxes
=
torch
.
tensor
(
[[
[[
...
@@ -46,6 +58,10 @@ def test_lidar_boxes3d():
...
@@ -46,6 +58,10 @@ def test_lidar_boxes3d():
[
31.31978
,
8.162144
,
-
1.6217787
,
1.74
,
3.77
,
1.48
,
2.79
]])
[
31.31978
,
8.162144
,
-
1.6217787
,
1.74
,
3.77
,
1.48
,
2.79
]])
boxes
=
LiDARInstance3DBoxes
.
cat
([
boxes_1
,
boxes_2
])
boxes
=
LiDARInstance3DBoxes
.
cat
([
boxes_1
,
boxes_2
])
assert
torch
.
allclose
(
boxes
.
tensor
,
expected_tensor
)
assert
torch
.
allclose
(
boxes
.
tensor
,
expected_tensor
)
# concatenate empty list
empty_boxes
=
LiDARInstance3DBoxes
.
cat
([])
assert
empty_boxes
.
tensor
.
shape
[
0
]
==
0
assert
empty_boxes
.
tensor
.
shape
[
-
1
]
==
7
# test box flip
# test box flip
expected_tensor
=
torch
.
tensor
(
expected_tensor
=
torch
.
tensor
(
...
@@ -437,7 +453,7 @@ def test_camera_boxes3d():
...
@@ -437,7 +453,7 @@ def test_camera_boxes3d():
[
19.823532
,
-
28.187025
,
-
1.736057
,
1.56
,
3.48
,
1.4
,
5.1036663
],
[
19.823532
,
-
28.187025
,
-
1.736057
,
1.56
,
3.48
,
1.4
,
5.1036663
],
[
27.974297
,
-
16.27845
,
-
1.6217787
,
1.74
,
3.77
,
1.48
,
0.6236664
]]),
[
27.974297
,
-
16.27845
,
-
1.6217787
,
1.74
,
3.77
,
1.48
,
0.6236664
]]),
Box3DMode
.
LIDAR
,
Box3DMode
.
CAM
)
Box3DMode
.
LIDAR
,
Box3DMode
.
CAM
)
boxes
.
rotate
(
0.27207362796436096
)
boxes
.
rotate
(
torch
.
tensor
(
0.27207362796436096
)
)
assert
torch
.
allclose
(
boxes
.
tensor
,
expected_tensor
)
assert
torch
.
allclose
(
boxes
.
tensor
,
expected_tensor
)
# test box scaling
# test box scaling
...
@@ -487,7 +503,7 @@ def test_camera_boxes3d():
...
@@ -487,7 +503,7 @@ def test_camera_boxes3d():
28.21472
,
-
16.502048
,
-
1.7878747
,
1.7497417
,
28.21472
,
-
16.502048
,
-
1.7878747
,
1.7497417
,
3.791107
,
1.488286
,
0.6236664
3.791107
,
1.488286
,
0.6236664
]]),
Box3DMode
.
LIDAR
,
Box3DMode
.
CAM
)
]]),
Box3DMode
.
LIDAR
,
Box3DMode
.
CAM
)
boxes
.
translate
([
0.13246193
,
0.15701613
,
0.0838056
])
boxes
.
translate
(
torch
.
tensor
(
[
0.13246193
,
0.15701613
,
0.0838056
])
)
assert
torch
.
allclose
(
boxes
.
tensor
,
expected_tensor
)
assert
torch
.
allclose
(
boxes
.
tensor
,
expected_tensor
)
# test bbox in_range_bev
# test bbox in_range_bev
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment