TIEVisionFaceDetector.alignFace
Declaration
function alignFace(image: TIEVisionImage; face: TIEVisionDetectedFace; size: int32_t = 112): TIEVisionImage; safecall;
Description
Returns an upright, square crop of a face. The image is rotated, scaled and cropped so the eyes, nose and mouth are always at the same positions.
Aligned faces make face recognition (
TIEVisionFaceRecognizer) much more reliable, because every training and query image is framed the same way.
| Parameter | Description |
| image | The image that was passed to detect |
| face | A face returned by detect |
| size | Width and height of the result, from 16 to 1024. Default: 112 |
The result has the same pixel format as the source, except that 1 bit images give an 8 bit gray result.
The crop is tight around the face (forehead to chin), the standard framing for face recognition.
Demos
| Demos\IEVision\GetFaces\GetFaces.dpr |
| Demos\ImageEditing\EveryMethod\EveryMethod.dpr |
Examples
// Add every face in the image to a face recognizer, labelled "Natalie"
img := ImageEnView1.IEBitmap.GetIEVisionImage();
faces := detector.detect( img, IEVisionRect( 0, 0, 0, 0 ));
for i := 0 to faces.size() - 1 do
m_faceRecognizer.addTrainImage( detector.alignFace( img, TIEVisionDetectedFace( faces.getObj( i )), 112 ), 'Natalie' );
m_faceRecognizer.train();
// Output the first face found, aligned upright at 112x112
detector := IEVisionLib.createFaceDetector();
img := ImageEnView1.IEBitmap.GetIEVisionImage();
faces := detector.detect( img, IEVisionRect( 0, 0, 0, 0 ));
if faces.size() > 0 then
ImageEnView1.IEBitmap.AssignIEVisionImage( detector.alignFace( img, TIEVisionDetectedFace( faces.getObj( 0 )), 112 ));
ImageEnView1.Update();
// Shows all faces found, side by side
See Also
◼LevelByEyes
◼DetectFaces