'@brief äžalign_openface()ç±»äŒŒïŒäœæ¯éè¿æŽå€äžªçç¹æ¥è®¡ç®ä»¿å°åæ¢ç©éµã'

def align_similarity(self, imgDim, rgbImg, bb=None, landmarks=None, landmarkIndices=range(0, 68)):

    assert (imgDim is not None)
    assert (rgbImg is not None)
    assert (landmarkIndices is not None)
    if (bb is None):
        bb = self.getLargestFaceBoundingBox(rgbImg)
        if (bb is None):
            return
    if (landmarks is None):
        landmarks = self.findLandmarks(rgbImg, bb)
    npLandmarkIndices = np.array(landmarkIndices)
    npLandmarks = np.array(landmarks).astype(np.int)
    T = (imgDim * self.new_template).astype(np.int)
    source = np.reshape(npLandmarks[npLandmarkIndices], (1, 68, 2))
    target = np.reshape(T[npLandmarkIndices], (1, 68, 2))
    H = cv2.estimateRigidTransform(source, target, False)
    if (H is None):
        return None
    else:
        aligned_face = cv2.warpAffine(rgbImg, H, (imgDim, imgDim))
        return aligned_face
