Facemorph.haar
Class HaarCascade

java.lang.Object
  extended by Facemorph.haar.HaarCascade

public class HaarCascade
extends java.lang.Object

The HaarCascade is essentially a list of HaarStages.


Constructor Summary
HaarCascade(BufferedImg img)
          Construct a new cascade.
 
Method Summary
static Face average(java.util.ArrayList<Face> faces)
          Finds the average of a groupd of object boxes
 java.util.List<Face> doCascade(HaarReader haar, double stepSize, double shift, double minScale, double maxScale, int xstart, int ystart, int scanWidth, int scanHeight, boolean group)
          Performs the cascade referenced by haar on the picture in this object.
 java.util.List<Face> doCascade(HaarReader haar, double stepSize, double shift, double minScale, double maxScale, java.util.List<Face> faces, int xstart, int ystart, int scanWidth, int scanHeight, boolean flip, boolean group)
          Performs the cascade referenced by haar on the picture in this object.
 boolean doCascade(HaarReader haar, int xOffset, int yOffset, double scale, boolean flip)
          Performs the cascade referenced by haar on the picture in this object.
 SAT getSAT()
          Returns the summed area table associated with this object.
 java.util.List<Face> groupResults(java.util.List<Face> inlist, int baseSize)
          Groups overlapping boxes
 boolean overlap(Face f1, Face f2, int baseSize)
          boolean test to see if 2 boxes are overlapping by some amount
 void setCascadeListener(CascadeListener cl)
          Sets the cascade listener if e.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HaarCascade

public HaarCascade(BufferedImg img)
Construct a new cascade. This generates a summed area table to use.

Parameters:
img - The image to search
Method Detail

getSAT

public SAT getSAT()
Returns the summed area table associated with this object.

Returns:
The summed area table associated with this object.

setCascadeListener

public void setCascadeListener(CascadeListener cl)
Sets the cascade listener if e.g. you want to animate the search. Set to null to turn animation off.

Parameters:
cl - The CascadeListener that will be notified of Cascade events

doCascade

public java.util.List<Face> doCascade(HaarReader haar,
                                      double stepSize,
                                      double shift,
                                      double minScale,
                                      double maxScale,
                                      int xstart,
                                      int ystart,
                                      int scanWidth,
                                      int scanHeight,
                                      boolean group)
Performs the cascade referenced by haar on the picture in this object.

Parameters:
shift - How big to step between applying this filter.
minScale - The minimum scale to scan at
maxScale - The maximum scale to scan at
xstart - The start x position
ystart - The start y position
scanWidth - The width of the box to scan
scanHeight - The height of the box to scan
group - Flag to indicate if you should group overlapping boxes
haar - The cascade to perform on the image.
stepSize - The default step size to use as a fraction of the cascade default image size.
Returns:
An array of 'Face' containing all faces found.

doCascade

public java.util.List<Face> doCascade(HaarReader haar,
                                      double stepSize,
                                      double shift,
                                      double minScale,
                                      double maxScale,
                                      java.util.List<Face> faces,
                                      int xstart,
                                      int ystart,
                                      int scanWidth,
                                      int scanHeight,
                                      boolean flip,
                                      boolean group)
Performs the cascade referenced by haar on the picture in this object.

Parameters:
faces - List of faces to add any found faces too
flip - Flag indicating if the cascade should be flipped
shift - How big to step between applying this filter.
minScale - The minimum scale to scan at
maxScale - The maximum scale to scan at
xstart - The start x position
ystart - The start y position
scanWidth - The width of the box to scan
scanHeight - The height of the box to scan
group - Flag to indicate if you should group overlapping boxes
haar - The cascade to perform on the image.
stepSize - The default step size to use as a fraction of the cascade default image size.
Returns:
An array of 'Face' containing all faces found.

groupResults

public java.util.List<Face> groupResults(java.util.List<Face> inlist,
                                         int baseSize)
Groups overlapping boxes

Parameters:
inlist - Input list of object's found
baseSize - The original baseSize
Returns:
Returns the list of non-overlapping objects

average

public static Face average(java.util.ArrayList<Face> faces)
Finds the average of a groupd of object boxes

Parameters:
faces - The list of faces boxes to average
Returns:
The averager face box

overlap

public boolean overlap(Face f1,
                       Face f2,
                       int baseSize)
boolean test to see if 2 boxes are overlapping by some amount

Parameters:
f1 - First face box
f2 - Second face box
baseSize - original ize of the training box
Returns:
true if the two faces overlap, otherwise false

doCascade

public boolean doCascade(HaarReader haar,
                         int xOffset,
                         int yOffset,
                         double scale,
                         boolean flip)
Performs the cascade referenced by haar on the picture in this object.

Parameters:
flip - flag to indicate if left-right should be flipped
haar - The cascade to perform on the image.
xOffset - The X offset to look at the picture from.
yOffset - The Y offset to look at the picture from.
scale - The scaling factor to use
Returns:
true if the image at the offset (0, 0) is a face, false otherwise.