Warping

Warping is the process of face image normalization. It requires landmarks and face detection to operate. The warp has the following properties:

  • its size is always 250x250 pixels

  • it’s always in RGB color format

  • it always contains just a single face

  • the face is always centered and rotated so that imaginary line between the eyes is horizontal.

The purpose of the process is to:

  • compensate image plane rotation (roll angle);

  • center the image using eye positions;

  • properly crop the image.

Module for creating warped images

class lunavl.sdk.estimators.face_estimators.warper.Warp(warpedImage, sourceDetection)[source]

Structure for storing warp.

sourceDetection

detection which generated warp

Type

FaceDetection

warpedImage
Type

WarpedImage

class lunavl.sdk.estimators.face_estimators.warper.WarpedImage(body, filename='', vlImage=None)[source]

Raw warped image.

Properties of a warped image:

  • its size is always 250x250 pixels

  • it’s always in RGB color format

  • it always contains just a single face

  • the face is always centered and rotated so that imaginary line between the eyes is horizontal.

assertWarp()[source]

Validate size and format

Raises
  • ValueError("Bad image size for warped image") – if image has incorrect size

  • ValueError("Bad image format for warped image, must be R8G8B8") – if image has incorrect format

Warning

this checks are not guarantee that image is warp. This function is intended for debug

classmethod load(*_, filename=None, url=None)[source]

Load imag from numpy array or file or url.

Parameters
  • *_ – for remove positional argument

  • filename – filename

  • url – url

Returns

warp

Return type

WarpedImage

warpedImage

Property for compatibility with Warp for outside methods. :returns: self

Return type

WarpedImage

class lunavl.sdk.estimators.face_estimators.warper.Warper(coreWarper)[source]

Class warper.

_coreWarper

core warper

Type

IWarperPtr

makeWarpTransformationWithLandmarks(faceDetection, typeLandmarks)[source]

Make warp transformation with landmarks

Parameters
  • faceDetection – face detection with landmarks5

  • typeLandmarks – landmarks for warping (“L68” or “L5”)

Returns

warping landmarks

Raises
  • ValueError – if landmarks5 is not estimated

  • LunaSDKException – if transform failed

Return type

Union[Landmarks68, Landmarks5]

warp(faceDetection)[source]

Create warp from detection.

Parameters

faceDetection – face detection with landmarks5

Returns

Warp

Raises

LunaSDKException – if creation failed

Return type

Warp