* distance channel: distance; possible choices= 0,1,2,3; default :3
%% Cell type:markdown id: tags:
The scenes must be of h x w 4 x 1 where h is the hight of image and w the width. The third dimension is needed for the different channels. We have R, G, B, D. Where R is the red, G is the green, B is the blue and D is the distance channel. Here is an example for how to initialize a random scene with 180 x 180 dimension.
For an example on how to get a rendered scene please refer to the other tutorials.
%% Cell type:code id: tags:
``` python
importnumpyasnp
scene=np.random.random((180,360,4,1))
```
%% Cell type:markdown id: tags:
To set up the viewing direction with a 180 x 180 scene, the following can be done:
The velocity contains the velocity of the current position as well as the acceleration (difference of velocity to the old position). The velocity must be a pandas dataframe with a multiindex, where the angles index must contain the convention to be used.
The conventions that can be used are:
'sxyz', 'sxyx', 'sxzy','sxzx', 'syzx', 'syzy',
'syxz', 'syxy', 'szxy', 'szxz', 'szyx', 'szyz',
'rzyx', 'rxyx', 'ryzx', 'rxzx', 'rxzy', 'ryzy',
'rzxy', 'ryxy', 'ryxz', 'rzxz', 'rxyz', 'rzyz'
Here is an example on how to initilize it. In this example the bee is rotating around the x axis (yaw) and stays constant otherwise.
%% Cell type:code id: tags:
``` python
importpandasaspd
# only the yaw is changes aka the bee is tilted up
positions=np.array([[-20,-20,2.6,1.57079633,0,0],
[-20,-20,2.6,1.90079633,0,0]])
x=positions[0,0]
y=positions[0,1]
z=positions[0,2]
yaw=positions[0,3]
pitch=positions[0,4]
roll=positions[0,5]
dx=positions[1,0]-positions[0,0]
dy=positions[1,1]-positions[0,1]
dz=positions[1,2]-positions[0,2]
dyaw=positions[1,3]-positions[0,3]
dpitch=positions[1,4]-positions[0,4]
droll=positions[1,5]-positions[0,5]
tuples=[('location','x'),('location','y'),
('location','z'),('location','dx'),
('location','dy'),('location','dz'),
('rxyz','alpha_0'),('rxyz','alpha_1'),
('rxyz','alpha_2'),('rxyz','dalpha_0'),
('rxyz','dalpha_1'),('rxyz','dalpha_2')]
index=pd.MultiIndex.from_tuples(tuples,
names=['position','orientation'])
velocity=pd.Series(index=index)
velocity['location']['x']=x
velocity['location']['y']=y
velocity['location']['z']=z
velocity['rxyz']['alpha_0']=yaw
velocity['rxyz']['alpha_1']=pitch
velocity['rxyz']['alpha_2']=roll
velocity['location']['dx']=dx
velocity['location']['dy']=dy
velocity['location']['dz']=dz
velocity['rxyz']['dalpha_0']=dyaw
velocity['rxyz']['dalpha_1']=dpitch
velocity['rxyz']['dalpha_2']=droll
```
%% Cell type:markdown id: tags:
So then the optic flow function can be called as follows: