Skip to content

Commit

Permalink
Add align_dlib.align for backwards compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Amos committed Jun 9, 2016
1 parent e534fa9 commit 54a5c9b
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions openface/align_dlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,39 @@ def findLandmarks(self, rgbImg, bb):
points = self.predictor(rgbImg, bb)
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,
landmarks=None, landmarkIndices=INNER_EYES_AND_BOTTOM_LIP,
skipMulti=False):
Expand Down

0 comments on commit 54a5c9b

Please sign in to comment.