Skip to content
Snippets Groups Projects
Commit 2947bfce authored by Olivier J.N. Bertrand's avatar Olivier J.N. Bertrand
Browse files

Update the doc of database

parent 97f320f1
No related branches found
No related tags found
No related merge requests found
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from navipy.database import DataBaseLoad
import pkg_resources
# 1) Connect to the database
mydb_filename = pkg_resources.resource_filename(
'navipy', 'resources/database.db')
mydb = DataBaseLoad(mydb_filename)
posorients = mydb.posorients
posorients.head(n=5)
...@@ -2,11 +2,12 @@ import pandas as pd ...@@ -2,11 +2,12 @@ import pandas as pd
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from navipy.database import DataBaseLoad from navipy.database import DataBaseLoad
import os import pkg_resources
# 1) Connect to the database # 1) Connect to the database
mydb_filename = os.path.abspath('../database.db') mydb_filename = pkg_resources.resource_filename(
'navipy', 'resources/database.db')
mydb = DataBaseLoad(mydb_filename) mydb = DataBaseLoad(mydb_filename)
# 2) Define the position-orinetation at which # 2) Define the position-orinetation at which
# we want the image # we want the image
...@@ -19,7 +20,8 @@ posorient.alpha_0 = np.pi / 2 ...@@ -19,7 +20,8 @@ posorient.alpha_0 = np.pi / 2
posorient.alpha_1 = 0 posorient.alpha_1 = 0
posorient.alpha_2 = 0 posorient.alpha_2 = 0
# 3) Load the image # 3) Load the image
image = mydb.read_image(posorient=posorient) image = mydb.scene(posorient=posorient)
image = image[...,0]
# 4) plot the image # 4) plot the image
to_plot_im = image[:, :, :3] to_plot_im = image[:, :, :3]
to_plot_im -= to_plot_im.min() to_plot_im -= to_plot_im.min()
......
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from navipy.database import DataBaseLoad from navipy.database import DataBaseLoad
import os import pkg_resources
# 1) Connect to the database # 1) Connect to the database
mydb_filename = os.path.abspath('../database.db') mydb_filename = pkg_resources.resource_filename(
'navipy', 'resources/database.db')
mydb = DataBaseLoad(mydb_filename) mydb = DataBaseLoad(mydb_filename)
# 2) Define the position-orinetation at which # 2) Define the position-orinetation at which
# we want the image # we want the image
rowid = 12 rowid = 12
# 3) Load the image # 3) Load the image
image = mydb.read_image(rowid=rowid) image = mydb.scene(rowid=rowid)
image = image[...,0]
# 4) plot the image # 4) plot the image
to_plot_im = image[:, :, :3] to_plot_im = image[:, :, :3]
to_plot_im -= to_plot_im.min() to_plot_im -= to_plot_im.min()
......
Moving Moving
====== ======
Moving on a grid .. automodule:: navipy.moving
----------------
Moving between grid points .. autoclass:: navipy.moving.agent.CyberBeeAgent
-------------------------- :members:
Interpolation of neighbouring images
.. autoclass:: navipy.moving.agent.GridAgent
:members:
.. autoclass:: navipy.moving.agent.GraphAgent
:members:
...@@ -13,11 +13,8 @@ are normalised, so to use the full coding range. ...@@ -13,11 +13,8 @@ are normalised, so to use the full coding range.
How to load a database How to load a database
---------------------- ----------------------
.. code-block:: python .. literalinclude:: example/database/get_posorients.py
:lines: 11
from database import DataBaseLoad
mydb_filename = 'database.db'
mydb = DataBaseLoad(mydb_filename)
How to load all position-orientation How to load all position-orientation
------------------------------------ ------------------------------------
...@@ -28,10 +25,10 @@ situation, it may be usefull to know all \ ...@@ -28,10 +25,10 @@ situation, it may be usefull to know all \
position-orientation in the database. More technically \ position-orientation in the database. More technically \
speaking, loading the full table of position-orientaiton. speaking, loading the full table of position-orientaiton.
.. code-block:: python .. literalinclude:: example/database/get_posorients.py
:lines: 12-13
posorients = mydb.get_posorients() .. plot:: example/database/get_posorients.py
posorients.head()
How to load an image How to load an image
-------------------- --------------------
...@@ -44,17 +41,8 @@ the position-orientation can be given. The DataBaseLoader will \ ...@@ -44,17 +41,8 @@ the position-orientation can be given. The DataBaseLoader will \
look if this position-orientation has been rendered. If it is \ look if this position-orientation has been rendered. If it is \
the case, the image will be returned. the case, the image will be returned.
.. code-block:: python .. literalinclude:: example/database/load_image_posorient.py
:lines: 14-23
posorient = pd.Series(index=['x', 'y', 'z',
'alpha_0', 'alpha_1', 'alpha_2'])
posorient.x = -0.6
posorient.y = -7.2
posorient.z = 2.35
posorient.alpha_0 = np.pi / 2
posorient.alpha_1 = 0
posorient.alpha_2 = 0
image = mydb.read_image(posorient=posorient)
.. plot:: example/database/load_image_posorient.py .. plot:: example/database/load_image_posorient.py
...@@ -65,15 +53,12 @@ Indeed each position-orientation can be identified by a unique row \ ...@@ -65,15 +53,12 @@ Indeed each position-orientation can be identified by a unique row \
number. This number is consistant through the entire database. Thus, \ number. This number is consistant through the entire database. Thus, \
an image can be loaded by providing the row number. an image can be loaded by providing the row number.
.. code-block:: python .. literalinclude:: example/database/load_image_rowid.py
:lines: 13-15
rowid = 1000
image = mydb.read_image(rowid=rowid)
.. plot:: example/database/load_image_rowid.py .. plot:: example/database/load_image_rowid.py
.. todo: channels as part of database .. todo: channels as part of database
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment