Commit 2acbfd5a authored by André Anjos's avatar André Anjos 💬
Browse files

Merge branch 'array' into 'master'

Add as_array to frame containers

See merge request !21
parents 0ba89608 0f132fb8
Pipeline #13437 passed with stages
in 18 minutes and 44 seconds
......@@ -38,6 +38,9 @@ def test_frame_container():
assert abs(quality - index/5.) < 1e-8
assert numpy.allclose(test_data[index], data)
# test as_array method
assert numpy.allclose(read.as_array(), test_data)
finally:
if os.path.exists(filename):
os.remove(filename)
......
......@@ -72,6 +72,22 @@ class FrameContainer:
if not numpy.allclose(a[1], b[1]): return False
return True
def as_array(self):
"""Returns the data of frames as a numpy array.
Returns
-------
numpy.ndarray
The frames are returned as an array with the shape of (n_frames, ...)
like a video.
"""
def _reader(frame):
# Each frame is assumed to be an image here. We make it a single frame
# video here by expanding its dimensions. This way it can be used with
# the vstack_features function.
return frame[1][None, ...]
return bob.bio.base.vstack_features(_reader, self._frames, same_size=True)
def save_compressed(frame_container, filename, save_function, create_link=True):
hdf5 = bob.bio.base.open_compressed(filename, 'w')
frame_container.save(hdf5, save_function)
......
Markdown is supported
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