Skip to content
Snippets Groups Projects
Commit c7cd96d0 authored by David GEISSBUHLER's avatar David GEISSBUHLER
Browse files

Update README.rst

parent 4bf9c5d1
No related branches found
No related tags found
No related merge requests found
Pipeline #47867 failed
...@@ -42,7 +42,7 @@ Usage ...@@ -42,7 +42,7 @@ Usage
A :obj:`Stream` object is a (pseudo-)container allowing storage, transfert and processing of numerical data, A :obj:`Stream` object is a (pseudo-)container allowing storage, transfert and processing of numerical data,
with a focus on raw multi-channel video. It shares part of the interface of a :obj:`numpy.ndarray` object, for with a focus on raw multi-channel video. It shares part of the interface of a :obj:`numpy.ndarray` object, for
instance the propertises `ndim`and `shape`, but with a name on top instance the propertises :obj:`ndim` and :obj:`shape`, but with a name on top
.. code-block:: python .. code-block:: python
from bob.io.stream import Stream from bob.io.stream import Stream
...@@ -52,7 +52,7 @@ instance the propertises `ndim`and `shape`, but with a name on top ...@@ -52,7 +52,7 @@ instance the propertises `ndim`and `shape`, but with a name on top
print(color.ndim) # -> None print(color.ndim) # -> None
print(color.shape) # -> None print(color.shape) # -> None
A :obj:`Stream` object is created in an 'indefinite' state, characterised by a `shape` and `ndim` properties equal to `None`. A :obj:`Stream` object is created in an 'indefinite' state, characterised by a :obj:`shape` and :obj:`ndim` properties equal to :obj:`None`.
Such a newly created can be made to point to a dataset stored in a properly formated HDF5 file Such a newly created can be made to point to a dataset stored in a properly formated HDF5 file
.. code-block:: python .. code-block:: python
...@@ -65,7 +65,7 @@ Such a newly created can be made to point to a dataset stored in a properly form ...@@ -65,7 +65,7 @@ Such a newly created can be made to point to a dataset stored in a properly form
print(color.ndim) # -> 4 print(color.ndim) # -> 4
print(color.shape) # -> (60, 3, 1080, 1920) print(color.shape) # -> (60, 3, 1080, 1920)
Which is the 'definite' state where the objet points towards a data source, this time characterised by definite values of `shape` and `ndim`. Which is the 'definite' state where the objet points towards a data source, this time characterised by definite values of :obj:`shape` and :obj:`ndim`.
A last possible state for such an object is a 'streaming' state where A last possible state for such an object is a 'streaming' state where
.. code-block:: python .. code-block:: python
...@@ -74,7 +74,7 @@ A last possible state for such an object is a 'streaming' state where ...@@ -74,7 +74,7 @@ A last possible state for such an object is a 'streaming' state where
print(color.ndim) # -> 4 print(color.ndim) # -> 4
print(color.shape) # -> (None, 3, 480, 720) print(color.shape) # -> (None, 3, 480, 720)
the first element of the `shape` property is `None`, such 'streaming' states are treated at a later stage . Unlike a :obj:`numpy.ndarray` the first element of the :obj:`shape` property is :obj:`None`, such 'streaming' states are treated at a later stage . Unlike a :obj:`numpy.ndarray`
object, the first dimension of a stream :obj:`Stream` is always a time direction and a unit slice a 'frame', setting back object, the first dimension of a stream :obj:`Stream` is always a time direction and a unit slice a 'frame', setting back
our stream to a definite state our stream to a definite state
...@@ -87,8 +87,8 @@ our stream to a definite state ...@@ -87,8 +87,8 @@ our stream to a definite state
print(frame.shape) # -> (60, 3, 1080, 1920) print(frame.shape) # -> (60, 3, 1080, 1920)
print(type(frame)) # -> <class 'numpy.ndarray'> print(type(frame)) # -> <class 'numpy.ndarray'>
Similarly to a numpy array of more than one dimension, subscripting on the first index of a sream also yields a numpy arry. If the Similarly to a numpy array of more than one dimension, subscripting on the first index of a sream also yields a numpy array. If the
the first index however is not an integer but a range (a pythonic `slice` formally) the first index however is not an integer but a range (a pythonic :obj:`slice` formally)
.. code-block:: python .. code-block:: python
what = color[3:13, :, 100:200, 300:400] what = color[3:13, :, 100:200, 300:400]
...@@ -106,13 +106,13 @@ is a only node in a data processing chain, with a parent and a child ...@@ -106,13 +106,13 @@ is a only node in a data processing chain, with a parent and a child
print(color.child == what) # -> True print(color.child == what) # -> True
This processing chain can be further extended by adding 'filters' after the child node, this is done by invoquing methods This processing chain can be further extended by adding 'filters' after the child node, this is done by invoquing methods
implemented by the `stream` object implemented by the :obj:`stream` object
.. code-block:: python .. code-block:: python
norm = what.normalise() # -> <class 'StreamNormalise'> norm = what.normalise() # -> <class 'StreamNormalise'>
real = norm.as_type('float') # -> <class 'StreamAsType'> real = norm.as_type('float') # -> <class 'StreamAsType'>
A list of filters is returned by the `get_available_filters()`method of the `Stream`class. A list of filters is returned by the :obj:`get_available_filters()` method of the :obj:`Stream` class.
.. code-block:: python .. code-block:: python
# StreamFile("file.h5") # StreamFile("file.h5")
...@@ -131,7 +131,7 @@ In the following example, the data goes down the chain on the first line, on the ...@@ -131,7 +131,7 @@ In the following example, the data goes down the chain on the first line, on the
data = real[0] data = real[0]
This buffering avoids useless computation in more complex pipelines. An alternative to subscripting for fetching data is via This buffering avoids useless computation in more complex pipelines. An alternative to subscripting for fetching data is via
the `load` method that also allows loading several frames at the same time the :obj:`load` method that also allows loading several frames at the same time
.. code-block:: python .. code-block:: python
data0, *meta0 = real.load(0) data0, *meta0 = real.load(0)
...@@ -144,7 +144,7 @@ the `load` method that also allows loading several frames at the same time ...@@ -144,7 +144,7 @@ the `load` method that also allows loading several frames at the same time
print(data1.shape) # -> (5, 3, 100, 100) print(data1.shape) # -> (5, 3, 100, 100)
print(type(data1)) # -> <class 'numpy.ndarray'> print(type(data1)) # -> <class 'numpy.ndarray'>
The `load` function is only available for a 'definite' state stream, in the other cases it raises an exception. In contrast of the The :obj:`load` function is only available for a 'definite' state stream, in the other cases it raises an exception. In contrast of the
subscripting syntax, this method also returns a tuple of metadata. (...) subscripting syntax, this method also returns a tuple of metadata. (...)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment