public class AffineAligner extends Object implements FaceAligner<KEDetectedFace>
AffineAligner
attempts to find an affine transform that will warp
the face to the canonical frame by aligning facial keypoints.Modifier and Type | Field and Description |
---|---|
protected static float[][] |
Pmu
Normalised positions of facial parts
|
Constructor and Description |
---|
AffineAligner()
Default Constructor with the default mask (80x80) and default border
percentage (0.225).
|
AffineAligner(FImage mask)
Construct with a mask (in the canonical frame) to apply after aligning
and default border percentage (0.225).
|
AffineAligner(FImage mask,
float facePatchBorderPercentage)
Construct with a mask (in the canonical frame) to apply after aligning
and default border percentage (0.225).
|
AffineAligner(int facePatchWidth,
int facePatchHeight,
float facePatchBorderPercentage)
Construct with no mask and the given size and border.
|
Modifier and Type | Method and Description |
---|---|
FImage |
align(KEDetectedFace descriptor)
For the provided face detection, return an aligned version of the face.
|
byte[] |
binaryHeader()
Header for binary input.
|
protected static Jama.Matrix |
estimateAffineTransform(FacialKeypoint[] pts) |
static Jama.Matrix |
estimateAffineTransform(KEDetectedFace face)
Estimate the affine transform required to warp a set of facial keypoints
to their canonical coordinates.
|
FImage |
getMask()
Return a mask image for aligned faces.
|
void |
readBinary(DataInput in)
Read internal state from in.
|
void |
writeBinary(DataOutput out)
Write the content of this as binary to out.
|
protected static final float[][] Pmu
public AffineAligner()
public AffineAligner(FImage mask)
mask
- public AffineAligner(FImage mask, float facePatchBorderPercentage)
mask
- the maskfacePatchBorderPercentage
- the proportional size (against the detection patch) of the
border for the crop. Higher values result in a more zoomed-in
face.public AffineAligner(int facePatchWidth, int facePatchHeight, float facePatchBorderPercentage)
facePatchWidth
- the width of the desired aligned facesfacePatchHeight
- the height of the desired aligned facesfacePatchBorderPercentage
- the proportional size (against the detection patch) of the
border for the crop. Higher values result in a more zoomed-in
face.public FImage align(KEDetectedFace descriptor)
FaceAligner
align
in interface FaceAligner<KEDetectedFace>
descriptor
- the face to alignpublic static Jama.Matrix estimateAffineTransform(KEDetectedFace face)
Affine transform is from a flat, vertically oriented (canonical) face to located face space. You'll need to invert this if you want to use it to extract the face from the image.
face
- the faceprotected static Jama.Matrix estimateAffineTransform(FacialKeypoint[] pts)
public FImage getMask()
FaceAligner
getMask
in interface FaceAligner<KEDetectedFace>
public void readBinary(DataInput in) throws IOException
ReadableBinary
readBinary
in interface ReadableBinary
in
- source to read from.IOException
- an error reading inputpublic byte[] binaryHeader()
ReadableBinary
binaryHeader
in interface ReadableBinary
binaryHeader
in interface WriteableBinary
public void writeBinary(DataOutput out) throws IOException
WriteableBinary
writeBinary
in interface WriteableBinary
out
- sink to write toIOException
- an error writing to out