"In this tutorial, you will learn to take advantage of navipy and the rendering modules (blender) to render what has been seen by the animal along its trajectory. \n",
"\n",
...
...
@@ -13,7 +13,9 @@
"* the environment (a blender file)\n",
"* the trajectory formatted for navipy (see 02-recording-animal-trajectory)\n",
"\n",
"## Ploting the position and orientation of the animal\n",
"## Along a trajectory\n",
"\n",
"### Ploting the position and orientation of the animal\n",
"\n",
"The trajectory of the animal can be plotted in different manners. Here we will look at two representations:\n",
"\n",
...
...
@@ -115,7 +117,7 @@
"source": [
"\n",
"\n",
"## Checking the position of the animal within the environment\n",
"### Checking the position of the animal within the environment\n",
"\n",
"Rendering a trajectory will take time, and thus we want to check - prior to rendering - the correctness of the animal within the environment. The best way to check, is to overlay the trajectory within the blender world, and by rotating the environment, one could look for: part of the trajectory crossing objects, a wrong height, etc... \n",
"\n",
...
...
@@ -133,7 +135,7 @@
"> along the trajectory and thus creating a 3D shaped. (Don't forget to enable rendering)\n",
"\n",
"\n",
"## Rendering the trajectory in a database\n",
"### Rendering the trajectory in a database\n",
"\n",
"Once we know that the trajectory is correctly placed within the environment, it is time to render along the trajectory. We, however, recommand to render only the first view frame of your trajectory first in order to check for the orientation. Indeed we only checked the position of the animal, but not its orientation. Navipy supports all 24 Euler convention, and also quaternion. You need to figure out which one you used. Sadly we did not find until now an easy way to do it... Having said that, if you \"only\" tracked the yaw of the animal, you can safely use the 'rzyx' convention, here alpha_0 of your trajectory correspond to the yaw of the animal and all other angles are set to 0. \n",
"\n",
...
...
@@ -151,7 +153,30 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Database to list of images\n",
"## On a grid\n",
"\n",
"In certain situation we want to have an image for every point on a rectangular and equally spaced grid.\n",
"here ```pathtomyworld.blend```, ```'pathtomytrajectory.csv'```, ```pathtodatabase.db```, ```pathtomyconfig.yaml``` are the path to your blender environment, to your trajectory, to the file to store the iamges, and to the configuration parameters (see for examples ```navipy/resources/configs```), respectively.\n",
"\n",
"\n",
"> Note that ```blendongrid```, ```blendalongtraj```, and other blend navipy functions can also generate a log of the steps in rendering, sometime useful for debugging. \n",
"> You enable the loging by adding the following options: ```--logfile='pathtolog.log' -vvv```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Database and images\n",
"\n",
"### Database to images\n",
"\n",
"The database store all position-orientation and images along the trajectory in a single file. On the one hand, it is convenient, because you always know at which position and in which orientation an image has been rendered. On the other hand, we can not easily visualise the images. \n",
In this tutorial, you will learn to take advantage of navipy and the rendering modules (blender) to render what has been seen by the animal along its trajectory.
To render along a trajectory, you will need to have:
* the environment (a blender file)
* the trajectory formatted for navipy (see 02-recording-animal-trajectory)
## Ploting the position and orientation of the animal
## Along a trajectory
### Ploting the position and orientation of the animal
The trajectory of the animal can be plotted in different manners. Here we will look at two representations:
* Timeseries
* Lollipop
### Timeseries
Plotting a trajectories along the time allows to visualize temporal dependencies between each component of the saccade. For example, flying insects engage in an active vision strategy containing saccades and intersaccades. By ploting the euler's angle along the time, one can observe a step like plot, i.e. a succesion of plateaus (interssacades) and quick change in the angle (saccade).
The positional and orientational components of the trajectories have different units (unit of distance and unit of angle, respectively). Therefore two different y-axis are necessary.
bpy.context.scene.frame_end = 7000 # Change the number of frames
bpy.context.scene.frame_current = 2
```
%% Cell type:markdown id: tags:
## Checking the position of the animal within the environment
### Checking the position of the animal within the environment
Rendering a trajectory will take time, and thus we want to check - prior to rendering - the correctness of the animal within the environment. The best way to check, is to overlay the trajectory within the blender world, and by rotating the environment, one could look for: part of the trajectory crossing objects, a wrong height, etc...
To overlay the trajectory within your blender environment you can use the following command:
here ```pathtomyworld.blend``` and ```'pathtomytrajectory.csv'``` are the path to your blender environment and your trajectory respectively.
> The overlayed trajectory will not be rendered, because it is a simple line and its rendering is disable. If you want
> to render the trajectory, you can bevel the trajectory with a circle for example. It will create an extrude with the circle
> along the trajectory and thus creating a 3D shaped. (Don't forget to enable rendering)
## Rendering the trajectory in a database
### Rendering the trajectory in a database
Once we know that the trajectory is correctly placed within the environment, it is time to render along the trajectory. We, however, recommand to render only the first view frame of your trajectory first in order to check for the orientation. Indeed we only checked the position of the animal, but not its orientation. Navipy supports all 24 Euler convention, and also quaternion. You need to figure out which one you used. Sadly we did not find until now an easy way to do it... Having said that, if you "only" tracked the yaw of the animal, you can safely use the 'rzyx' convention, here alpha_0 of your trajectory correspond to the yaw of the animal and all other angles are set to 0.
```bash
blendalongtraj --output-file='pathtodatabase.db'
--blenderworld='pathtomyworld.blend'
--trajectory='pathtomytrajectory.csv'
--config-file='pathtomyconfig.yaml'
```
here ```pathtomyworld.blend```, ```'pathtomytrajectory.csv'```, ```pathtodatabase.db```, ```pathtomyconfig.yaml``` are the path to your blender environment, to your trajectory, to the file to store the iamges, and to the configuration parameters (see for examples ```navipy/resources/configs```), respectively.
%% Cell type:markdown id: tags:
## Database to list of images
## On a grid
In certain situation we want to have an image for every point on a rectangular and equally spaced grid.
```bash
blendongrid --blender-world='pathtomyworld.blend'
--config-file='pathtomyconfig.yaml'
--output-file='pathtodatabase.db'
```
here ```pathtomyworld.blend```, ```'pathtomytrajectory.csv'```, ```pathtodatabase.db```, ```pathtomyconfig.yaml``` are the path to your blender environment, to your trajectory, to the file to store the iamges, and to the configuration parameters (see for examples ```navipy/resources/configs```), respectively.
> Note that ```blendongrid```, ```blendalongtraj```, and other blend navipy functions can also generate a log of the steps in rendering, sometime useful for debugging.
> You enable the loging by adding the following options: ```--logfile='pathtolog.log' -vvv```
%% Cell type:markdown id: tags:
## Database and images
### Database to images
The database store all position-orientation and images along the trajectory in a single file. On the one hand, it is convenient, because you always know at which position and in which orientation an image has been rendered. On the other hand, we can not easily visualise the images.
To convert the database into an image sequence or list, you can run the following script in a ipython notebook (Don't forget to change the variable ```database``` to the path of your trajectory
/home/bolirev/.virtualenvs/toolbox-navigation/lib/python3.6/site-packages/matplotlib/figure.py:457: UserWarning: matplotlib is currently using a non-GUI backend, so cannot show the figure
"matplotlib is currently using a non-GUI backend, "