jAER project on SourceForge

net.sf.jaer.eventprocessing.tracking
Class RectangularClusterTracker

java.lang.Object
  extended by net.sf.jaer.eventprocessing.EventFilter
      extended by net.sf.jaer.eventprocessing.EventFilter2D
          extended by net.sf.jaer.eventprocessing.tracking.RectangularClusterTracker
All Implemented Interfaces:
java.util.Observer, FrameAnnotater
Direct Known Subclasses:
StereoClusterTracker

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

Tracks blobs of events using a rectangular hypothesis about the object shape. Many parameters constrain the hypothesese in various ways, including perspective projection, fixed aspect ratio, variable size and aspect ratio, "mixing factor" that determines how much each event moves a cluster, etc.

Author:
tobi

Nested Class Summary
 class RectangularClusterTracker.Cluster
           
 
Field Summary
static float ASPECT_RATIO_MAX
          maximum and minimum allowed dynamic aspect ratio
static float ASPECT_RATIO_MIN
          maximum and minimum allowed dynamic aspect ratio
protected  AEChip chip
           
protected  int clusterCounter
           
protected  float defaultClusterRadius
           
protected static float fullbrightnessLifetime
           
protected  boolean growMergedSizeEnabled
           
static float MAX_SCALE_RATIO
          scaling can't make cluster bigger or smaller than this ratio to default cluster size
protected  float mixingFactor
           
protected  java.util.LinkedList<RectangularClusterTracker.Cluster> pruneList
           
protected  java.util.Random random
           
 
Fields inherited from class net.sf.jaer.eventprocessing.EventFilter2D
enclosedFilter, out
 
Fields inherited from class net.sf.jaer.eventprocessing.EventFilter
annotationEnabled, enclosedFilterChain, filterEnabled, log, perf, propertyTooltipMap, support
 
Constructor Summary
RectangularClusterTracker(AEChip chip)
          Creates a new instance of RectangularClusterTracker
 
Method Summary
 void annotate(float[][][] frame)
          annotate the rendered retina frame to show locations of clusters
 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.
protected  void drawBox(javax.media.opengl.GL gl, int x, int y, int sx, int sy, float angle)
           
 EventPacket filterPacket(EventPacket in)
          Subclasses implement this method to define custom processing.
 float getAspectRatio()
           
 float getClassifierThreshold()
           
 int getClusterLifetimeWithoutSupportUs()
          lifetime of cluster in ms without support
 java.util.List<RectangularClusterTracker.Cluster> getClusters()
           
 float getClusterSize()
          max distance from cluster to event as fraction of size of array
