Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
navipy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Looking for advice? Join the
Matrix channel for GitLab users in Bielefeld
!
Show more breadcrumbs
Olivier Bertrand
navipy
Commits
21c0c226
Commit
21c0c226
authored
6 years ago
by
Olivier Bertrand
Browse files
Options
Downloads
Patches
Plain Diff
Add Image rotation difference function as in Zeil 2004
parent
f781a3c6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
navipy/comparing/__init__.py
+3
-0
3 additions, 0 deletions
navipy/comparing/__init__.py
navipy/models/hafner_2000.py
+3
-3
3 additions, 3 deletions
navipy/models/hafner_2000.py
navipy/models/irdf_2003.py
+79
-0
79 additions, 0 deletions
navipy/models/irdf_2003.py
with
85 additions
and
3 deletions
navipy/comparing/__init__.py
+
3
−
0
View file @
21c0c226
...
@@ -80,6 +80,9 @@ the current and memorised place code.
...
@@ -80,6 +80,9 @@ the current and memorised place code.
should be image based
'
)
should be image based
'
)
check_scene
(
current
)
check_scene
(
current
)
check_scene
(
memory
)
check_scene
(
memory
)
# ridf is a NxM matrix,
# because one value per azimuth (N) and n values per channel
# (M)
ridf
=
np
.
zeros
((
current
.
shape
[
1
],
current
.
shape
[
2
]))
ridf
=
np
.
zeros
((
current
.
shape
[
1
],
current
.
shape
[
2
]))
for
azimuth_i
in
range
(
0
,
current
.
shape
[
1
]):
for
azimuth_i
in
range
(
0
,
current
.
shape
[
1
]):
rot_im
=
np
.
roll
(
current
,
azimuth_i
,
axis
=
1
)
rot_im
=
np
.
roll
(
current
,
azimuth_i
,
axis
=
1
)
...
...
This diff is collapsed.
Click to expand it.
navipy/models/hafner_2000.py
+
3
−
3
View file @
21c0c226
...
@@ -18,12 +18,12 @@ def processing(scene, viewing_directions, channel):
...
@@ -18,12 +18,12 @@ def processing(scene, viewing_directions, channel):
* Müller et al. 2018
* Müller et al. 2018
* Basten and Mallot 2010
* Basten and Mallot 2010
refer as COMANV in :
refer as COMANV in :
* Haf
t
er 2000,
* Haf
n
er 2000,
* Bertrand 2015
* Bertrand 2015
center of mass of average nearness vector
center of mass of average nearness vector
"""
"""
# Invert distance to nearness
# Invert distance to nearness
scene
[...,
3
,
:]
=
1
/
scene
[...,
3
,
:]
scene
[...,
3
,
:]
=
1
/
scene
[...,
3
,
:]
# Calculate the skyline
# Calculate the skyline
scene
=
skyline
(
scene
)
scene
=
skyline
(
scene
)
# skyline viewing direction
# skyline viewing direction
...
@@ -38,7 +38,7 @@ def comparing(current, memory):
...
@@ -38,7 +38,7 @@ def comparing(current, memory):
homing vector = current vector - memory vector
homing vector = current vector - memory vector
"""
"""
return
current
-
memory
return
current
-
memory
class
ASVBrain
(
Brain
):
class
ASVBrain
(
Brain
):
...
...
This diff is collapsed.
Click to expand it.
navipy/models/irdf_2003.py
0 → 100644
+
79
−
0
View file @
21c0c226
from
navipy
import
Brain
from
navipy.comparing
import
rot_imagediff
import
pandas
as
pd
import
numpy
as
np
from
navipy.scene
import
__spherical_indeces__
from
navipy.maths.coordinates
import
spherical_to_cartesian
# 0) Define a class heriting from Brain
def
processing
(
scene
,
channel
):
"""
Return the image difference
* inverse of distance (i.e. distance -> nearness)
"""
# Invert distance to nearness
scene
[...,
3
,
:]
=
1
/
scene
[...,
3
,
:]
return
scene
[...,
channel
,
:]
def
comparing
(
current
,
memory
,
viewing_directions
):
"""
Calculate homing vector with irdf
irdf: Image rotation difference function
The image difference is root mean square
Used in:
* Zeil, J., Hofmann, M., & Chahl, J. (2003).
\
Catchment Areas of Panoramic Snapshots in Outdoor Scenes.
* Baddeley, B., Graham, P., Husbands, P., & Philippides, A. (2012).
\
A Model of Ant Route Navigation Driven by Scene Familiarity.
* Ardin, P., Peng, F., Mangan, M., Lagogiannis, K., & Webb, B. (2016).
\
Using an Insect Mushroom Body Circuit to Encode Route
\
Memory in Complex Natural Environments.
"""
if
(
current
.
shape
[
2
]
!=
1
)
or
(
memory
.
shape
[
2
]
!=
1
):
msg
=
'
Current view {} and the memory {}
\n
'
msg
+=
'
should be a NxMx1x1 matrix
'
msg
=
msg
.
format
(
current
.
shape
,
memory
.
shape
)
raise
NameError
(
msg
)
irdf
=
rot_imagediff
(
current
,
memory
)
# [..., 0] because processing
# select one channel, and therefore
# irdf should is only a Nx1 matrix
idx
=
np
.
argmin
(
irdf
[...,
0
])
minval
=
np
.
min
(
irdf
[...,
0
])
direction
=
viewing_directions
[
idx
,
__spherical_indeces__
[
'
azimuth
'
]]
homing_vect
=
spherical_to_cartesian
(
elevation
=
0
,
azimuth
=
direction
,
radius
=
minval
)
return
homing_vect
class
IRDFBrain
(
Brain
):
def
__init__
(
self
,
memory
,
renderer
=
None
,
channel
=
0
):
Brain
.
__init__
(
self
,
renderer
=
renderer
)
# Init memory
self
.
channel
=
channel
self
.
memory
=
memory
def
velocity
(
self
):
index
=
self
.
posorient
.
index
convention
=
index
.
levels
[
0
][
-
1
]
current
=
processing
(
self
.
vision
.
scene
,
self
.
channel
)
homing_vector
=
comparing
(
current
,
self
.
memory
,
self
.
vision
.
viewing_directions
,
)
homing_vector
=
np
.
squeeze
(
homing_vector
)
indeces
=
[(
'
location
'
,
'
dx
'
),
(
'
location
'
,
'
dy
'
),
(
'
location
'
,
'
dz
'
),
(
convention
,
'
dalpha_0
'
),
(
convention
,
'
dalpha_1
'
),
(
convention
,
'
dalpha_2
'
)]
velocity
=
pd
.
Series
(
data
=
0
,
index
=
pd
.
MultiIndex
.
from_tuples
(
indeces
))
velocity
.
loc
[
'
location
'
]
=
homing_vector
return
velocity
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