made a few fixes

This commit is contained in:
mohsen-mansouryar 2016-04-29 00:14:51 +02:00
parent 67123bb970
commit ec2a98b843
5 changed files with 52 additions and 30 deletions

View file

@ -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
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.
(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:
import visual as vs
from visual import vector as v
from visual import vector as vv
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 cv2, cv
from geom import *
## 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
from pupil.calibrate import get_map_from_cloud
@ -31,8 +37,8 @@ from pupil.calibrate import get_map_from_cloud
point_scale_factor = 10
## Uncomment the following if you want visualization (and comment the line after)
# class GazeSimulation(Visualizable):
class GazeSimulation:
class GazeSimulation(Visualizable):
# class GazeSimulation:
_log = True
def log(self, msg):
if self._log: print msg
@ -531,6 +537,8 @@ class GazeSimulation:
calibration = False #
display_test_point_rays = False #
display_active_gaze_point = False
display_calibration_point_rays = True
display_test_point_rays = True
rays = []
def draw(self):
@ -540,22 +548,26 @@ class GazeSimulation:
'''
from util import drawAxes, drawLine
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
drawAxes(None, vs.color.white, 13, (0, 0, 0))
# drawAxes(None, vs.color.white, 13, (0, 0, 0))
## 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,
color=vs.color.red)
## 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,
color=vs.color.white)
self.recomputeEyeInner()
eye_inner.pos = self.cornea_pos
eye_inner.pos = v_to_vv(self.cornea_pos)
## 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
if self.display_calibration_points:
vs.points(pos=self.calibration_points, size=10, color=vs.color.yellow)
@ -572,18 +584,18 @@ class GazeSimulation:
if self.display_calibration_point_rays:
# Cast rays from scene camera towards calibration points
for point in self.calibration_points:
diff = vs.vector(point) - vs.vector(self.scene_camera.t)
drawLine(None, vs.vector(self.scene_camera.t), diff.mag, diff.norm())
diff = vv(point) - vv(self.scene_camera.t)
drawLine(None, vv(self.scene_camera.t), diff.mag, diff.norm())
# Display rays from scene camera towards test points
if self.display_test_point_rays:
# Cast rays from scene camera towards calibration points
for point in self.test_points:
diff = vs.vector(point) - vs.vector(self.scene_camera.t)
drawLine(None, vs.vector(self.scene_camera.t), diff.mag, diff.norm())
diff = vv(point) - vv(self.scene_camera.t)
drawLine(None, vv(self.scene_camera.t), diff.mag, diff.norm())
# 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:
vs.points(pos=self.tr_target_projections_3d, size=7, color=vs.color.red)