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
f2ae5e94
Commit
f2ae5e94
authored
Jun 07, 2020
by
yinchimaoliang
Browse files
clean unnecessary funcs
parent
ad08a792
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
104 deletions
+0
-104
data/sunrgbd/sunrgbd_utils.py
data/sunrgbd/sunrgbd_utils.py
+0
-104
No files found.
data/sunrgbd/sunrgbd_utils.py
View file @
f2ae5e94
...
@@ -11,8 +11,6 @@ Updated by Charles R. Qi
...
@@ -11,8 +11,6 @@ Updated by Charles R. Qi
Date: December, 2018
Date: December, 2018
Note: removed basis loading.
Note: removed basis loading.
'''
'''
import
gzip
import
pickle
import
cv2
import
cv2
import
numpy
as
np
import
numpy
as
np
...
@@ -164,20 +162,6 @@ class SUNRGBD_Calibration(object):
...
@@ -164,20 +162,6 @@ class SUNRGBD_Calibration(object):
pts_3d_upright_depth
)
pts_3d_upright_depth
)
def
rotx
(
t
):
"""Rotation about the x-axis."""
c
=
np
.
cos
(
t
)
s
=
np
.
sin
(
t
)
return
np
.
array
([[
1
,
0
,
0
],
[
0
,
c
,
-
s
],
[
0
,
s
,
c
]])
def
roty
(
t
):
"""Rotation about the y-axis."""
c
=
np
.
cos
(
t
)
s
=
np
.
sin
(
t
)
return
np
.
array
([[
c
,
0
,
s
],
[
0
,
1
,
0
],
[
-
s
,
0
,
c
]])
def
rotz
(
t
):
def
rotz
(
t
):
"""Rotation about the z-axis."""
"""Rotation about the z-axis."""
c
=
np
.
cos
(
t
)
c
=
np
.
cos
(
t
)
...
@@ -192,16 +176,6 @@ def transform_from_rot_trans(R, t):
...
@@ -192,16 +176,6 @@ def transform_from_rot_trans(R, t):
return
np
.
vstack
((
np
.
hstack
([
R
,
t
]),
[
0
,
0
,
0
,
1
]))
return
np
.
vstack
((
np
.
hstack
([
R
,
t
]),
[
0
,
0
,
0
,
1
]))
def
inverse_rigid_trans
(
Tr
):
"""Inverse a rigid body transform matrix (3x4 as [R|t])
[R'|-R't; 0|1]
"""
inv_Tr
=
np
.
zeros_like
(
Tr
)
# 3x4
inv_Tr
[
0
:
3
,
0
:
3
]
=
np
.
transpose
(
Tr
[
0
:
3
,
0
:
3
])
inv_Tr
[
0
:
3
,
3
]
=
np
.
dot
(
-
np
.
transpose
(
Tr
[
0
:
3
,
0
:
3
]),
Tr
[
0
:
3
,
3
])
return
inv_Tr
def
read_sunrgbd_label
(
label_filename
):
def
read_sunrgbd_label
(
label_filename
):
lines
=
[
line
.
rstrip
()
for
line
in
open
(
label_filename
)]
lines
=
[
line
.
rstrip
()
for
line
in
open
(
label_filename
)]
objects
=
[
SUNObject3d
(
line
)
for
line
in
lines
]
objects
=
[
SUNObject3d
(
line
)
for
line
in
lines
]
...
@@ -222,23 +196,6 @@ def load_depth_points_mat(depth_filename):
...
@@ -222,23 +196,6 @@ def load_depth_points_mat(depth_filename):
return
depth
return
depth
def
random_shift_box2d
(
box2d
,
shift_ratio
=
0.1
):
''' Randomly shift box center, randomly scale width and height
'''
r
=
shift_ratio
xmin
,
ymin
,
xmax
,
ymax
=
box2d
h
=
ymax
-
ymin
w
=
xmax
-
xmin
cx
=
(
xmin
+
xmax
)
/
2.0
cy
=
(
ymin
+
ymax
)
/
2.0
cx2
=
cx
+
w
*
r
*
(
np
.
random
.
random
()
*
2
-
1
)
cy2
=
cy
+
h
*
r
*
(
np
.
random
.
random
()
*
2
-
1
)
h2
=
h
*
(
1
+
np
.
random
.
random
()
*
2
*
r
-
r
)
# 0.9 to 1.1
w2
=
w
*
(
1
+
np
.
random
.
random
()
*
2
*
r
-
r
)
# 0.9 to 1.1
return
np
.
array
(
[
cx2
-
w2
/
2.0
,
cy2
-
h2
/
2.0
,
cx2
+
w2
/
2.0
,
cy2
+
h2
/
2.0
])
def
in_hull
(
p
,
hull
):
def
in_hull
(
p
,
hull
):
from
scipy.spatial
import
Delaunay
from
scipy.spatial
import
Delaunay
if
not
isinstance
(
hull
,
Delaunay
):
if
not
isinstance
(
hull
,
Delaunay
):
...
@@ -299,64 +256,3 @@ def compute_box_3d(obj, calib):
...
@@ -299,64 +256,3 @@ def compute_box_3d(obj, calib):
corners_2d
,
_
=
calib
.
project_upright_depth_to_image
(
corners_2d
,
_
=
calib
.
project_upright_depth_to_image
(
np
.
transpose
(
corners_3d
))
np
.
transpose
(
corners_3d
))
return
corners_2d
,
np
.
transpose
(
corners_3d
)
return
corners_2d
,
np
.
transpose
(
corners_3d
)
def
compute_orientation_3d
(
obj
,
calib
):
''' Takes an object and a projection matrix (P) and projects the 3d
object orientation vector into the image plane.
Returns:
orientation_2d: (2,2) array in image coord.
orientation_3d: (2,3) array in depth coord.
'''
# orientation in object coordinate system
ori
=
obj
.
orientation
orientation_3d
=
np
.
array
([[
0
,
ori
[
0
]],
[
0
,
ori
[
1
]],
[
0
,
0
]])
center
=
obj
.
centroid
orientation_3d
[
0
,
:]
=
orientation_3d
[
0
,
:]
+
center
[
0
]
orientation_3d
[
1
,
:]
=
orientation_3d
[
1
,
:]
+
center
[
1
]
orientation_3d
[
2
,
:]
=
orientation_3d
[
2
,
:]
+
center
[
2
]
# project orientation into the image plane
orientation_2d
,
_
=
calib
.
project_upright_depth_to_image
(
np
.
transpose
(
orientation_3d
))
return
orientation_2d
,
np
.
transpose
(
orientation_3d
)
def
draw_projected_box3d
(
image
,
qs
,
color
=
(
255
,
255
,
255
),
thickness
=
2
):
''' Draw 3d bounding box in image
qs: (8,2) array of vertices for the 3d box in following order:
1 -------- 0
/| /|
2 -------- 3 .
| | | |
. 5 -------- 4
|/ |/
6 -------- 7
'''
qs
=
qs
.
astype
(
np
.
int32
)
for
k
in
range
(
0
,
4
):
# http://docs.enthought.com/mayavi/mayavi/auto/mlab_helper_functions.html
i
,
j
=
k
,
(
k
+
1
)
%
4
cv2
.
line
(
image
,
(
qs
[
i
,
0
],
qs
[
i
,
1
]),
(
qs
[
j
,
0
],
qs
[
j
,
1
]),
color
,
thickness
,
cv2
.
CV_AA
)
# use LINE_AA for opencv3
i
,
j
=
k
+
4
,
(
k
+
1
)
%
4
+
4
cv2
.
line
(
image
,
(
qs
[
i
,
0
],
qs
[
i
,
1
]),
(
qs
[
j
,
0
],
qs
[
j
,
1
]),
color
,
thickness
,
cv2
.
CV_AA
)
i
,
j
=
k
,
k
+
4
cv2
.
line
(
image
,
(
qs
[
i
,
0
],
qs
[
i
,
1
]),
(
qs
[
j
,
0
],
qs
[
j
,
1
]),
color
,
thickness
,
cv2
.
CV_AA
)
return
image
def
save_zipped_pickle
(
obj
,
filename
,
protocol
=-
1
):
with
gzip
.
open
(
filename
,
'wb'
)
as
f
:
pickle
.
dump
(
obj
,
f
,
protocol
)
def
load_zipped_pickle
(
filename
):
with
gzip
.
open
(
filename
,
'rb'
)
as
f
:
loaded_object
=
pickle
.
load
(
f
)
return
loaded_object
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