Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
navipy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Olivier Bertrand
navipy
Commits
5da78310
Commit
5da78310
authored
6 years ago
by
Olivier Bertrand
Browse files
Options
Downloads
Patches
Plain Diff
Add more infos in log, and remove tmp file after loading image
parent
6d7fe10f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
navipy/sensors/renderer.py
+16
-7
16 additions, 7 deletions
navipy/sensors/renderer.py
with
16 additions
and
7 deletions
navipy/sensors/renderer.py
+
16
−
7
View file @
5da78310
...
@@ -119,6 +119,7 @@ class AbstractRender():
...
@@ -119,6 +119,7 @@ class AbstractRender():
distance
[
distance
>
self
.
worldlimit
]
=
self
.
worldlimit
distance
[
distance
>
self
.
worldlimit
]
=
self
.
worldlimit
scene
[...,
-
1
]
=
distance
scene
[...,
-
1
]
=
distance
if
mode
==
'
database
'
:
if
mode
==
'
database
'
:
self
.
_logger
.
info
(
'
Write image
'
)
dataloger
.
write_image
(
posorient
,
scene
)
dataloger
.
write_image
(
posorient
,
scene
)
elif
mode
==
'
array
'
:
elif
mode
==
'
array
'
:
if
imformat
==
'
.npy
'
:
if
imformat
==
'
.npy
'
:
...
@@ -493,13 +494,14 @@ class BlenderRender(AbstractRender):
...
@@ -493,13 +494,14 @@ class BlenderRender(AbstractRender):
self
.
tmp_fileoutput
[
'
ext
'
])
self
.
tmp_fileoutput
[
'
ext
'
])
im_width
,
im_height
=
self
.
camera_resolution
im_width
,
im_height
=
self
.
camera_resolution
im
=
bpy
.
data
.
images
.
load
(
filename
)
im
=
bpy
.
data
.
images
.
load
(
filename
)
# remote image once we read it. To avoid storing all images
pixels
=
np
.
array
(
im
.
pixels
).
copy
()
self
.
_logger
.
debug
(
'
Delete file {}
'
.
format
(
filename
))
os
.
remove
(
filename
)
pixels
=
np
.
array
(
im
.
pixels
)
pixels
=
pixels
.
reshape
([
im_height
,
im_width
,
-
1
])
pixels
=
pixels
.
reshape
([
im_height
,
im_width
,
-
1
])
# The last channel is the alpha channel
# The last channel is the alpha channel
pixels
=
pixels
[...,
:(
pixels
.
shape
[
2
]
-
1
)]
pixels
=
pixels
[...,
:(
pixels
.
shape
[
2
]
-
1
)]
self
.
_logger
.
debug
(
'
Image -> Ok
'
)
# remote image once we read it. To avoid storing all images
self
.
_logger
.
debug
(
'
Delete file {}
'
.
format
(
filename
))
os
.
remove
(
filename
)
return
pixels
return
pixels
@property
@property
...
@@ -525,12 +527,16 @@ class BlenderRender(AbstractRender):
...
@@ -525,12 +527,16 @@ class BlenderRender(AbstractRender):
self
.
tmp_fileoutput
[
'
ext
'
])
self
.
tmp_fileoutput
[
'
ext
'
])
im_width
,
im_height
=
self
.
camera_resolution
im_width
,
im_height
=
self
.
camera_resolution
im
=
bpy
.
data
.
images
.
load
(
filename
)
im
=
bpy
.
data
.
images
.
load
(
filename
)
# remote image once we read it. To avoid storing all images
distance
=
np
.
array
(
im
.
pixels
).
copy
()
# somehow failing os.remove(filename)
self
.
_logger
.
debug
(
'
Reshape {}->{}
'
.
format
(
distance
=
np
.
array
(
im
.
pixels
)
distance
.
shape
,
self
.
camera_resolution
)
)
distance
=
distance
.
reshape
([
im_height
,
im_width
,
-
1
])
distance
=
distance
.
reshape
([
im_height
,
im_width
,
-
1
])
# Distance are channel independent
# Distance are channel independent
distance
=
distance
[:,
:,
0
]
distance
=
distance
[:,
:,
0
]
self
.
_logger
.
debug
(
'
Distance -> Ok
'
)
# remote image once we read it. To avoid storing all images
self
.
_logger
.
debug
(
'
Delete file {}
'
.
format
(
filename
))
os
.
remove
(
filename
)
return
distance
[...,
np
.
newaxis
]
return
distance
[...,
np
.
newaxis
]
def
update
(
self
,
posorient
):
def
update
(
self
,
posorient
):
...
@@ -560,6 +566,7 @@ class BlenderRender(AbstractRender):
...
@@ -560,6 +566,7 @@ class BlenderRender(AbstractRender):
specified by scene.camera.rotation_mode
specified by scene.camera.rotation_mode
:type posorient: pandas Series with multi-index
:type posorient: pandas Series with multi-index
"""
"""
self
.
_logger
.
info
(
'
update posorient to {}
'
.
format
(
posorient
))
if
isinstance
(
posorient
,
pd
.
Series
):
if
isinstance
(
posorient
,
pd
.
Series
):
# set frame
# set frame
cframe
=
int
(
posorient
.
name
)
cframe
=
int
(
posorient
.
name
)
...
@@ -614,6 +621,7 @@ class BlenderRender(AbstractRender):
...
@@ -614,6 +621,7 @@ class BlenderRender(AbstractRender):
is the distance.
is the distance.
:rtype: a double numpy array
:rtype: a double numpy array
"""
"""
self
.
_logger
.
info
(
'
get a scene
'
)
self
.
update
(
posorient
)
self
.
update
(
posorient
)
toreturn
=
np
.
concatenate
((
self
.
image
,
toreturn
=
np
.
concatenate
((
self
.
image
,
self
.
distance
),
axis
=
2
)
self
.
distance
),
axis
=
2
)
...
@@ -627,4 +635,5 @@ is the distance.
...
@@ -627,4 +635,5 @@ is the distance.
toreturn
[
np
.
isinf
(
cim
)
==
1
]
=
cmax
toreturn
[
np
.
isinf
(
cim
)
==
1
]
=
cmax
if
ninffound
>
0
:
if
ninffound
>
0
:
warnings
.
warn
(
'
{} Inf found in image
'
.
format
(
ninffound
))
warnings
.
warn
(
'
{} Inf found in image
'
.
format
(
ninffound
))
self
.
_logger
.
info
(
'
Scene -> Ok
'
)
return
toreturn
[...,
np
.
newaxis
]
return
toreturn
[...,
np
.
newaxis
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment