Commit 6df3b1c3 authored by David GEISSBUHLER's avatar David GEISSBUHLER
Browse files

allow stream files with no config

parent 728f9cfc
from bob.io.stream import Stream, StreamFile, StreamFilter, stream_filter, StreamServer, StreamRemote
from bob.io.stream import Stream, StreamFile, StreamFilter, stream_filter #, StreamServer, StreamRemote
import numpy as np
import bob.io.base
......@@ -18,7 +18,7 @@ assert(data_b.shape == data_shape)
# create data file
f = bob.io.base.HDF5File('data_file.h5', 'w')
f = bob.io.base.HDF5File('api_test.h5', 'w')
f.set('data_a', data_a)
f.set('data_b', data_b)
del f
......@@ -26,42 +26,48 @@ del f
# TODO timestamps
# TODO config
# load as stream
# minimal streams with no config
f = StreamFile( 'data_file.h5', 'configjson'))
color = Stream('color', f)
nir_left = Stream('nir_left_stereo', f).adjust(color)
f = StreamFile('api_test.h5')
stream_a = Stream('data_a', f)
stream_b = Stream('data_b', f)
assert(stream_a.shape == data_a.shape)
assert(stream_b.shape == data_b.shape)
assert(stream_a.timestamps == None)
assert(stream_b.timestamps == None)
assert(stream_a.camera == None)
assert(stream_b.camera == None)
print(stream_a.image_points)
###########
fo = StreamFile('test.h5', 'w')
#fo = StreamFile('api_test.h5', 'w')
so = Stream('out')
co = so.clean()
co.save(fo)
#so = Stream('out')
#co = so.clean()
#co.save(fo)
for i in range(10):
so[i] = data
#for i in range(10):
# so[i] = data
# or
so.append(data)
#
# so.append(data)
# or
fo = StreamFile('test.h5', 'w')
so = Stream('out')
co = so.clean()
#fo = StreamFile('test.h5', 'w')
#so = Stream('out')
#co = so.clean()
for i in range(10):
so[i] = data
#for i in range(10):
# so[i] = data
fo.save(co)
#fo.save(co)
......
......@@ -46,7 +46,15 @@ class StreamFile:
return list(self.data_format_config.keys())
def get_stream_config(self, stream_name):
data_config = self.data_format_config[stream_name]
if self.data_format_config is not None:
data_config = self.data_format_config[stream_name]
else:
# return a generic config if no config is present
# TODO: make formal
data_config = { 'array_format' : None,
'rotation' : None,
'camera' : None,
'path' : stream_name}
return data_config
def get_stream_shape(self, stream_name):
......@@ -78,6 +86,8 @@ class StreamFile:
if "use_config_from" in data_config:
data_config = self.get_stream_config(data_config["use_config_from"])
camera_name = data_config["camera"]
if camera_name is None:
return None
return self.camera_config[camera_name]
def load_stream_data(self, stream_name, index):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment