jAER project on SourceForge

net.sf.jaer.eventprocessing.tracking
Class MultiLineClusterTracker

java.lang.Object
  extended by net.sf.jaer.eventprocessing.EventFilter
      extended by net.sf.jaer.eventprocessing.EventFilter2D
          extended by net.sf.jaer.eventprocessing.tracking.MultiLineClusterTracker
All Implemented Interfaces:
java.util.Observer, LineDetector, FrameAnnotater

public class MultiLineClusterTracker
extends EventFilter2D
implements FrameAnnotater, java.util.Observer, LineDetector

Tracks multiple lines in the scene using a cluster based method based on pairs of recent events. The event pairs come from a buffer formed from recent events. Each pair defines a line with polar and angle parameters. Lines are tracked using polar (rho) and angle (theta) parameters in a space of rho/theta, in analogy with the MultiLineClusterTracker tracking of rectangular objects in retinal coordinate space.

Author:
tobi
See Also:
LineDetector

Nested Class Summary
 class MultiLineClusterTracker.LineCluster
          Represents a single tracked line.
 
Field Summary
protected  AEChip chip
           
protected  int clusterCounter
           
protected static float fullbrightnessLifetime
           
static float MAX_SCALE_RATIO
          scaling can't make cluster bigger or smaller than this ratio to default cluster size
protected  java.util.LinkedList<MultiLineClusterTracker.LineCluster> pruneList
           
 
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
MultiLineClusterTracker(AEChip chip)
          Creates a new instance of MultiLineClusterTracker
 
Method Summary
 void annotate(float[][][] frame)
          annotate the RGB frame somehow by color pixels in the rendered pixel frame data.
 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.
 int getClusterLifetimeWithoutSupportUs()
          lifetime of cluster in ms without support
 java.util.List<MultiLineClusterTracker.LineCluster> getClusters()
          Returns list of all clusters, including those not "visible" yet.
static java.lang.String getDescription()
           
 int getEventBufferLength()
           
 java.lang.Object getFilterState()
          should return the filter state in some useful form
 int getMaxNumClusters()
          max number of clusters
 int getMaxSegmentDt()
           
 int getMaxSegmentLength()
           
 float getMinDistanceNormalized()
           
 int getMinSegmentLength()
           
 float getMixingFactorLength()
           
 float getMixingFactorPosition()
           
 float getMixingFactorRho()
           
 float getMixingFactorTheta()
           
 int getNumClusters()
           
 int getOriDiffAllowed()
           
 float getRhoPixelsFiltered()
          returns the filtered Hough line radius estimate - the closest distance from the middle of the chip image.
 float getRhoRadius()
           
 MultiLineClusterTracker.LineCluster getStrongestCluster()
          returns cluster with maximum average event rate.
 float getTauMs()
           
 float getThetaDegFiltered()
          returns the filtered angle of the line cluster normal.
 float getThetaRadiusDeg()
           
 int getThresholdEventsForVisibleCluster()
          number of events to make a potential cluster visible
 void initFilter()
          this should allocate and initialize memory: it may be called when the chip e.g.
 boolean isClusterLifetimeIncreasesWithAge()
           
 boolean isColorClustersDifferentlyEnabled()
           
 boolean isLengthEnabled()
           
 boolean isLogDataEnabled()
           
 boolean isRenderInputEvents()
           
 boolean isShowAllClusters()
           
 boolean isShowLineSegments()
           
 boolean isWeightLengthEnabled()
           
 void resetFilter()
          should reset the filter to initial state
 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 setColorClustersDifferentlyEnabled(boolean colorClustersDifferentlyEnabled)
           
 void setEventBufferLength(int eventBufferLength)
          Sets tne number of events to consider for forming line segments for clustering
 void setLengthEnabled(boolean lengthEnabled)
           
 void setLogDataEnabled(boolean logDataEnabled)
           
 void setMaxNumClusters(int maxNumClusters)
          max number of clusters
 void setMaxSegmentDt(int maxSegmentDt)
           
 void setMaxSegmentLength(int maxSegmentLength)
           
 void setMinDistanceNormalized(float minDistanceNormalized)
           
 void setMinSegmentLength(int minSegmentLength)
           
 void setMixingFactorLength(float mixingFactorLength)
           
 void setMixingFactorPosition(float mixingFactorPosition)
           
 void setMixingFactorRho(float mixingFactor)
           
 void setMixingFactorTheta(float mixingFactor)
           
 void setOriDiffAllowed(int oriDiffAllowed)
           
 void setRenderInputEvents(boolean renderInputEvents)
           
 void setRhoRadius(float rhoRadius)
           
 void setShowAllClusters(boolean showAllClusters)
          Sets annotation visibility of clusters that are not "visible"
 void setShowLineSegments(boolean showLineSegments)
           
 void setTauMs(float tauMs)
           
 void setThetaRadiusDeg(float thetaRadius)
          Sets radius of LineClusters; argument is in degrees for user interface
 void setThresholdEventsForVisibleCluster(int thresholdEventsForVisibleCluster)
          number of events to make a potential cluster visible
 void setWeightLengthEnabled(boolean weightLengthEnabled)
           
 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

