Facemorph.aam
Class CLMSVM

java.lang.Object
  extended by Facemorph.aam.CLMSVM

public class CLMSVM
extends java.lang.Object

Constrained local model with SVM based patch detectors


Constructor Summary
CLMSVM()
           
 
Method Summary
 void build(java.lang.String file, HaarReader haar)
          Builds an SVM based CLM model
 Template delineate(java.awt.image.BufferedImage bimg, HaarReader haar, Template template, ImageZoomPanel izp)
          Delineate am image using this CLMSVM using the convex quadratic fitting (CQF) method
 FloatImage[] getStrip(Template tem, FloatImage fimg, java.awt.Rectangle rect, int minOffset, int maxOffset)
          Gets the patches from all points arranged in a strip
static void main(java.lang.String[] args)
          Main method used for generating a random split of the data
 boolean processPatches(java.util.ArrayList<FloatImage[]> patches, java.util.ArrayList<FloatImage[]> negativePatches, boolean doCV)
          Build the SVM model from the patches
 void read(java.lang.String file)
          Reads PCI data from a directory
 void write(java.lang.String file)
          Writes CLMSVM data to a directory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CLMSVM

public CLMSVM()
Method Detail

build

public void build(java.lang.String file,
                  HaarReader haar)
           throws java.io.FileNotFoundException,
                  java.io.IOException
Builds an SVM based CLM model

Parameters:
file - the name of the file listing the training images
haar - the face detector
Throws:
java.io.FileNotFoundException
java.io.IOException

delineate

public Template delineate(java.awt.image.BufferedImage bimg,
                          HaarReader haar,
                          Template template,
                          ImageZoomPanel izp)
                   throws PowellException
Delineate am image using this CLMSVM using the convex quadratic fitting (CQF) method

Parameters:
bimg - the image to delineate
haar - the face detector
template - used to initialise if not null
izp - the image zoom panel to use if animating the searcg
Returns:
returns the estimated template
Throws:
PowellException

getStrip

public FloatImage[] getStrip(Template tem,
                             FloatImage fimg,
                             java.awt.Rectangle rect,
                             int minOffset,
                             int maxOffset)
Gets the patches from all points arranged in a strip

Parameters:
tem - the current template
fimg - the image to sample the patches from
rect - the face detection rectangle, if not null this indicates that the priors should be updated
minOffset - the minimum offset used when building an enriched training set
maxOffset - the maximum offset used when building an enriched training set
Returns:
returns the patch strip image

processPatches

public boolean processPatches(java.util.ArrayList<FloatImage[]> patches,
                              java.util.ArrayList<FloatImage[]> negativePatches,
                              boolean doCV)
                       throws java.io.IOException
Build the SVM model from the patches

Parameters:
patches - the positive example patches
negativePatches - the negative example patches
doCV - perform grid based cross validation
Returns:
returns true if the model was built OK
Throws:
java.io.IOException

read

public void read(java.lang.String file)
          throws java.io.IOException
Reads PCI data from a directory

Parameters:
file - The text file containing the names of the image component files and their variance
Throws:
java.io.IOException - if the file can't be read

write

public void write(java.lang.String file)
           throws java.io.IOException
Writes CLMSVM data to a directory

Parameters:
file - The text file containing the names of the image component files and their variance
Throws:
java.io.IOException - throws IOException if problem writing file

main

public static void main(java.lang.String[] args)
                 throws java.io.FileNotFoundException,
                        java.io.IOException
Main method used for generating a random split of the data

Parameters:
args - args[0] = name of file to read, args[1] = fraction to put in file1, args[2] = output file1, args[3] = output file2
Throws:
java.io.FileNotFoundException
java.io.IOException