Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.io.stream
Commits
2819d3a7
Commit
2819d3a7
authored
Sep 14, 2020
by
David GEISSBUHLER
Browse files
Merge branch 'sliced_stream' of gitlab.idiap.ch:bob/bob.io.stream into sliced_stream
parents
5440e074
3c30fe5b
Changes
2
Hide whitespace changes
Inline
Side-by-side
bob/io/stream/stream.py
View file @
2819d3a7
...
...
@@ -22,8 +22,8 @@ class Stream:
# reset stream
def
reset
(
self
):
self
.
_
_
loaded
=
None
self
.
_
_
data
=
None
self
.
_loaded
=
None
self
.
_data
=
None
self
.
__bounding_box
=
StreamArray
(
self
)
self
.
__image_points
=
StreamArray
(
self
)
...
...
@@ -199,14 +199,14 @@ class Stream:
def
load
(
self
,
index
=
None
):
indices
=
self
.
get_frame_indices
(
index
)
# return buffered data OR load from file OR process data
if
self
.
_
_
loaded
==
indices
and
self
.
_
_
data
is
not
None
:
if
self
.
_loaded
==
indices
and
self
.
_data
is
not
None
:
# print('loaded', self.name)
pass
else
:
self
.
_
_
data
=
self
.
parent
.
load_stream_data
(
self
.
name
,
indices
)
self
.
_data
=
self
.
parent
.
load_stream_data
(
self
.
name
,
indices
)
# buffer and return data
self
.
_
_
loaded
=
indices
return
self
.
_
_
data
self
.
_loaded
=
indices
return
self
.
_data
# get size of a given (sliced) axis
def
get_axis_size
(
self
,
axis
,
_slice
=
None
):
...
...
@@ -264,16 +264,16 @@ class StreamFilter(Stream):
# load one or several frames
def
load
(
self
,
index
=
None
):
indices
=
self
.
get_frame_indices
(
index
)
# return buffered data OR
load from file OR
process data
if
self
.
_
Stream__
loaded
==
indices
and
self
.
_
Stream__
data
is
not
None
:
# return buffered data OR process data
if
self
.
_loaded
==
indices
and
self
.
_data
is
not
None
:
# print('loaded', self.name)
pass
else
:
self
.
_
_
data
=
self
.
process
(
self
.
parent
.
load
(
indices
),
indices
)
self
.
_data
=
self
.
process
(
self
.
parent
.
load
(
indices
),
indices
)
# buffer and return data
self
.
_
_
loaded
=
indices
return
self
.
_
_
data
self
.
_loaded
=
indices
return
self
.
_data
################################################################################
### astype ###
...
...
bob/io/stream/stream_file.py
View file @
2819d3a7
...
...
@@ -8,9 +8,11 @@ from bob.ip.stereo import load_camera_config
from
.config
import
load_data_config
class
StreamFile
:
def
__init__
(
self
,
hdf5_file_path
=
None
,
data_format_config_file_path
=
None
,
camera_config_file_path
=
None
,
mode
=
"r"
):
if
hdf5_file_path
is
not
None
:
self
.
hdf5_file
=
HDF5File
(
hdf5_file_path
,
mode
)
def
__init__
(
self
,
hdf5_file
=
None
,
data_format_config_file_path
=
None
,
camera_config_file_path
=
None
,
mode
=
"r"
):
if
isinstance
(
hdf5_file
,
str
):
# case string: it is a path, use bob.io.base.HDF5File
self
.
hdf5_file
=
HDF5File
(
hdf5_file
,
mode
)
elif
hdf5_file
is
not
None
:
# otherwise expect an opened file object (h5py.File, etc...)
self
.
hdf5_file
=
hdf5_file
else
:
self
.
hdf5_file
=
None
if
data_format_config_file_path
is
not
None
:
...
...
@@ -26,16 +28,16 @@ class StreamFile:
pass
def
__exit__
(
self
,
exc_type
,
exc_val
,
exc_tb
):
if
self
.
hdf5_file
is
not
None
:
if
isinstance
(
self
.
hdf5_file
,
HDF5File
)
:
self
.
hdf5_file
.
close
()
# set source
def
set_source
(
self
,
hdf5_file
_path
=
None
,
data_format_config_file_path
=
None
,
camera_config_file_path
=
None
,
mode
=
"r"
self
,
hdf5_file
=
None
,
data_format_config_file_path
=
None
,
camera_config_file_path
=
None
,
mode
=
"r"
):
self
.
__init__
(
hdf5_file
_path
=
hdf5_file
_path
,
hdf5_file
=
hdf5_file
,
data_format_config_file_path
=
data_format_config_file_path
,
camera_config_file_path
=
camera_config_file_path
,
mode
=
mode
,
...
...
@@ -93,7 +95,7 @@ class StreamFile:
if
camera_name
in
self
.
camera_config
:
return
self
.
camera_config
[
camera_name
]
else
:
R
aise
(
'invalid camera name'
)
r
aise
(
'invalid camera name'
)
else
:
return
None
...
...
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