jAER project on SourceForge

ch.unizh.ini.jaer.projects.eyetracker
Class EyeTracker

java.lang.Object
  extended by net.sf.jaer.eventprocessing.EventFilter
      extended by net.sf.jaer.eventprocessing.EventFilter2D
          extended by ch.unizh.ini.jaer.projects.eyetracker.EyeTracker
All Implemented Interfaces:
java.util.Observer, FrameAnnotater

public class EyeTracker
extends EventFilter2D
implements java.util.Observer, FrameAnnotater

A filter whose underlying model rims (pupil and iris) with a position and radius and rimThickness, which is pushed around by events.

Author:
tobi

Field Summary
 
Fields inherited from class net.sf.jaer.eventprocessing.EventFilter2D
enclosedFilter, out
 
Fields inherited from class net.sf.jaer.eventprocessing.EventFilter
annotationEnabled, chip, enclosedFilterChain, filterEnabled, log, perf, propertyTooltipMap, support
 
Constructor Summary
EyeTracker(AEChip chip)
          Creates a new instance of EyeTracker
 
Method Summary
 void annotate(float[][][] frame)
          does nothing, must be in openGL rendering mode to see results
 void annotate(javax.media.opengl.GLAutoDrawable drawable)
          Each annotator enters annotate with graphics context current, in coordinates with pixel 0,0 in LL corner (note opposite from Java2D) and pixel spacing 1 unit after the scaling transform (which is already active).
 void annotate(java.awt.Graphics2D g)
          each annotator is called by the relevant class (e.g.
 EventPacket filterPacket(EventPacket in)
          Subclasses implement this method to define custom processing.
 float getAcquisitionMultiplier()
           
 java.lang.Object getFilterState()
          should return the filter state in some useful form
 float getIrisRadius()
           
 java.awt.geom.Point2D.Float getPosition()
          Returns the present location of the eye in pixels
 float getPositionMixingFactor()
           
 float getPupilRadius()
           
 float getQualityMixingFactor()
           
 float getQualityThreshold()
           
 float getRimThickness()
           
 float getScalingMixingFactor()
          gets "mixing factor" for dynamic scaling of model size.
 float getTargetSpeed()
           
 void initFilter()
          this should allocate and initialize memory: it may be called when the chip e.g.
 boolean isAnnotationEnabled()
          Each filter has an annotationEnabled flag that is used to graphical annotation of the filter, e.g.
 boolean isDynamicAcquisitionSize()
           
 boolean isLogDataEnabled()
           
 boolean isScalingEnabled()
           
 boolean isShowGazeEnabled()
           
 void resetFilter()
          should reset the filter to initial state
 void setAcquisitionMultiplier(float acquisitionMultiplier)
          Sets the factor by which the model area is increased when low quality tracking is detected.
 void setDynamicAcquisitionSize(boolean dynamicAcquisitionSize)
          Sets whether to use dynamic resizing of acquisition model size, depending on quality of tracking.
 void setIrisRadius(float irisRadius)
          Sets radius of outer ring of eye model (the iris)
 void setLogDataEnabled(boolean logDataEnabled)
           
 void setPositionMixingFactor(float mixingFactor)
          Sets mixing factor for eye position
 void setPupilRadius(float eyeRadius)
          Sets initial value of eye (pupil or iris) radius
 void setQualityMixingFactor(float qualityMixingFactor)
          Sets the "mixing factor" for tracking quality measure.
 void setQualityThreshold(float qualityThreshold)
          Sets the threshold for good tracking.
 void setRimThickness(float rimThickness)
          sets thickness of disk of sensitivity around model circles; affects both pupil and iris model.
 void setScalingEnabled(boolean scalingEnabled)
          Enables/disables dynamic scaling.
 void setScalingMixingFactor(float factor)
          sets mixing factor for dynamic resizing of eye
 void setShowGazeEnabled(boolean showGazeEnabled)
          If enabled, shows a measure of gaze based on statistics of measured eye position
 void setTargetSpeed(float speed)
           
 void setX(float x)
           
 void setY(float y)
           
 void update(java.util.Observable o, java.lang.Object arg)
           
 
Methods inherited from class net.sf.jaer.eventprocessing.EventFilter2D
checkOutputPacketEventType, checkOutputPacketEventType, getEnclosedFilter, resetOut, setEnclosedFilter, setFilterEnabled
 
Methods inherited from class net.sf.jaer.eventprocessing.EventFilter
getChip, getDescription, getEnclosedFilterChain, getEnclosingFilter, getPrefs, getPropertyChangeSupport, getPropertyTooltip, isEnclosed, isFilterEnabled, prefsEnabledKey, setAnnotationEnabled, setChip, setEnclosed, setEnclosedFilter, setEnclosedFilterChain, setEnclosingFilter, setPreferredEnabledState, setPrefs, setPropertyTooltip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.jaer.graphics.FrameAnnotater
setAnnotationEnabled
 

Constructor Detail

EyeTracker

public EyeTracker(AEChip chip)
Creates a new instance of EyeTracker

Parameters:
chip - the chip we are eye tracking on
Method Detail

initFilter

public void initFilter()
Description copied from class: EventFilter
this should allocate and initialize memory: it may be called when the chip e.g. size parameters are changed after creation of the filter

Specified by:
initFilter in class EventFilter

filterPacket

public EventPacket filterPacket(EventPacket in)
Description copied from class: EventFilter2D
Subclasses implement this method to define custom processing.

Specified by:
filterPacket in class EventFilter2D
Parameters:
in - the input packet
Returns:
the output packet

getFilterState

public java.lang.Object getFilterState()
Description copied from class: EventFilter
should return the filter state in some useful form

Specified by:
getFilterState in class EventFilter

resetFilter

public void resetFilter()
Description copied from class: EventFilter
should reset the filter to initial state

Specified by:
resetFilter in class EventFilter

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Specified by:
update in interface java.util.Observer

annotate

public void annotate(float[][][] frame)
does nothing, must be in openGL rendering mode to see results

Specified by:
annotate in interface FrameAnnotater
Parameters:
frame - the RGB pixel information. First dimension is Y, second is X, third is RGB

annotate

public void annotate(javax.media.opengl.GLAutoDrawable drawable)
Description copied from interface: FrameAnnotater
Each annotator enters annotate with graphics context current, in coordinates with pixel 0,0 in LL corner (note opposite from Java2D) and pixel spacing 1 unit after the scaling transform (which is already active). The FrameAnnotater then can use JOGL calls to render to the screen by getting the GL context, e.g. the following code, used in the context of an AEChip object, draws a golden lines from LL to UR of the pixel array.
        GL gl = drawable.getGL();
        gl.glBegin(GL.GL_LINES);
        gl.glColor3f(.5f, .5f, 0);
        gl.glVertex2f(0, 0);
        gl.glVertex2f(getSizeX() - 1, getSizeY() - 1);
        gl.glEnd();
 

Specified by:
annotate in interface FrameAnnotater
Parameters:
drawable - the OpenGL drawable components, e.g., GLCanvas

annotate

public void annotate(java.awt.Graphics2D g)
Description copied from interface: FrameAnnotater
each annotator is called by the relevant class (e.g. EyeTracker) and enters annotate with graphics context current, in coordinates with pixel 0,0 in UL corner and pixel spacing 1 unit before scaling transform (which is already active).

Specified by:
annotate in interface FrameAnnotater
Parameters:
g - the Graphics2D context

setX

public void setX(float x)

setY

public void setY(float y)

getPupilRadius

public float getPupilRadius()

setPupilRadius

public void setPupilRadius(float eyeRadius)
Sets initial value of eye (pupil or iris) radius

Parameters:
eyeRadius - the radius in pixels

getRimThickness

public float getRimThickness()

setRimThickness

public void setRimThickness(float rimThickness)
sets thickness of disk of sensitivity around model circles; affects both pupil and iris model. This number is summed and subtracted from radius to give disk of sensitivity.

Parameters:
rimThickness - the thickness in pixels

getPositionMixingFactor

public float getPositionMixingFactor()

setPositionMixingFactor

public void setPositionMixingFactor(float mixingFactor)
Sets mixing factor for eye position

Parameters:
mixingFactor - 0-1

getScalingMixingFactor

public float getScalingMixingFactor()
gets "mixing factor" for dynamic scaling of model size. Setting a small value means model size updates slowly

Returns:
scalingMixingFactor 0-1 value, 0 means no update, 1 means immediate update

setScalingMixingFactor

public void setScalingMixingFactor(float factor)
sets mixing factor for dynamic resizing of eye

Parameters:
factor - mixing factor 0-1

getIrisRadius

public float getIrisRadius()

setIrisRadius

public void setIrisRadius(float irisRadius)
Sets radius of outer ring of eye model (the iris)

Parameters:
irisRadius - in pixels

isScalingEnabled

public boolean isScalingEnabled()

setScalingEnabled

public void setScalingEnabled(boolean scalingEnabled)
Enables/disables dynamic scaling. If scaling is enabled, then all sizes are dynamically estimated and updated. The scale

Parameters:
scalingEnabled - true to enable

isShowGazeEnabled

public boolean isShowGazeEnabled()

setShowGazeEnabled

public void setShowGazeEnabled(boolean showGazeEnabled)
If enabled, shows a measure of gaze based on statistics of measured eye position

Parameters:
showGazeEnabled - true to enable gaze point

setTargetSpeed

public void setTargetSpeed(float speed)

getTargetSpeed

public float getTargetSpeed()

getPosition

public java.awt.geom.Point2D.Float getPosition()
Returns the present location of the eye in pixels

Returns:
the position in pixels

getQualityThreshold

public float getQualityThreshold()

setQualityThreshold

public void setQualityThreshold(float qualityThreshold)
Sets the threshold for good tracking. If fraction of events inside the model (the small-sized optimal model) falls below this number then tracking is regarded as poor.

Parameters:
qualityThreshold - the fraction inside model for good tracking

isAnnotationEnabled

public boolean isAnnotationEnabled()
Description copied from class: EventFilter
Each filter has an annotationEnabled flag that is used to graphical annotation of the filter, e.g. a spatial border, text strings, global graphical overlay, etc. isAnnotationEnabled returns true if the filter is not enclosed and the filter is enabled and annotation is enabled. It returns false if the filter is enclosed and the enclosing filter is not enabled.

Specified by:
isAnnotationEnabled in interface FrameAnnotater
Overrides:
isAnnotationEnabled in class EventFilter
Returns:
true to show filter annotation should be shown

getAcquisitionMultiplier

public float getAcquisitionMultiplier()

setAcquisitionMultiplier

public void setAcquisitionMultiplier(float acquisitionMultiplier)
Sets the factor by which the model area is increased when low quality tracking is detected. Depends on setting of setDynamicAcquisitionSize(boolean) method

Parameters:
acquisitionMultiplier - the ratio of areas; the ratio between disk radius during bad tracking to that during good tracking.

getQualityMixingFactor

public float getQualityMixingFactor()

setQualityMixingFactor

public void setQualityMixingFactor(float qualityMixingFactor)
Sets the "mixing factor" for tracking quality measure. A low value means that the metric updates slowly -- is more lowpassed. If the mixing factor is set to 1 then the measure is instantaneous.

Parameters:
qualityMixingFactor - the mixing factor 0-1

isDynamicAcquisitionSize

public boolean isDynamicAcquisitionSize()

setDynamicAcquisitionSize

public void setDynamicAcquisitionSize(boolean dynamicAcquisitionSize)
Sets whether to use dynamic resizing of acquisition model size, depending on quality of tracking. If tracking quality is poor (support for model is small fraction of total events (defined by qualityThreshold)), then model area is increased proportionally.

Parameters:
dynamicAcquisitionSize - true to enable dynamic proportional resizing of model

isLogDataEnabled

public boolean isLogDataEnabled()

setLogDataEnabled

public void setLogDataEnabled(boolean logDataEnabled)

jAER project on SourceForge