FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
GIGA/scripts/construct_dataset_parallel.py at main · UT-Austin-RPL/GIGA · GitHub
UT-Austin-RPL
/
GIGA
Public
Notifications
You must be signed in to change notification settings
Fork
32
Star
161
Code
Issues
4
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
GIGA
/
scripts
/
construct_dataset_parallel.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
104 lines (86 loc) · 3.2 KB
Breadcrumbs
GIGA
/
scripts
/
construct_dataset_parallel.py
Copy path
File metadata and controls
104 lines (86 loc) · 3.2 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import
argparse
from
pathlib
import
Path
import
numpy
as
np
import
open3d
as
o3d
from
tqdm
import
tqdm
import
multiprocessing
as
mp
from
vgn
.
io
import
*
from
vgn
.
perception
import
*
from
vgn
.
utils
.
misc
import
apply_noise
RESOLUTION
=
40
def
process_one_scene
(
args
,
f
):
if
f
.
suffix
!=
".npz"
:
return
f
.
stem
depth_imgs
,
extrinsics
=
read_sensor_data
(
args
.
raw
,
f
.
stem
)
# add noise
depth_imgs
=
np
.
array
([
apply_noise
(
x
,
args
.
add_noise
)
for
x
in
depth_imgs
])
if
args
.
single_view
:
tsdf
=
create_tsdf
(
size
,
RESOLUTION
,
depth_imgs
[[
0
]],
intrinsic
,
extrinsics
[[
0
]])
else
:
tsdf
=
create_tsdf
(
size
,
RESOLUTION
,
depth_imgs
,
intrinsic
,
extrinsics
)
grid
=
tsdf
.
get_grid
()
write_voxel_grid
(
args
.
dataset
,
f
.
stem
,
grid
)
pc
=
tsdf
.
get_cloud
()
# crop surface and borders from point cloud
lower
=
np
.
array
([
0.02
,
0.02
,
0.055
])
upper
=
np
.
array
([
0.28
,
0.28
,
0.3
])
bounding_box
=
o3d
.
geometry
.
AxisAlignedBoundingBox
(
lower
,
upper
)
pc
=
pc
.
crop
(
bounding_box
)
pc
=
np
.
asarray
(
pc
.
points
)
write_point_cloud
(
args
.
dataset
,
f
.
stem
,
pc
)
return
str
(
f
.
stem
)
def
log_result
(
result
):
g_num_completed_jobs
.
append
(
result
)
elapsed_time
=
time
.
time
()
-
g_starting_time
if
len
(
g_num_completed_jobs
)
%
1000
==
0
:
msg
=
"%05d/%05d %s finished! "
%
(
len
(
g_num_completed_jobs
),
g_num_total_jobs
,
result
)
msg
=
msg
+
'Elapsed time: '
+
\
time
.
strftime
(
"%H:%M:%S"
,
time
.
gmtime
(
elapsed_time
))
+
'. '
print
(
msg
)
def
main
(
args
):
if
args
.
single_view
:
print
(
'Loading first view only!'
)
# create directory of new dataset
(
args
.
dataset
/
"scenes"
).
mkdir
(
parents
=
True
)
(
args
.
dataset
/
"point_clouds"
).
mkdir
(
parents
=
True
)
global
g_num_completed_jobs
global
g_num_total_jobs
global
g_starting_time
global
size
global
intrinsic
# load setup information
size
,
intrinsic
,
_
,
finger_depth
=
read_setup
(
args
.
raw
)
assert
np
.
isclose
(
size
,
6.0
*
finger_depth
)
voxel_size
=
size
/
RESOLUTION
# create df
df
=
read_df
(
args
.
raw
)
df
[
"x"
]
/=
voxel_size
df
[
"y"
]
/=
voxel_size
df
[
"z"
]
/=
voxel_size
df
[
"width"
]
/=
voxel_size
df
=
df
.
rename
(
columns
=
{
"x"
:
"i"
,
"y"
:
"j"
,
"z"
:
"k"
})
write_df
(
df
,
args
.
dataset
)
g_num_completed_jobs
=
[]
file_list
=
list
((
args
.
raw
/
"scenes"
).
iterdir
())
g_num_total_jobs
=
len
(
file_list
)
g_starting_time
=
time
.
time
()
# create tsdfs and pcs
if
args
.
num_proc
>
1
:
pool
=
mp
.
Pool
(
processes
=
args
.
num_proc
)
print
(
'Total jobs: %d, CPU num: %d'
%
(
g_num_total_jobs
,
args
.
num_proc
))
for
f
in
file_list
:
pool
.
apply_async
(
func
=
process_one_scene
,
args
=
(
args
,
f
,),
callback
=
log_result
)
pool
.
close
()
pool
.
join
()
else
:
for
f
in
tqdm
(
file_list
,
total
=
len
(
file_list
)):
process_one_scene
(
args
,
f
)
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"raw"
,
type
=
Path
)
parser
.
add_argument
(
"dataset"
,
type
=
Path
)
parser
.
add_argument
(
"--num-proc"
,
type
=
int
,
default
=
1
)
parser
.
add_argument
(
"--single-view"
,
action
=
'store_true'
)
parser
.
add_argument
(
"--add-noise"
,
type
=
str
,
default
=
''
)
args
=
parser
.
parse_args
()
main
(
args
)
Back
|
FazBrowse Home
|
New Git URL