Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
obj2rgbd
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Elphel
obj2rgbd
Commits
b2583e61
Commit
b2583e61
authored
Feb 27, 2020
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed debug, added 16bit depth map conversion from *.exr
parent
81a91132
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
13 deletions
+34
-13
blender_generate_image_and_depth.py
blender_generate_image_and_depth.py
+1
-3
exr2png.py
exr2png.py
+1
-3
obj2rgbd.py
obj2rgbd.py
+32
-7
No files found.
blender_generate_image_and_depth.py
View file @
b2583e61
...
...
@@ -80,7 +80,7 @@ rn = scene.node_tree.nodes.new('CompositorNodeRLayers')
depth
=
scene
.
node_tree
.
nodes
.
new
(
'CompositorNodeOutputFile'
)
depth
.
format
.
file_format
=
'OPEN_EXR'
depth
.
format
.
color_depth
=
'32'
#
TODO: try BW
#
Note: no option for BW?
depth
.
format
.
color_mode
=
'RGB'
depth
.
format
.
exr_codec
=
'ZIP'
depth
.
base_path
=
model_output_folder
...
...
@@ -109,5 +109,3 @@ for fpath in fpaths:
bpy
.
data
.
objects
.
remove
(
obj
)
# rename exr
os
.
rename
(
os
.
path
.
join
(
model_output_folder
,
'depth-0001.exr'
),
os
.
path
.
join
(
model_output_folder
,
obj_name
+
"-depth.exr"
))
exr2png.py
View file @
b2583e61
...
...
@@ -11,7 +11,6 @@ def exr2arr(exrfile):
dw
=
file
.
header
()[
'dataWindow'
]
channels
=
file
.
header
()[
'channels'
]
.
keys
()
print
(
channels
)
channels_list
=
list
()
for
c
in
(
'R'
,
'G'
,
'B'
,
'A'
):
if
c
in
channels
:
...
...
@@ -23,8 +22,7 @@ def exr2arr(exrfile):
color_channels
=
file
.
channels
(
channels_list
,
Imath
.
PixelType
(
Imath
.
PixelType
.
FLOAT
))
channels_tuple
=
[
np
.
fromstring
(
channel
,
dtype
=
'f'
)
for
channel
in
color_channels
]
res
=
np
.
dstack
(
channels_tuple
)
res
.
reshape
(
size
+
(
len
(
channels_tuple
),))
return
res
[:,:,
0
]
return
res
.
reshape
(
size
+
(
len
(
channels_tuple
),))
if
__name__
==
"__main__"
:
...
...
obj2rgbd.py
View file @
b2583e61
import
os
import
subprocess
import
exr2png
as
e2p
PATH_TO_BLENDER
=
""
PATH_TO_BLENDER
=
''
# depth map scale, units in the generated depth map for RGB-D - 16-bit png
#DMP = 1 # 1 m - range 0-65535 m
#DMP = 0.1 # 10 cm - range 0-6553.5 m
DMP
=
0.01
# 1 cm - range 0-655.35 m
#DMP = 0.001 # 1 mm - range 0-65.535 m
fpaths
=
[
'input/1527256815_550165_v01/1527256815_550165.obj'
,
'input/1527256903_350165/v03/1527256903_350165.obj'
,
'input/1488240695_710844_x3d105/1488240695_710844.obj'
]
fpaths
=
[
'input/1527256815_550165_v01/1527256815_550165.obj'
,]
filelist
=
','
.
join
(
fpaths
)
# this will run by Blender's bundled python
subprocess
.
run
(
os
.
path
.
join
(
PATH_TO_BLENDER
,
'blender'
)
+
" -b -P blender_generate_image_and_depth.py -- "
+
filelist
,
shell
=
True
)
model_output_folder
=
"output"
\ No newline at end of file
fname
=
'1527256815_550165-depth.exr'
model_output_folder
=
"output"
fname
=
os
.
path
.
join
(
model_output_folder
,
fname
)
import
exr2png
as
e2p
import
matplotlib.pyplot
as
plt
from
PIL
import
Image
import
numpy
as
np
dmap
=
e2p
.
exr2arr
(
fname
)[:,:,
0
]
# zero background
if
dmap
.
dtype
==
'float32'
:
dmap
[
dmap
==
10000000000.0
]
=
0
dmap
=
dmap
/
DMP
dmap
[
dmap
>
65535
]
=
0
im
=
Image
.
fromarray
(
dmap
.
astype
(
np
.
uint16
))
im
.
save
(
os
.
path
.
join
(
model_output_folder
,
'model-depth.png'
))
plt
.
imshow
(
dmap
)
plt
.
colorbar
()
plt
.
show
()
\ No newline at end of file
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