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
603281ae
Commit
603281ae
authored
Apr 28, 2020
by
liyinhao
Browse files
add indoor sample points
parent
2f5b24ce
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
0 deletions
+65
-0
mmdet3d/datasets/pipelines/indoor_sample.py
mmdet3d/datasets/pipelines/indoor_sample.py
+65
-0
No files found.
mmdet3d/datasets/pipelines/indoor_sample.py
0 → 100644
View file @
603281ae
import
numpy
as
np
from
mmdet.datasets.registry
import
PIPELINES
def
points_random_sampling
(
points
,
num_samples
,
replace
=
None
,
return_choices
=
False
):
"""Points Random Sampling
Sample points to a certain number.
Args:
points (ndarray): 3D Points.
num_samples (int): Number of samples to be sampled.
"""
if
replace
is
None
:
replace
=
(
points
.
shape
[
0
]
<
num_samples
)
choices
=
np
.
random
.
choice
(
points
.
shape
[
0
],
num_samples
,
replace
=
replace
)
if
return_choices
:
return
points
[
choices
],
choices
else
:
return
points
[
choices
]
@
PIPELINES
.
register_module
class
IndoorSamplePoints
(
object
):
"""Indoor Sample Points
Sampling data to a certain number.
Args:
name (str): Name of the dataset.
num_points (int): Number of points to be sampled.
"""
def
__init__
(
self
,
name
,
num_points
):
assert
name
in
[
'scannet'
,
'sunrgbd'
]
self
.
name
=
name
self
.
num_points
=
num_points
def
__call__
(
self
,
results
):
points
=
results
.
get
(
'points'
,
None
)
pcl_color
=
results
.
get
(
'pcl_color'
,
None
)
points
,
choices
=
points_random_sampling
(
points
,
self
.
num_points
,
return_choices
=
True
)
results
[
'points'
]
=
points
if
self
.
name
==
'scannet'
:
pcl_color
=
pcl_color
[
choices
]
instance_labels
=
results
.
get
(
'instance_labels'
,
None
)
semantic_labels
=
results
.
get
(
'semantic_labels'
,
None
)
instance_labels
=
instance_labels
[
choices
]
semantic_labels
=
semantic_labels
[
choices
]
results
[
'instance_labels'
]
=
instance_labels
results
[
'semantic_labels'
]
=
semantic_labels
results
[
'pcl_color'
]
=
pcl_color
return
results
def
__repr__
(
self
):
repr_str
=
self
.
__class__
.
__name__
repr_str
+=
'(num_points={})'
.
format
(
self
.
num_points
)
return
repr_str
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