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
5b7004f4
Commit
5b7004f4
authored
Sep 06, 2021
by
Yezhen Cong
Committed by
Tai-Wang
Sep 24, 2021
Browse files
Change cam rot_3d_in_axis (#906)
parent
720caedf
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
14 deletions
+33
-14
mmdet3d/core/bbox/structures/cam_box3d.py
mmdet3d/core/bbox/structures/cam_box3d.py
+2
-9
mmdet3d/core/bbox/structures/utils.py
mmdet3d/core/bbox/structures/utils.py
+2
-2
mmdet3d/models/dense_heads/ssd_3d_head.py
mmdet3d/models/dense_heads/ssd_3d_head.py
+2
-1
tests/test_models/test_detectors.py
tests/test_models/test_detectors.py
+2
-1
tests/test_utils/test_box3d.py
tests/test_utils/test_box3d.py
+25
-1
No files found.
mmdet3d/core/bbox/structures/cam_box3d.py
View file @
5b7004f4
...
...
@@ -137,11 +137,8 @@ class CameraInstance3DBoxes(BaseInstance3DBoxes):
corners_norm
=
corners_norm
-
dims
.
new_tensor
([
0.5
,
1
,
0.5
])
corners
=
dims
.
view
([
-
1
,
1
,
3
])
*
corners_norm
.
reshape
([
1
,
8
,
3
])
# positive direction of the gravity axis
# in cam coord system points to the earth
# so the rotation is clockwise if viewed from above
corners
=
rotation_3d_in_axis
(
corners
,
self
.
tensor
[:,
6
],
axis
=
self
.
YAW_AXIS
,
clockwise
=
True
)
corners
,
self
.
tensor
[:,
6
],
axis
=
self
.
YAW_AXIS
)
corners
+=
self
.
tensor
[:,
:
3
].
view
(
-
1
,
1
,
3
)
return
corners
...
...
@@ -182,11 +179,7 @@ class CameraInstance3DBoxes(BaseInstance3DBoxes):
self
.
tensor
[:,
0
:
3
],
angle
,
axis
=
self
.
YAW_AXIS
,
return_mat
=
True
,
# positive direction of the gravity axis
# in cam coord system points to the earth
# so the rotation is clockwise if viewed from above
clockwise
=
True
)
return_mat
=
True
)
else
:
rot_mat_T
=
angle
rot_sin
=
rot_mat_T
[
2
,
0
]
...
...
mmdet3d/core/bbox/structures/utils.py
View file @
5b7004f4
...
...
@@ -71,9 +71,9 @@ def rotation_3d_in_axis(points,
if
points
.
shape
[
-
1
]
==
3
:
if
axis
==
1
or
axis
==
-
2
:
rot_mat_T
=
torch
.
stack
([
torch
.
stack
([
rot_cos
,
zeros
,
rot_sin
]),
torch
.
stack
([
rot_cos
,
zeros
,
-
rot_sin
]),
torch
.
stack
([
zeros
,
ones
,
zeros
]),
torch
.
stack
([
-
rot_sin
,
zeros
,
rot_cos
])
torch
.
stack
([
rot_sin
,
zeros
,
rot_cos
])
])
elif
axis
==
2
or
axis
==
-
1
:
rot_mat_T
=
torch
.
stack
([
...
...
mmdet3d/models/dense_heads/ssd_3d_head.py
View file @
5b7004f4
...
...
@@ -391,7 +391,8 @@ class SSD3DHead(VoteHead):
# LiDARInstance3DBoxes and DepthInstance3DBoxes
canonical_xyz
=
rotation_3d_in_axis
(
canonical_xyz
.
unsqueeze
(
0
).
transpose
(
0
,
1
),
-
gt_bboxes_3d
.
yaw
[
assignment
],
2
).
squeeze
(
1
)
-
gt_bboxes_3d
.
yaw
[
assignment
],
axis
=
2
).
squeeze
(
1
)
distance_front
=
torch
.
clamp
(
size_res_targets
[:,
0
]
-
canonical_xyz
[:,
0
],
min
=
0
)
distance_back
=
torch
.
clamp
(
...
...
tests/test_models/test_detectors.py
View file @
5b7004f4
...
...
@@ -437,7 +437,8 @@ def test_imvoxelnet():
if
not
torch
.
cuda
.
is_available
():
pytest
.
skip
(
'test requires GPU and torch+cuda'
)
imvoxelnet_cfg
=
_get_detector_cfg
(
'imvoxelnet/imvoxelnet_kitti-3d-car.py'
)
imvoxelnet_cfg
=
_get_detector_cfg
(
'imvoxelnet/imvoxelnet_4x8_kitti-3d-car.py'
)
self
=
build_detector
(
imvoxelnet_cfg
).
cuda
()
imgs
=
torch
.
rand
([
1
,
3
,
384
,
1280
],
dtype
=
torch
.
float32
).
cuda
()
gt_bboxes_3d
=
[
LiDARInstance3DBoxes
(
torch
.
rand
([
3
,
7
],
device
=
'cuda'
))]
...
...
tests/test_utils/test_box3d.py
View file @
5b7004f4
...
...
@@ -1553,13 +1553,37 @@ def test_rotation_3d_in_axis():
[[
-
0.2555
,
-
0.2683
,
0.0000
],
[
-
0.2555
,
-
0.2683
,
0.9072
]]])
angles
=
[
np
.
pi
/
2
,
-
np
.
pi
/
2
]
rotated
=
rotation_3d_in_axis
(
points
,
angles
,
axis
=
0
)
rotated
=
rotation_3d_in_axis
(
points
,
angles
,
axis
=
0
)
.
numpy
()
expected_rotated
=
np
.
array
([[[
-
0.4599
,
0.0000
,
-
0.0471
],
[
-
0.4599
,
-
1.8433
,
-
0.0471
]],
[[
-
0.2555
,
0.0000
,
0.2683
],
[
-
0.2555
,
0.9072
,
0.2683
]]])
assert
np
.
allclose
(
rotated
,
expected_rotated
,
atol
=
1e-3
)
points
=
torch
.
tensor
([[[
-
0.4599
,
-
0.0471
,
0.0000
],
[
-
0.4599
,
-
0.0471
,
1.8433
]],
[[
-
0.2555
,
-
0.2683
,
0.0000
],
[
-
0.2555
,
-
0.2683
,
0.9072
]]])
angles
=
[
np
.
pi
/
2
,
-
np
.
pi
/
2
]
rotated
=
rotation_3d_in_axis
(
points
,
angles
,
axis
=
1
).
numpy
()
expected_rotated
=
np
.
array
([[[
0.0000
,
-
0.0471
,
0.4599
],
[
1.8433
,
-
0.0471
,
0.4599
]],
[[
0.0000
,
-
0.2683
,
-
0.2555
],
[
-
0.9072
,
-
0.2683
,
-
0.2555
]]])
assert
np
.
allclose
(
rotated
,
expected_rotated
,
atol
=
1e-3
)
points
=
torch
.
tensor
([[[
-
0.4599
,
-
0.0471
,
0.0000
],
[
-
0.4599
,
0.0471
,
1.8433
]],
[[
-
0.2555
,
-
0.2683
,
0.0000
],
[
0.2555
,
-
0.2683
,
0.9072
]]])
angles
=
[
np
.
pi
/
2
,
-
np
.
pi
/
2
]
rotated
=
rotation_3d_in_axis
(
points
,
angles
,
axis
=
2
).
numpy
()
expected_rotated
=
np
.
array
([[[
0.0471
,
-
0.4599
,
0.0000
],
[
-
0.0471
,
-
0.4599
,
1.8433
]],
[[
-
0.2683
,
0.2555
,
0.0000
],
[
-
0.2683
,
-
0.2555
,
0.9072
]]])
assert
np
.
allclose
(
rotated
,
expected_rotated
,
atol
=
1e-3
)
points
=
torch
.
tensor
([[[
-
0.0471
,
0.0000
],
[
-
0.0471
,
1.8433
]],
[[
-
0.2683
,
0.0000
],
[
-
0.2683
,
0.9072
]]])
angles
=
[
np
.
pi
/
2
,
-
np
.
pi
/
2
]
...
...
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