made a few fixes
This commit is contained in:
parent
67123bb970
commit
ec2a98b843
5 changed files with 52 additions and 30 deletions
|
@ -1,7 +1,7 @@
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
|
|
||||||
import os, sys
|
import os, sys
|
||||||
import seaborn
|
# import seaborn
|
||||||
from pylab import rcParams
|
from pylab import rcParams
|
||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
|
@ -204,10 +204,10 @@ class Parallax2Dto3DMapping(Experiment):
|
||||||
aae_3ds_aae.append((AAE, STD))
|
aae_3ds_aae.append((AAE, STD))
|
||||||
aae_3ds_phe.append((PHE, PHE_STD))
|
aae_3ds_phe.append((PHE, PHE_STD))
|
||||||
|
|
||||||
|
|
||||||
# results only contains AAE
|
# results only contains AAE
|
||||||
results.append([np.mean(np.array(aae_2ds_aae)[:,0]), np.mean(np.array(aae_3ds_aae)[:,0]), np.mean(np.array(aae_3D3Ds)[:,0])])
|
results.append([np.mean(np.array(aae_2ds_aae)[:,0]), np.mean(np.array(aae_3ds_aae)[:,0]), np.mean(np.array(aae_3D3Ds)[:,0])])
|
||||||
results_std.append([np.std(np.array(aae_2ds_aae)[:,0]), np.std(np.array(aae_3ds_aae)[:,0]), np.std(np.array(aae_3D3Ds)[:,0])])
|
results_std.append([np.std(np.array(aae_2ds_aae)[:,0]), np.std(np.array(aae_3ds_aae)[:,0]), np.std(np.array(aae_3D3Ds)[:,0])])
|
||||||
|
|
||||||
######################################################################################################
|
######################################################################################################
|
||||||
# plot code based on EffectNumberofClusters.py
|
# plot code based on EffectNumberofClusters.py
|
||||||
mean2D2D = [res[0] for res in results]
|
mean2D2D = [res[0] for res in results]
|
||||||
|
@ -272,6 +272,7 @@ class Parallax2Dto3DMapping(Experiment):
|
||||||
plt.subplots_adjust(left=left, bottom=bottom, right=right, top=top, wspace=wspace, hspace=hspace)
|
plt.subplots_adjust(left=left, bottom=bottom, right=right, top=top, wspace=wspace, hspace=hspace)
|
||||||
plt.show()
|
plt.show()
|
||||||
######################################################################################################
|
######################################################################################################
|
||||||
|
self.sim = sim
|
||||||
|
|
||||||
class Parallax3Dto3DMapping(Experiment): # GT pupil pose instead of estimating the pose
|
class Parallax3Dto3DMapping(Experiment): # GT pupil pose instead of estimating the pose
|
||||||
def __run__(self):
|
def __run__(self):
|
||||||
|
|
|
@ -8,9 +8,10 @@ from time import time
|
||||||
from geom import getSphericalCoords, getAngularDiff
|
from geom import getSphericalCoords, getAngularDiff
|
||||||
from recording.tracker import Marker
|
from recording.tracker import Marker
|
||||||
|
|
||||||
try:
|
# try:
|
||||||
from visual import vector as v
|
# from visual import vector as v
|
||||||
except ImportError:
|
# except ImportError:
|
||||||
|
# from vector import Vector as v
|
||||||
from vector import Vector as v
|
from vector import Vector as v
|
||||||
|
|
||||||
DATA_DIR = './recording/data/'
|
DATA_DIR = './recording/data/'
|
||||||
|
|
42
code/sim.py
42
code/sim.py
|
@ -9,19 +9,25 @@ simply run the experiment with no visualization to get the data.
|
||||||
However, you can as well visualize the environment after the simulation
|
However, you can as well visualize the environment after the simulation
|
||||||
environment is set up and you ran the experiment. in order to do so,
|
environment is set up and you ran the experiment. in order to do so,
|
||||||
after you have a GazeSimulation object, simply call visualize() method on it.
|
after you have a GazeSimulation object, simply call visualize() method on it.
|
||||||
|
(notice that you need to disable plotting code so you can visualize and manipulate
|
||||||
|
the visualization otherwise after closing the plots the app stops)
|
||||||
'''
|
'''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import visual as vs
|
import visual as vs
|
||||||
from visual import vector as v
|
from visual import vector as vv
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from vector import Vector as vector
|
from vector import Vector as vv
|
||||||
|
# from vector import Vector as vector
|
||||||
|
pass
|
||||||
|
from vector import Vector as v
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2, cv
|
import cv2, cv
|
||||||
|
|
||||||
from geom import *
|
from geom import *
|
||||||
## Uncomment the following import if you want visualization
|
## Uncomment the following import if you want visualization
|
||||||
# from svis import Visualizable
|
from svis import Visualizable
|
||||||
|
|
||||||
# 2D to 2D calibration method from the pupil project
|
# 2D to 2D calibration method from the pupil project
|
||||||
from pupil.calibrate import get_map_from_cloud
|
from pupil.calibrate import get_map_from_cloud
|
||||||
|
@ -31,8 +37,8 @@ from pupil.calibrate import get_map_from_cloud
|
||||||
point_scale_factor = 10
|
point_scale_factor = 10
|
||||||
|
|
||||||
## Uncomment the following if you want visualization (and comment the line after)
|
## Uncomment the following if you want visualization (and comment the line after)
|
||||||
# class GazeSimulation(Visualizable):
|
class GazeSimulation(Visualizable):
|
||||||
class GazeSimulation:
|
# class GazeSimulation:
|
||||||
_log = True
|
_log = True
|
||||||
def log(self, msg):
|
def log(self, msg):
|
||||||
if self._log: print msg
|
if self._log: print msg
|
||||||
|
@ -531,6 +537,8 @@ class GazeSimulation:
|
||||||
calibration = False #
|
calibration = False #
|
||||||
display_test_point_rays = False #
|
display_test_point_rays = False #
|
||||||
display_active_gaze_point = False
|
display_active_gaze_point = False
|
||||||
|
display_calibration_point_rays = True
|
||||||
|
display_test_point_rays = True
|
||||||
rays = []
|
rays = []
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
|
@ -540,22 +548,26 @@ class GazeSimulation:
|
||||||
'''
|
'''
|
||||||
from util import drawAxes, drawLine
|
from util import drawAxes, drawLine
|
||||||
from svis import drawCameraFrame
|
from svis import drawCameraFrame
|
||||||
|
|
||||||
|
# converts a vector object into a visual vector object
|
||||||
|
v_to_vv = lambda vec: vv(vec.x, vec.y, vec.z)
|
||||||
|
|
||||||
## World Axes
|
## World Axes
|
||||||
drawAxes(None, vs.color.white, 13, (0, 0, 0))
|
# drawAxes(None, vs.color.white, 13, (0, 0, 0))
|
||||||
## Eyeball component (outer sphere)
|
## Eyeball component (outer sphere)
|
||||||
eye_outer = vs.sphere(pos=self.sclera_pos,
|
eye_outer = vs.sphere(pos=v_to_vv(self.sclera_pos),
|
||||||
radius=self.sclera_radius,
|
radius=self.sclera_radius,
|
||||||
color=vs.color.red)
|
color=vs.color.red)
|
||||||
## Eyeball component (inner sphere)
|
## Eyeball component (inner sphere)
|
||||||
eye_inner = vs.sphere(pos=self.cornea_pos,
|
eye_inner = vs.sphere(pos=v_to_vv(self.cornea_pos),
|
||||||
radius = self.cornea_radius,
|
radius = self.cornea_radius,
|
||||||
color=vs.color.white)
|
color=vs.color.white)
|
||||||
self.recomputeEyeInner()
|
self.recomputeEyeInner()
|
||||||
eye_inner.pos = self.cornea_pos
|
eye_inner.pos = v_to_vv(self.cornea_pos)
|
||||||
|
|
||||||
## Pupil position
|
## Pupil position
|
||||||
if self.display_pupil_position:
|
if self.display_pupil_position:
|
||||||
vs.points(pos=[self.pupil_position], size=5, color=vs.color.black)
|
vs.points(pos=[v_to_vv(self.pupil_position)], size=5, color=vs.color.black)
|
||||||
## calibration points
|
## calibration points
|
||||||
if self.display_calibration_points:
|
if self.display_calibration_points:
|
||||||
vs.points(pos=self.calibration_points, size=10, color=vs.color.yellow)
|
vs.points(pos=self.calibration_points, size=10, color=vs.color.yellow)
|
||||||
|
@ -572,18 +584,18 @@ class GazeSimulation:
|
||||||
if self.display_calibration_point_rays:
|
if self.display_calibration_point_rays:
|
||||||
# Cast rays from scene camera towards calibration points
|
# Cast rays from scene camera towards calibration points
|
||||||
for point in self.calibration_points:
|
for point in self.calibration_points:
|
||||||
diff = vs.vector(point) - vs.vector(self.scene_camera.t)
|
diff = vv(point) - vv(self.scene_camera.t)
|
||||||
drawLine(None, vs.vector(self.scene_camera.t), diff.mag, diff.norm())
|
drawLine(None, vv(self.scene_camera.t), diff.mag, diff.norm())
|
||||||
# Display rays from scene camera towards test points
|
# Display rays from scene camera towards test points
|
||||||
if self.display_test_point_rays:
|
if self.display_test_point_rays:
|
||||||
# Cast rays from scene camera towards calibration points
|
# Cast rays from scene camera towards calibration points
|
||||||
for point in self.test_points:
|
for point in self.test_points:
|
||||||
diff = vs.vector(point) - vs.vector(self.scene_camera.t)
|
diff = vv(point) - vv(self.scene_camera.t)
|
||||||
drawLine(None, vs.vector(self.scene_camera.t), diff.mag, diff.norm())
|
drawLine(None, vv(self.scene_camera.t), diff.mag, diff.norm())
|
||||||
|
|
||||||
# active gaze point
|
# active gaze point
|
||||||
if self.display_active_gaze_point and self.active_gaze_point:
|
if self.display_active_gaze_point and self.active_gaze_point:
|
||||||
vs.points(pos=[self.active_gaze_point], size=10, color=vs.color.red)
|
vs.points(pos=[v_to_vv(self.active_gaze_point)], size=10, color=vs.color.red)
|
||||||
|
|
||||||
if self.tr_target_projections_3d:
|
if self.tr_target_projections_3d:
|
||||||
vs.points(pos=self.tr_target_projections_3d, size=7, color=vs.color.red)
|
vs.points(pos=self.tr_target_projections_3d, size=7, color=vs.color.red)
|
||||||
|
|
15
code/svis.py
15
code/svis.py
|
@ -3,24 +3,29 @@ This is the visualization backend for bare_sim module
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
import visual as vs
|
import visual as vs
|
||||||
from visual import vector as v
|
from visual import vector as vv
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
from vector import Vector as vv
|
||||||
|
# from vector import Vector as vector
|
||||||
|
pass
|
||||||
from vector import Vector as v
|
from vector import Vector as v
|
||||||
|
|
||||||
from geom import Camera
|
from geom import Camera
|
||||||
|
|
||||||
from util import drawAxes
|
from util import drawAxes
|
||||||
|
# converts a vector object into a visual vector object
|
||||||
|
v_to_vv = lambda vec: vv(vec.x, vec.y, vec.z)
|
||||||
|
|
||||||
def drawCameraFrame(cam): # create frame and draw its contents
|
def drawCameraFrame(cam): # create frame and draw its contents
|
||||||
c = v(cam.t)
|
c = v(cam.t)
|
||||||
cam.center = vs.sphere(pos=c,
|
cam.center = vs.sphere(pos=v_to_vv(c),
|
||||||
radius=Camera.default_radius,
|
radius=Camera.default_radius,
|
||||||
color=vs.color.green)
|
color=vs.color.green)
|
||||||
cam.dir = vs.arrow(pos=c,
|
cam.dir = vs.arrow(pos=v_to_vv(c),
|
||||||
axis=v(cam.direction) * cam.f,
|
axis=v_to_vv(v(cam.direction)) * cam.f,
|
||||||
shaftwidth=1.0)
|
shaftwidth=1.0)
|
||||||
# TODO: check for orientation of the camera, rotate plane accordingly
|
# TODO: check for orientation of the camera, rotate plane accordingly
|
||||||
cam.img_plane = vs.box(pos=c + cam.dir.axis,
|
cam.img_plane = vs.box(pos=v_to_vv(c) + v_to_vv(cam.dir.axis),
|
||||||
length=cam.image_width,
|
length=cam.image_width,
|
||||||
width=0.5,
|
width=0.5,
|
||||||
height=cam.image_width,
|
height=cam.image_width,
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
try:
|
try:
|
||||||
import visual as vs
|
import visual as vs
|
||||||
from visual import vector as v
|
from visual import vector as vv
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from vector import Vector as vector
|
from vector import Vector as vv
|
||||||
|
# from vector import Vector as vector
|
||||||
|
pass
|
||||||
|
from vector import Vector as v
|
||||||
|
|
||||||
import wx
|
import wx
|
||||||
|
|
||||||
|
@ -28,7 +31,7 @@ def drawLine(frame, position, length, direction, color = vs.color.white):
|
||||||
'''
|
'''
|
||||||
return vs.curve(
|
return vs.curve(
|
||||||
frame=frame,
|
frame=frame,
|
||||||
pos=[v(position), v(position)+v(direction).norm()*length],
|
pos=[vv(position), vv(position)+vv(direction).norm()*length],
|
||||||
color = color)
|
color = color)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue