Add align_dlib.align for backwards compatibility.
This commit is contained in:
parent
e534fa9c7f
commit
54a5c9b59f
|
@ -146,6 +146,39 @@ class AlignDlib:
|
||||||
points = self.predictor(rgbImg, bb)
|
points = self.predictor(rgbImg, bb)
|
||||||
return list(map(lambda p: (p.x, p.y), points.parts()))
|
return list(map(lambda p: (p.x, p.y), points.parts()))
|
||||||
|
|
||||||
|
def align(self, imgDim, rgbImg, bb=None,
|
||||||
|
landmarks=None, landmarkIndices=INNER_EYES_AND_BOTTOM_LIP,
|
||||||
|
skipMulti=False, version=1):
|
||||||
|
r"""align(imgDim, rgbImg, bb=None, landmarks=None, landmarkIndices=INNER_EYES_AND_BOTTOM_LIP, version=1)
|
||||||
|
|
||||||
|
Transform and align a face in an image.
|
||||||
|
|
||||||
|
:param imgDim: The edge length in pixels of the square the image is resized to.
|
||||||
|
:type imgDim: int
|
||||||
|
:param rgbImg: RGB image to process. Shape: (height, width, 3)
|
||||||
|
:type rgbImg: numpy.ndarray
|
||||||
|
:param bb: Bounding box around the face to align. \
|
||||||
|
Defaults to the largest face.
|
||||||
|
:type bb: dlib.rectangle
|
||||||
|
:param landmarks: Detected landmark locations. \
|
||||||
|
Landmarks found on `bb` if not provided.
|
||||||
|
:type landmarks: list of (x,y) tuples
|
||||||
|
:param landmarkIndices: The indices to transform to.
|
||||||
|
:type landmarkIndices: list of ints
|
||||||
|
:param skipMulti: Skip image if more than one face detected.
|
||||||
|
:type skipMulti: bool
|
||||||
|
:param version: int
|
||||||
|
:return: The aligned RGB image. Shape: (imgDim, imgDim, 3)
|
||||||
|
:rtype: numpy.ndarray
|
||||||
|
"""
|
||||||
|
|
||||||
|
if version == 1:
|
||||||
|
self.align_v1(imgDim, rgbImg, bb, landmarks, landmarkIndices, skipMulti)
|
||||||
|
elif version == 2:
|
||||||
|
self.align_v2(imgDim, rgbImg, bb, landmarks, landmarkIndices, skipMulti)
|
||||||
|
else:
|
||||||
|
assert False
|
||||||
|
|
||||||
def align_v1(self, imgDim, rgbImg, bb=None,
|
def align_v1(self, imgDim, rgbImg, bb=None,
|
||||||
landmarks=None, landmarkIndices=INNER_EYES_AND_BOTTOM_LIP,
|
landmarks=None, landmarkIndices=INNER_EYES_AND_BOTTOM_LIP,
|
||||||
skipMulti=False):
|
skipMulti=False):
|
||||||
|
|
Loading…
Reference in New Issue