pruneList

protected java.util.LinkedList<MultiLineClusterTracker.LineCluster> pruneList

clusterCounter

protected int clusterCounter

fullbrightnessLifetime

protected static final float fullbrightnessLifetime
See Also:
Constant Field Values
Constructor Detail

MultiLineClusterTracker

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

Parameters:
chip - the chip we are tracking for
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

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

getNumClusters

public int getNumClusters()

toString

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

getClusters

public java.util.List<MultiLineClusterTracker.LineCluster> getClusters()
Returns list of all clusters, including those not "visible" yet.

Returns:
List of LineCluster

getStrongestCluster

public MultiLineClusterTracker.LineCluster getStrongestCluster()
returns cluster with maximum average event rate. Thread safe.

Returns:
strongest supported cluster in events

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


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

getMixingFactorRho

public float getMixingFactorRho()

setMixingFactorRho

public void setMixingFactorRho(float mixingFactor)

getMixingFactorTheta

public float getMixingFactorTheta()

setMixingFactorTheta

public void setMixingFactorTheta(float mixingFactor)

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

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

annotate

public void annotate(float[][][] frame)
Description copied from interface: FrameAnnotater
annotate the RGB frame somehow by color pixels in the rendered pixel frame data.

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

isLogDataEnabled

public boolean isLogDataEnabled()

setLogDataEnabled

public void setLogDataEnabled(boolean logDataEnabled)

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"

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


getEventBufferLength

public int getEventBufferLength()

setEventBufferLength

public void setEventBufferLength(int eventBufferLength)
Sets tne number of events to consider for forming line segments for clustering

Parameters:
eventBufferLength - the length of the buffer in events

getRhoRadius

public float getRhoRadius()

setRhoRadius

public void setRhoRadius(float rhoRadius)

getThetaRadiusDeg

public float getThetaRadiusDeg()

setThetaRadiusDeg

public void setThetaRadiusDeg(float thetaRadius)
Sets radius of LineClusters; argument is in degrees for user interface


getMinSegmentLength

public int getMinSegmentLength()

setMinSegmentLength

public void setMinSegmentLength(int minSegmentLength)

getMaxSegmentLength

public int getMaxSegmentLength()

setMaxSegmentLength

public void setMaxSegmentLength(int maxSegmentLength)

getMaxSegmentDt

public int getMaxSegmentDt()

setMaxSegmentDt

public void setMaxSegmentDt(int maxSegmentDt)

getMixingFactorPosition

public float getMixingFactorPosition()

setMixingFactorPosition

public void setMixingFactorPosition(float mixingFactorPosition)

isShowLineSegments

public boolean isShowLineSegments()

setShowLineSegments

public void setShowLineSegments(boolean showLineSegments)

getMinDistanceNormalized

public float getMinDistanceNormalized()

setMinDistanceNormalized

public void setMinDistanceNormalized(float minDistanceNormalized)

getMixingFactorLength

public float getMixingFactorLength()

setMixingFactorLength

public void setMixingFactorLength(float mixingFactorLength)

isLengthEnabled

public boolean isLengthEnabled()

setLengthEnabled

public void setLengthEnabled(boolean lengthEnabled)

isWeightLengthEnabled

public boolean isWeightLengthEnabled()

setWeightLengthEnabled

public void setWeightLengthEnabled(boolean weightLengthEnabled)

isRenderInputEvents

public boolean isRenderInputEvents()

setRenderInputEvents

public void setRenderInputEvents(boolean renderInputEvents)

getRhoPixelsFiltered

public float getRhoPixelsFiltered()
returns the filtered Hough line radius estimate - the closest distance from the middle of the chip image.

Specified by:
getRhoPixelsFiltered in interface LineDetector
Returns:
the distance in pixels. If the chip size is sx by sy, can range over +-Math.sqrt( (sx/2)^2 + (sy/2)^2). This number is positive if the line is above the origin (center of chip)

getThetaDegFiltered

public float getThetaDegFiltered()
returns the filtered angle of the line cluster normal.

Specified by:
getThetaDegFiltered in interface LineDetector
Returns:
angle in degrees. Ranges from -180 to 180 degrees, where -180 and 180 represent a vertical line (horizontal line normal) and 90 and -90 is a horizontal line (??? not consistent with LineDetector interface definition!!! - should fix) TO-DO

getTauMs

public float getTauMs()

setTauMs

public void setTauMs(float tauMs)

getOriDiffAllowed

public int getOriDiffAllowed()

setOriDiffAllowed

public void setOriDiffAllowed(int oriDiffAllowed)

jAER project on SourceForge