| ImageEn, unit iexHelperFunctions |
|
TIEBitmapHelper.LevelByEyes
Declaration
function LevelByEyes(Crop: Boolean = False; MinAngle: Double = 0.5; MaxAngle: Double = 30; MinScore: Double = 0.8): Double;
Description
Straightens a photo so the eyes of the main (largest) face are level. Useful for tilted portraits and ID photos.
Returns the angle the image was rotated by (degrees counter-clockwise), or 0 if it was not rotated.
| Parameter | Description |
| Crop | If False, the canvas is enlarged and the new corners are filled with the background color (Rotate). If True, the new corners are trimmed (RotateAndCrop with iecaAngledPhoto) |
| MinAngle | The image is not rotated if the tilt is smaller than this (degrees) |
| MaxAngle | The image is not rotated if the tilt is larger than this (degrees), as it is more likely to be a detection error |
| MinScore | The minimum detection score for a face (0 to 1) |
The eye angle of strongly tilted faces is underestimated by the detector, so the tilt is measured again after rotating (up to three times) and the most level result is used.
The image is only rotated once, so quality is not affected by the refinement.
Note:
◼You must add the iexHelperFunctions unit to your uses clause
◼Delphi/C++ 2005 or newer is required to use helper classes
◼If no face is found, the image is not changed and the result is 0
◼Face detection requires
IEVision. You will need to
register it before calling the method
Demo
| Demos\ImageEditing\EveryMethod\EveryMethod.dpr |
Examples
// Level the portrait and trim the rotated corners
angle := ImageEnView1.IEBitmap.LevelByEyes( True );
ImageEnView1.Update();
if angle = 0 then
ShowMessage( 'Image is already level (or no face was found)' );
// Straighten the image so the eyes of the main face are level
angle := ImageEnView1.IEBitmap.LevelByEyes( False, 0.5, 30 );
ImageEnView1.Update();
See Also
◼DetectFaces
◼alignFace