static java.lang.String getDescription()
           
 boolean getDynamicSizeEnabled()
           
 java.lang.Object getFilterState()
          should return the filter state in some useful form
 int getMaxNumClusters()
          max number of clusters
 float getMixingFactor()
           
 int getNumClusters()
           
 float getOpticalGyroTauLowpassMs()
           
 int getPathLength()
           
 int getPredictiveVelocityFactor()
           
 float getSurround()
           
 int getThresholdEventsForVisibleCluster()
          number of events to make a potential cluster visible
 float getThresholdVelocityForVisibleCluster()
           
 int getVelocityPoints()
           
 void initFilter()
          this should allocate and initialize memory: it may be called when the chip e.g.
 boolean isClassifierEnabled()
           
 boolean isClusterLifetimeIncreasesWithAge()
           
 boolean isColorClustersDifferentlyEnabled()
           
 boolean isDynamicAngleEnabled()
           
 boolean isDynamicAspectRatioEnabled()
           
 boolean isGrowMergedSizeEnabled()
           
 boolean isHighwayPerspectiveEnabled()
           
 boolean isLogDataEnabled()
           
 boolean isOpticalGyroEnabled()
          Get the value of opticalGyroEnabled
 boolean isPathsEnabled()
           
 boolean isShowAllClusters()
           
 boolean isUseNearestCluster()
           
 boolean isUseOffPolarityOnlyEnabled()
           
 boolean isUseOnePolarityOnlyEnabled()
           
 boolean isUseVelocity()
           
 void resetFilter()
          should reset the filter to initial state
 void setAspectRatio(float aspectRatio)
           
 void setClassifierEnabled(boolean classifierEnabled)
          Sets whether classifier is enabled.
 void setClassifierThreshold(float classifierThreshold)
           
 void setClusterLifetimeIncreasesWithAge(boolean clusterLifetimeIncreasesWithAge)
          If true, cluster lifetime withtout support increases proportional to the age of the cluster relative to the clusterLifetimeWithoutSupportUs time
 void setClusterLifetimeWithoutSupportUs(int clusterLifetimeWithoutSupport)
          lifetime of cluster in ms without support
 void setClusterSize(float clusterSize)
          sets max distance from cluster center to event as fraction of maximum size of chip pixel array.
 void setColorClustersDifferentlyEnabled(boolean colorClustersDifferentlyEnabled)
           
 void setDynamicAngleEnabled(boolean dynamicAngleEnabled)
          Setting dynamicAngleEnabled true enables variable-angle clusters.
 void setDynamicAspectRatioEnabled(boolean dynamicAspectRatioEnabled)
           
 void setDynamicSizeEnabled(boolean dynamicSizeEnabled)
          Enables cluster size scaling.
 void setGrowMergedSizeEnabled(boolean growMergedSizeEnabled)
           
 void setHighwayPerspectiveEnabled(boolean highwayPerspectiveEnabled)
           
 void setLogDataEnabled(boolean logDataEnabled)
           
 void setMaxNumClusters(int maxNumClusters)
          max number of clusters
 void setMixingFactor(float mixingFactor)
           
 void setOpticalGyroEnabled(boolean opticalGyroEnabled)
          Set the value of opticalGyroEnabled
 void setOpticalGyroTauLowpassMs(float opticalGyroTauLowpassMs)
           
 void setPathLength(int pathLength)
           
 void setPathsEnabled(boolean pathsEnabled)
           
 void setPredictiveVelocityFactor(int predictiveVelocityFactor)
           
 void setShowAllClusters(boolean showAllClusters)
          Sets annotation visibility of clusters that are not "visible"
 void setSurround(float surround)
          sets scale factor of radius that events outside the cluster size can affect the size of the cluster if scaling is enabled.
 void setThresholdEventsForVisibleCluster(int thresholdEventsForVisibleCluster)
          number of events to make a potential cluster visible
 void setThresholdVelocityForVisibleCluster(float thresholdVelocityForVisibleCluster)
          A cluster must have at least this velocity magnitude to become visible
 void setUseNearestCluster(boolean useNearestCluster)
           
 void setUseOffPolarityOnlyEnabled(boolean useOffPolarityOnlyEnabled)
           
 void setUseOnePolarityOnlyEnabled(boolean useOnePolarityOnlyEnabled)
           
 void setUseVelocity(boolean useVelocity)
           
 void setVelocityPoints(int velocityPoints)
           
 java.lang.String toString()
           
 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, getEnclosedFilterChain, getEnclosingFilter, getPrefs, getPropertyChangeSupport, getPropertyTooltip, isAnnotationEnabled, 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, wait, wait, wait
 
Methods inherited from interface net.sf.jaer.graphics.FrameAnnotater
isAnnotationEnabled, setAnnotationEnabled
 

Field Detail

chip

protected AEChip chip

MAX_SCALE_RATIO

public static final float MAX_SCALE_RATIO
scaling can't make cluster bigger or smaller than this ratio to default cluster size

See Also:
Constant Field Values

ASPECT_RATIO_MAX

public static final float ASPECT_RATIO_MAX
maximum and minimum allowed dynamic aspect ratio

See Also:
Constant Field Values

ASPECT_RATIO_MIN

public static final float ASPECT_RATIO_MIN
maximum and minimum allowed dynamic aspect ratio

See Also:
Constant Field Values

defaultClusterRadius

protected float defaultClusterRadius

mixingFactor

protected float mixingFactor

growMergedSizeEnabled

protected boolean growMergedSizeEnabled

pruneList

protected java.util.LinkedList<RectangularClusterTracker.Cluster> pruneList

clusterCounter

protected int clusterCounter

fullbrightnessLifetime

protected static final float fullbrightnessLifetime
See Also:
Constant Field Values

random

protected java.util.Random random
Constructor Detail

RectangularClusterTracker

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

Method Detail

getDescription

public static java.lang.String getDescription()

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

getNumClusters

public int getNumClusters()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getOpticalGyroTauLowpassMs

public float getOpticalGyroTauLowpassMs()
Returns:
the opticalGyroTauLowpassMs

setOpticalGyroTauLowpassMs

public void setOpticalGyroTauLowpassMs(float opticalGyroTauLowpassMs)
Parameters:
opticalGyroTauLowpassMs - the opticalGyroTauLowpassMs to set

getClusters

public java.util.List<RectangularClusterTracker.Cluster> getClusters()

getClusterLifetimeWithoutSupportUs

public final int getClusterLifetimeWithoutSupportUs()
lifetime of cluster in ms without support


setClusterLifetimeWithoutSupportUs

public void setClusterLifetimeWithoutSupportUs(int clusterLifetimeWithoutSupport)
lifetime of cluster in ms without support


getClusterSize

public final float getClusterSize()
max distance from cluster to event as fraction of size of array


setClusterSize

public void setClusterSize(float clusterSize)
sets max distance from cluster center to event as fraction of maximum size of chip pixel array. e.g. clusterSize=0.5 and 128x64 array means cluster has radius of 0.5*128=64 pixels.

Parameters:
clusterSize -

getMaxNumClusters

public final int getMaxNumClusters()
max number of clusters


setMaxNumClusters

public void setMaxNumClusters(int maxNumClusters)
max number of clusters


getThresholdEventsForVisibleCluster

public final int getThresholdEventsForVisibleCluster()
number of events to make a potential cluster visible


setThresholdEventsForVisibleCluster

public void setThresholdEventsForVisibleCluster(int thresholdEventsForVisibleCluster)
number of events to make a potential cluster visible


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

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

isHighwayPerspectiveEnabled

public boolean isHighwayPerspectiveEnabled()

setHighwayPerspectiveEnabled

public void setHighwayPerspectiveEnabled(boolean highwayPerspectiveEnabled)

getMixingFactor

public float getMixingFactor()

setMixingFactor

public void setMixingFactor(float mixingFactor)

getSurround

public float getSurround()
See Also:
setSurround(float)

setSurround

public void setSurround(float surround)
sets scale factor of radius that events outside the cluster size can affect the size of the cluster if scaling is enabled.

Parameters:
surround - the scale factor, constrained >1 by setter. radius is multiplied by this to determine if event is within surround.

isPathsEnabled

public boolean isPathsEnabled()
See Also:
setPathsEnabled(boolean)

setPathsEnabled

public void setPathsEnabled(boolean pathsEnabled)
Parameters:
pathsEnabled - true to show the history of the cluster locations on each packet

getDynamicSizeEnabled

public boolean getDynamicSizeEnabled()
See Also:
setDynamicSizeEnabled(boolean)

setDynamicSizeEnabled

public void setDynamicSizeEnabled(boolean dynamicSizeEnabled)
Enables cluster size scaling. The clusters are dynamically resized by the distances of the events from the cluster center. If most events are far from the cluster then the cluster size is increased, but if most events are close to the cluster center than the cluster size is decreased. The size change for each event comes from mixing the old size with a the event distance from the center using the mixing factor.

Parameters:
dynamicSizeEnabled - true to enable scaling of cluster size

isColorClustersDifferentlyEnabled

public boolean isColorClustersDifferentlyEnabled()
See Also:
setColorClustersDifferentlyEnabled(boolean)

setColorClustersDifferentlyEnabled

public void setColorClustersDifferentlyEnabled(boolean colorClustersDifferentlyEnabled)
Parameters:
colorClustersDifferentlyEnabled - true to color each cluster a different color. false to color each cluster by its age

update

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

isUseOnePolarityOnlyEnabled

public boolean isUseOnePolarityOnlyEnabled()

