Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.io.base
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.io.base
Commits
22e754c7
Commit
22e754c7
authored
10 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
Documentation patches
parent
18361e20
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
doc/c_cpp_api.rst
+17
-13
17 additions, 13 deletions
doc/c_cpp_api.rst
doc/conf.py
+6
-6
6 additions, 6 deletions
doc/conf.py
doc/guide.rst
+79
-73
79 additions, 73 deletions
doc/guide.rst
doc/index.rst
+5
-5
5 additions, 5 deletions
doc/index.rst
with
107 additions
and
97 deletions
doc/c_cpp_api.rst
+
17
−
13
View file @
22e754c7
...
@@ -6,10 +6,10 @@
...
@@ -6,10 +6,10 @@
C++ API
C++ API
=========
=========
The C++ API of ``xbob.io`` allows users to leverage from automatic converters
The C++ API of ``xbob.io
.base
`` allows users to leverage from automatic converters
for classes in :py:class:`xbob.io`. To use the C API, clients should first,
for classes in :py:class:`xbob.io
.base
`. To use the C API, clients should first,
include the header file ``<xbob.io/api.h>`` on their compilation units and
include the header file ``<xbob.io
.base
/api.h>`` on their compilation units and
then, make sure to call once ``import_xbob_io()`` at their module
then, make sure to call once ``import_xbob_io
_base
()`` at their module
instantiation, as explained at the `Python manual
instantiation, as explained at the `Python manual
<http://docs.python.org/2/extending/extending.html#using-capsules>`_.
<http://docs.python.org/2/extending/extending.html#using-capsules>`_.
...
@@ -18,7 +18,7 @@ the import function:
...
@@ -18,7 +18,7 @@ the import function:
.. code-block:: c++
.. code-block:: c++
#include <xbob.io/api.h>
#include <xbob.io
.base
/api.h>
PyMODINIT_FUNC initclient(void) {
PyMODINIT_FUNC initclient(void) {
...
@@ -26,21 +26,25 @@ the import function:
...
@@ -26,21 +26,25 @@ the import function:
if (!m) return;
if (!m) return;
// imports the NumPy C-API
/* imports dependencies */
import_array();
if (import_xbob_blitz() < 0) {
PyErr_Print();
PyErr_SetString(PyExc_ImportError, "cannot import extension");
return 0;
}
//
import
s blitz.array C-API
if (
import
_xbob_io_base() < 0) {
import_xbob_blitz
();
PyErr_Print
();
PyErr_SetString(PyExc_ImportError, "cannot import extension");
// imports xbob.io C-API
return 0;
import_xbob_io();
}
}
}
.. note::
.. note::
The include directory can be discovered using
The include directory can be discovered using
:py:func:`xbob.io.get_include`.
:py:func:`xbob.io.
base.
get_include`.
Generic Functions
Generic Functions
-----------------
-----------------
...
...
This diff is collapsed.
Click to expand it.
doc/conf.py
+
6
−
6
View file @
22e754c7
...
@@ -58,12 +58,12 @@ source_suffix = '.rst'
...
@@ -58,12 +58,12 @@ source_suffix = '.rst'
master_doc
=
'
index
'
master_doc
=
'
index
'
# General information about the project.
# General information about the project.
project
=
u
'
xbob.io
'
project
=
u
'
xbob.io
.base
'
import
time
import
time
copyright
=
u
'
%s, Idiap Research Institute
'
%
time
.
strftime
(
'
%Y
'
)
copyright
=
u
'
%s, Idiap Research Institute
'
%
time
.
strftime
(
'
%Y
'
)
# Grab the setup entry
# Grab the setup entry
distribution
=
pkg_resources
.
require
(
'
xbob.io
'
)[
0
]
distribution
=
pkg_resources
.
require
(
'
xbob.io
.base
'
)[
0
]
# The version info for the project you're documenting, acts as replacement for
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# |version| and |release|, also used in various other places throughout the
...
@@ -129,7 +129,7 @@ if sphinx.__version__ >= "1.0":
...
@@ -129,7 +129,7 @@ if sphinx.__version__ >= "1.0":
#html_title = None
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = 'xbob_io'
#html_short_title = 'xbob_io
_base
'
# The name of an image file (relative to this directory) to place at the top
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
# of the sidebar.
...
@@ -187,7 +187,7 @@ html_favicon = 'img/favicon.ico'
...
@@ -187,7 +187,7 @@ html_favicon = 'img/favicon.ico'
#html_file_suffix = None
#html_file_suffix = None
# Output file base name for HTML help builder.
# Output file base name for HTML help builder.
htmlhelp_basename
=
'
xbob_io_doc
'
htmlhelp_basename
=
'
xbob_io_
base_
doc
'
# -- Options for LaTeX output --------------------------------------------------
# -- Options for LaTeX output --------------------------------------------------
...
@@ -201,7 +201,7 @@ latex_font_size = '10pt'
...
@@ -201,7 +201,7 @@ latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents
=
[
latex_documents
=
[
(
'
index
'
,
'
xbob_io.tex
'
,
u
'
Bob I/O Routines
'
,
(
'
index
'
,
'
xbob_io
_base
.tex
'
,
u
'
Core
Bob I/O Routines
'
,
u
'
Biometrics Group, Idiap Research Institute
'
,
'
manual
'
),
u
'
Biometrics Group, Idiap Research Institute
'
,
'
manual
'
),
]
]
...
@@ -241,7 +241,7 @@ rst_epilog = """
...
@@ -241,7 +241,7 @@ rst_epilog = """
# One entry per manual page. List of tuples
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
# (source start file, name, description, authors, manual section).
man_pages
=
[
man_pages
=
[
(
'
index
'
,
'
xbob_io
'
,
u
'
Bob I/O Routines Documentation
'
,
[
u
'
Idiap Research Institute
'
],
1
)
(
'
index
'
,
'
xbob_io
_base
'
,
u
'
Core
Bob I/O Routines Documentation
'
,
[
u
'
Idiap Research Institute
'
],
1
)
]
]
# Default processing flags for sphinx
# Default processing flags for sphinx
...
...
This diff is collapsed.
Click to expand it.
doc/guide.rst
+
79
−
73
View file @
22e754c7
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
.. testsetup:: iotest
.. testsetup:: iotest
import numpy
import numpy
import xbob.io
import xbob.io
.base
============
============
User Guide
User Guide
...
@@ -25,7 +25,7 @@ and |project| loaded into the `Python`_ environment.
...
@@ -25,7 +25,7 @@ and |project| loaded into the `Python`_ environment.
.. testsetup:: *
.. testsetup:: *
import numpy
import numpy
import xbob.io
import xbob.io
.base
import tempfile
import tempfile
import os
import os
...
@@ -49,8 +49,8 @@ an `HDF5`_ file. These are supplied by the `HDF5`_ project.
...
@@ -49,8 +49,8 @@ an `HDF5`_ file. These are supplied by the `HDF5`_ project.
``h5diff``
``h5diff``
Finds the differences between HDF5 files.
Finds the differences between HDF5 files.
I/O operations using the class `xbob.io.HDF5File`
I/O operations using the class `xbob.io.
base.
HDF5File`
-------------------------------------------------
-------------------------------------------------
-----
Writing operations
Writing operations
------------------
------------------
...
@@ -62,7 +62,7 @@ floats.
...
@@ -62,7 +62,7 @@ floats.
>>> an_integer = 5
>>> an_integer = 5
>>> a_float = 3.1416
>>> a_float = 3.1416
>>> f = xbob.io.HDF5File('testfile1.hdf5', 'w')
>>> f = xbob.io.
base.
HDF5File('testfile1.hdf5', 'w')
>>> f.set('my_integer', an_integer)
>>> f.set('my_integer', an_integer)
>>> f.set('my_float', a_float)
>>> f.set('my_float', a_float)
>>> del f
>>> del f
...
@@ -113,7 +113,7 @@ in a different directory like this:
...
@@ -113,7 +113,7 @@ in a different directory like this:
.. doctest::
.. doctest::
>>> f = xbob.io.HDF5File('testfile1.hdf5', 'a')
>>> f = xbob.io.
base.
HDF5File('testfile1.hdf5', 'a')
>>> f.create_group('/test')
>>> f.create_group('/test')
>>> f.set('/test/my_float', numpy.float32(6.28))
>>> f.set('/test/my_float', numpy.float32(6.28))
>>> del f
>>> del f
...
@@ -149,7 +149,7 @@ as it was defined.
...
@@ -149,7 +149,7 @@ as it was defined.
If you need to place lots of variables in a subfolder, it may be better to
If you need to place lots of variables in a subfolder, it may be better to
setup the prefix folder before starting the writing operations on the
setup the prefix folder before starting the writing operations on the
:py:class:`xbob.io.HDF5File` object. You can do this using the method
:py:class:`xbob.io.
base.
HDF5File` object. You can do this using the method
:py:meth:`HDF5File.cd`. Look up its help for more information and usage
:py:meth:`HDF5File.cd`. Look up its help for more information and usage
instructions.
instructions.
...
@@ -160,7 +160,7 @@ is an example:
...
@@ -160,7 +160,7 @@ is an example:
.. doctest::
.. doctest::
>>> A = numpy.array(range(4), 'int8').reshape(2,2)
>>> A = numpy.array(range(4), 'int8').reshape(2,2)
>>> f = xbob.io.HDF5File('testfile1.hdf5', 'a')
>>> f = xbob.io.
base.
HDF5File('testfile1.hdf5', 'a')
>>> f.set('my_array', A)
>>> f.set('my_array', A)
>>> del f
>>> del f
...
@@ -180,22 +180,23 @@ The result of running ``h5dump`` on the file ``testfile3.hdf5`` should be:
...
@@ -180,22 +180,23 @@ The result of running ``h5dump`` on the file ``testfile3.hdf5`` should be:
...
...
You don't need to limit yourself to single variables, you can also save lists
You don't need to limit yourself to single variables, you can also save lists
of scalars and arrays using the function :py:meth:`xbob.io.HDF5.append`
instead
of scalars and arrays using the function :py:meth:`xbob.io.
base.
HDF5.append`
of :py:meth:`xbob.io.HDF5.set`.
instead
of :py:meth:`xbob.io.
base.
HDF5.set`.
Reading operations
Reading operations
------------------
------------------
Reading data from a file that you just wrote to is just as easy. For this task
Reading data from a file that you just wrote to is just as easy. For this task
you should use :py:meth:`xbob.io.HDF5File.read`. The read method will read all
you should use :py:meth:`xbob.io.base.HDF5File.read`. The read method will read
the contents of the variable pointed to by the given path. This is the normal
all the contents of the variable pointed to by the given path. This is the
way to read a variable you have written with :py:meth:`xbob.io.HDF5File.set`. If
normal way to read a variable you have written with
you decided to create a list of scalar or arrays, the way to read that up would
:py:meth:`xbob.io.base.HDF5File.set`. If you decided to create a list of scalar
be using :py:meth:`xbob.io.HDF5File.lread` instead. Here is an example:
or arrays, the way to read that up would be using
:py:meth:`xbob.io.base.HDF5File.lread` instead. Here is an example:
.. doctest::
.. doctest::
>>> f = xbob.io.HDF5File('testfile1.hdf5') #read only
>>> f = xbob.io.
base.
HDF5File('testfile1.hdf5') #read only
>>> f.read('my_integer') #reads integer
>>> f.read('my_integer') #reads integer
5
5
>>> print(f.read('my_array')) # reads the array
>>> print(f.read('my_array')) # reads the array
...
@@ -204,13 +205,13 @@ be using :py:meth:`xbob.io.HDF5File.lread` instead. Here is an example:
...
@@ -204,13 +205,13 @@ be using :py:meth:`xbob.io.HDF5File.lread` instead. Here is an example:
>>> del f
>>> del f
Now let's look at an example where we have used
Now let's look at an example where we have used
:py:meth:`xbob.io.HDF5File.append` instead of
:py:meth:`xbob.io.HDF5File.set`
:py:meth:`xbob.io.
base.
HDF5File.append` instead of
to write data to a file. That is normally
the case when you write lists of
:py:meth:`xbob.io.base.HDF5File.set`
to write data to a file. That is normally
variables to a dataset.
the case when you write lists of
variables to a dataset.
.. doctest::
.. doctest::
>>> f = xbob.io.HDF5File('testfile2.hdf5', 'w')
>>> f = xbob.io.
base.
HDF5File('testfile2.hdf5', 'w')
>>> f.append('arrayset', numpy.array(range(10), 'float64'))
>>> f.append('arrayset', numpy.array(range(10), 'float64'))
>>> f.append('arrayset', 2*numpy.array(range(10), 'float64'))
>>> f.append('arrayset', 2*numpy.array(range(10), 'float64'))
>>> f.append('arrayset', 3*numpy.array(range(10), 'float64'))
>>> f.append('arrayset', 3*numpy.array(range(10), 'float64'))
...
@@ -245,19 +246,21 @@ shot:
...
@@ -245,19 +246,21 @@ shot:
.. doctest::
.. doctest::
>>> f = xbob.io.HDF5File('testfile2.hdf5')
>>> f = xbob.io.
base.
HDF5File('testfile2.hdf5')
>>> print(f.read('arrayset'))
>>> print(f.read('arrayset'))
[[ 0. 1. 2. 3. 4. 5. 6. 7. 8. 9.]
[[ 0. 1. 2. 3. 4. 5. 6. 7. 8. 9.]
[ 0. 2. 4. 6. 8. 10. 12. 14. 16. 18.]
[ 0. 2. 4. 6. 8. 10. 12. 14. 16. 18.]
[ 0. 3. 6. 9. 12. 15. 18. 21. 24. 27.]]
[ 0. 3. 6. 9. 12. 15. 18. 21. 24. 27.]]
As you can see, the only difference between :py:meth:`xbob.io.HDF5File.read`
As you can see, the only difference between
and :py:meth:`xbob.io.HDF5File.lread` is on how |project| considers the
:py:meth:`xbob.io.base.HDF5File.read` and
:py:meth:`xbob.io.base.HDF5File.lread` is on how |project| considers the
available data (as a single array with N dimensions or as a set of arrays with
available data (as a single array with N dimensions or as a set of arrays with
N-1 dimensions). In the first example, you would have also been able to read
N-1 dimensions). In the first example, you would have also been able to read
the variable `my_array` as an arrayset using :py:meth:`xbob.io.HDF5File.lread`
the variable `my_array` as an arrayset using
instead of :py:meth:`xbob.io.HDF5File.read`. In this case, each position
:py:meth:`xbob.io.base.HDF5File.lread` instead of
readout would return a 1D uint8 array instead of a 2D array.
:py:meth:`xbob.io.base.HDF5File.read`. In this case, each position readout
would return a 1D uint8 array instead of a 2D array.
Array interfaces
Array interfaces
----------------
----------------
...
@@ -268,25 +271,27 @@ other software frameworks, debug your data or just implement your own classes
...
@@ -268,25 +271,27 @@ other software frameworks, debug your data or just implement your own classes
that can serialize and de-serialize from HDF5 file containers. In |project|,
that can serialize and de-serialize from HDF5 file containers. In |project|,
most of the time you will be working with :py:class:`numpy.ndarrays`\s. In
most of the time you will be working with :py:class:`numpy.ndarrays`\s. In
special situations though, you may be asked to handle
special situations though, you may be asked to handle
:py:class:`xbob.io.File`\s. :py:class:`xbob.io.File` objects create a
:py:class:`xbob.io.
base.
File`\s. :py:class:`xbob.io.
base.
File` objects create a
transparent connection between C++ (`Blitz++`_) / Python (`NumPy`_) arrays and
transparent connection between C++ (`Blitz++`_) / Python (`NumPy`_) arrays and
file access. You specify the filename from which you want to input data and
file access. You specify the filename from which you want to input data and
the :py:class:`xbob.io.File` object decides what is the best codec to be
used
the :py:class:`xbob.io.
base.
File` object decides what is the best codec to be
(from the extension) and how to read the data back into your array.
used
(from the extension) and how to read the data back into your array.
To create an :py:class:`xbob.io.File` from a file path, just do the following:
To create an :py:class:`xbob.io.base.File` from a file path, just do the
following:
.. doctest::
.. doctest::
>>> a = xbob.io.File('testfile2.hdf5', 'r')
>>> a = xbob.io.
base.
File('testfile2.hdf5', 'r')
>>> a.filename
>>> a.filename
'testfile2.hdf5'
'testfile2.hdf5'
:py:class:`xbob.io.File`\s simulate containers for :py:class:`numpy.ndarray`\s,
:py:class:`xbob.io.base.File`\s simulate containers for
transparently accessing the file data when requested. Note, however, that when
:py:class:`numpy.ndarray`\s, transparently accessing the file data when
you instantiate an :py:class:`xbob.io.File` it does **not** load the file
requested. Note, however, that when you instantiate an
contents into memory. It waits until you emit another explicit instruction to
:py:class:`xbob.io.base.File` it does **not** load the file contents into
do so. We do this with the :py:meth:`xbob.io.File.read` method:
memory. It waits until you emit another explicit instruction to do so. We do
this with the :py:meth:`xbob.io.base.File.read` method:
.. doctest::
.. doctest::
...
@@ -296,44 +301,44 @@ do so. We do this with the :py:meth:`xbob.io.File.read` method:
...
@@ -296,44 +301,44 @@ do so. We do this with the :py:meth:`xbob.io.File.read` method:
[ 0., 2., 4., 6., 8., 10., 12., 14., 16., 18.],
[ 0., 2., 4., 6., 8., 10., 12., 14., 16., 18.],
[ 0., 3., 6., 9., 12., 15., 18., 21., 24., 27.]])
[ 0., 3., 6., 9., 12., 15., 18., 21., 24., 27.]])
Every time you say :py:meth:`xbob.io.File.read`, the file contents will be
read
Every time you say :py:meth:`xbob.io.
base.
File.read`, the file contents will be
from the file and into a new array.
read
from the file and into a new array.
Saving arrays to the :py:class:`xbob.io.File` is as easy, just call the
Saving arrays to the :py:class:`xbob.io.
base.
File` is as easy, just call the
:py:meth:`xbob.io.File.write` method:
:py:meth:`xbob.io.
base.
File.write` method:
.. doctest::
.. doctest::
>>> f = xbob.io.File('copy1.hdf5', 'w')
>>> f = xbob.io.
base.
File('copy1.hdf5', 'w')
>>> f.write(array)
>>> f.write(array)
Numpy ndarray shortcuts
Numpy ndarray shortcuts
-----------------------
-----------------------
To just load an :py:class:`numpy.ndarray` in memory, you can use a short cut
To just load an :py:class:`numpy.ndarray` in memory, you can use a short cut
that lives at :py:func:`xbob.io.load`. With it, you don't have to go
through
that lives at :py:func:`xbob.io.
base.
load`. With it, you don't have to go
the :py:class:`xbob.io.File` container:
through
the :py:class:`xbob.io.
base.
File` container:
.. doctest::
.. doctest::
>>> t = xbob.io.load('testfile2.hdf5')
>>> t = xbob.io.
base.
load('testfile2.hdf5')
>>> t
>>> t
array([[ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9.],
array([[ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9.],
[ 0., 2., 4., 6., 8., 10., 12., 14., 16., 18.],
[ 0., 2., 4., 6., 8., 10., 12., 14., 16., 18.],
[ 0., 3., 6., 9., 12., 15., 18., 21., 24., 27.]])
[ 0., 3., 6., 9., 12., 15., 18., 21., 24., 27.]])
You can also directly save :py:class:`numpy.ndarray`\s without going
You can also directly save :py:class:`numpy.ndarray`\s without going
through
through
the :py:class:`xbob.io.Array` container:
the :py:class:`xbob.io.
base.
Array` container:
.. doctest::
.. doctest::
>>> xbob.io.save(t, 'copy2.hdf5')
>>> xbob.io.
base.
save(t, 'copy2.hdf5')
.. note::
.. note::
Under the hood, we still use the :py:class:`xbob.io.File` API to execute
Under the hood, we still use the :py:class:`xbob.io.
base.
File` API to execute
the read and write operations. Have a look at the manual section for
the read and write operations. Have a look at the manual section for
:py:mod:`xbob.io` for more details and other shortcuts available.
:py:mod:`xbob.io
.base
` for more details and other shortcuts available.
Reading and writing images
Reading and writing images
--------------------------
--------------------------
...
@@ -350,8 +355,8 @@ must be of type uint8 or uint16.
...
@@ -350,8 +355,8 @@ must be of type uint8 or uint16.
.. doctest::
.. doctest::
>>> my_image = numpy.random.random_integers(0,255,(3,256,256))
>>> my_image = numpy.random.random_integers(0,255,(3,256,256))
>>> xbob.io.save(my_image.astype('uint8'), 'testimage.jpg') # saving the image in jpeg format
>>> xbob.io.
base.
save(my_image.astype('uint8'), 'testimage.jpg') # saving the image in jpeg format
>>> my_image_copy = xbob.io.load('testimage.jpg')
>>> my_image_copy = xbob.io.
base.
load('testimage.jpg')
.. tip::
.. tip::
...
@@ -371,25 +376,25 @@ with images:
...
@@ -371,25 +376,25 @@ with images:
.. doctest::
.. doctest::
>>> my_video = numpy.random.random_integers(0,255,(30,3,256,256))
>>> my_video = numpy.random.random_integers(0,255,(30,3,256,256))
>>> xbob.io.save(my_video.astype('uint8'), 'testvideo.avi') # saving the video avi format with a default codec
>>> xbob.io.
base.
save(my_video.astype('uint8'), 'testvideo.avi') # saving the video avi format with a default codec
>>> my_video_copy = xbob.io.load('testvideo.avi')
>>> my_video_copy = xbob.io.
base.
load('testvideo.avi')
Video reading and writing is performed using an `FFmpeg`_ (or `libav`_ if
Video reading and writing is performed using an `FFmpeg`_ (or `libav`_ if
`FFmpeg`_ is not available) bridge. |project|'s :py:meth:`xbob.io.save`
method
`FFmpeg`_ is not available) bridge. |project|'s :py:meth:`xbob.io.
base.
save`
will allow you to choose the output format with the same extension
mechanism as
method
will allow you to choose the output format with the same extension
mentioned earlier. `FFmpeg`_ will then choose a default codec for
the format
mechanism as
mentioned earlier. `FFmpeg`_ will then choose a default codec for
and perform encoding. The output file can be as easily loaded using
the format
and perform encoding. The output file can be as easily loaded using
:py:meth:`xbob.io.load`.
:py:meth:`xbob.io.
base.
load`.
For finer control over the loading, saving, format and codecs used for a
For finer control over the loading, saving, format and codecs used for a
specific encoding or decoding operation, you must directly use either
specific encoding or decoding operation, you must directly use either
:py:class:`xbob.io.VideoReader` or :py:class:`xbob.io.VideoWriter`
classes. For
:py:class:`xbob.io.
base.
VideoReader` or :py:class:`xbob.io.
base.
VideoWriter`
example, it is possible to use
:py:class:`xbob.io.VideoReader` to read videos
classes. For
example, it is possible to use
frame by frame and avoid overloading your machine's memory. In the following
:py:class:`xbob.io.base.VideoReader` to read videos frame by frame and avoid
example you can see how to create a video, save it using the class
overloading your machine's memory. In the following example you can see how to
:py:class:`xbob.io.VideoWriter`
and load it again using the class
create a video, save it using the class
:py:class:`xbob.io.
base.
VideoWriter`
:py:class:`xbob.io.VideoReader`. The
created video will have 30 frames
and load it again using the class
:py:class:`xbob.io.
base.
VideoReader`. The
generated randomly.
created video will have 30 frames
generated randomly.
.. note::
.. note::
...
@@ -400,12 +405,12 @@ generated randomly.
...
@@ -400,12 +405,12 @@ generated randomly.
>>> width = 50; height = 50;
>>> width = 50; height = 50;
>>> framerate = 24
>>> framerate = 24
>>> outv = xbob.io.VideoWriter('testvideo.avi', height, width, framerate, codec='mpeg1video') # output video
>>> outv = xbob.io.
base.
VideoWriter('testvideo.avi', height, width, framerate, codec='mpeg1video') # output video
>>> for i in range(0, 30):
>>> for i in range(0, 30):
... newframe = (numpy.random.random_integers(0,255,(3,height,width)))
... newframe = (numpy.random.random_integers(0,255,(3,height,width)))
... outv.append(newframe.astype('uint8'))
... outv.append(newframe.astype('uint8'))
>>> outv.close()
>>> outv.close()
>>> input = xbob.io.VideoReader('testvideo.avi')
>>> input = xbob.io.
base.
VideoReader('testvideo.avi')
>>> input.number_of_frames
>>> input.number_of_frames
30
30
>>> inv = input.load()
>>> inv = input.load()
...
@@ -434,12 +439,13 @@ in version of |project| installed on your machine can be listed using the
...
@@ -434,12 +439,13 @@ in version of |project| installed on your machine can be listed using the
Loading and saving Matlab data
Loading and saving Matlab data
------------------------------
------------------------------
An alternative for saving data in ``.mat`` files using :py:meth:`xbob.io.save`,
An alternative for saving data in ``.mat`` files using
would be to save them as a `HDF5`_ file which then can be easily read in
:py:meth:`xbob.io.base.save`, would be to save them as a `HDF5`_ file which
Matlab. Similarly, instead of having to read ``.mat`` files using
then can be easily read in Matlab. Similarly, instead of having to read
:py:meth:`xbob.io.load`, you can save your Matlab data in `HDF5`_ format, which
``.mat`` files using :py:meth:`xbob.io.base.load`, you can save your Matlab
then can be easily read from |project|. Detailed instructions about how to save
data in `HDF5`_ format, which then can be easily read from |project|. Detailed
and load data from Matlab to and from `HDF5`_ files can be found `here`__.
instructions about how to save and load data from Matlab to and from `HDF5`_
files can be found `here`__.
.. _audiosignal:
.. _audiosignal:
...
...
This diff is collapsed.
Click to expand it.
doc/index.rst
+
5
−
5
View file @
22e754c7
.. vim: set fileencoding=utf-8 :
.. vim: set fileencoding=utf-8 :
.. Andre Anjos <andre.anjos@idiap.ch>
.. Andre Anjos <andre.anjos@idiap.ch>
..
Mon 4 Nov 20:58:04
201
3
CET
..
Wed 14 May 15:22:33
201
4
CE
S
T
..
..
.. Copyright (C) 2011-201
3
Idiap Research Institute, Martigny, Switzerland
.. Copyright (C) 2011-201
4
Idiap Research Institute, Martigny, Switzerland
====================
====================
=====
Bob's I/O Routines
Bob's
Core
I/O Routines
====================
====================
=====
.. todolist::
.. todolist::
...
...
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