setUseOnePolarityOnlyEnabled

public void setUseOnePolarityOnlyEnabled(boolean useOnePolarityOnlyEnabled)

isUseOffPolarityOnlyEnabled

public boolean isUseOffPolarityOnlyEnabled()

setUseOffPolarityOnlyEnabled

public void setUseOffPolarityOnlyEnabled(boolean useOffPolarityOnlyEnabled)

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

drawBox

protected void drawBox(javax.media.opengl.GL gl,
                       int x,
                       int y,
                       int sx,
                       int sy,
                       float angle)

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(float[][][] frame)
annotate the rendered retina frame to show locations of clusters

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

isGrowMergedSizeEnabled

public boolean isGrowMergedSizeEnabled()

setGrowMergedSizeEnabled

public void setGrowMergedSizeEnabled(boolean growMergedSizeEnabled)

setUseVelocity

public void setUseVelocity(boolean useVelocity)

isUseVelocity

public boolean isUseVelocity()

isLogDataEnabled

public boolean isLogDataEnabled()

setLogDataEnabled

public void setLogDataEnabled(boolean logDataEnabled)

getAspectRatio

public float getAspectRatio()

setAspectRatio

public void setAspectRatio(float aspectRatio)

isClassifierEnabled

public boolean isClassifierEnabled()

setClassifierEnabled

public void setClassifierEnabled(boolean classifierEnabled)
Sets whether classifier is enabled.

Parameters:
classifierEnabled - true to enable classifier

getClassifierThreshold

public float getClassifierThreshold()

setClassifierThreshold

public void setClassifierThreshold(float classifierThreshold)

isShowAllClusters

public boolean isShowAllClusters()

setShowAllClusters

public void setShowAllClusters(boolean showAllClusters)
Sets annotation visibility of clusters that are not "visible"

Parameters:
showAllClusters - true to show all clusters even if there are not "visible"

isDynamicAspectRatioEnabled

public boolean isDynamicAspectRatioEnabled()

setDynamicAspectRatioEnabled

public void setDynamicAspectRatioEnabled(boolean dynamicAspectRatioEnabled)

isUseNearestCluster

public boolean isUseNearestCluster()

setUseNearestCluster

public void setUseNearestCluster(boolean useNearestCluster)

getPredictiveVelocityFactor

public int getPredictiveVelocityFactor()

setPredictiveVelocityFactor

public void setPredictiveVelocityFactor(int predictiveVelocityFactor)

isClusterLifetimeIncreasesWithAge

public boolean isClusterLifetimeIncreasesWithAge()

setClusterLifetimeIncreasesWithAge

public void setClusterLifetimeIncreasesWithAge(boolean clusterLifetimeIncreasesWithAge)
If true, cluster lifetime withtout support increases proportional to the age of the cluster relative to the clusterLifetimeWithoutSupportUs time


getThresholdVelocityForVisibleCluster

public float getThresholdVelocityForVisibleCluster()

setThresholdVelocityForVisibleCluster

public void setThresholdVelocityForVisibleCluster(float thresholdVelocityForVisibleCluster)
A cluster must have at least this velocity magnitude to become visible

Parameters:
thresholdVelocityForVisibleCluster - speed in pixels/second

isOpticalGyroEnabled

public boolean isOpticalGyroEnabled()
Get the value of opticalGyroEnabled

Returns:
the value of opticalGyroEnabled

setOpticalGyroEnabled

public void setOpticalGyroEnabled(boolean opticalGyroEnabled)
Set the value of opticalGyroEnabled

Parameters:
opticalGyroEnabled - new value of opticalGyroEnabled

getPathLength

public int getPathLength()

setPathLength

public void setPathLength(int pathLength)

isDynamicAngleEnabled

public boolean isDynamicAngleEnabled()

setDynamicAngleEnabled

public void setDynamicAngleEnabled(boolean dynamicAngleEnabled)
Setting dynamicAngleEnabled true enables variable-angle clusters.


getVelocityPoints

public int getVelocityPoints()

setVelocityPoints

public void setVelocityPoints(int velocityPoints)

jAER project on SourceForge