@@ -0,0 +1,2401 @@
+%22%22%22 This is license%0A%22%22%22%0A%0A%0Afrom ctypes import *%0A%0Afrom common import _Face, _LandMarks, _Image%0A%0A%0Aalign_lib = cdll.LoadLibrary('../SeetaFaceEngine/library/libseeta_fa_lib.dylib')%0Aalign_lib.get_face_aligner.restype = c_void_p%0Aalign_lib.get_face_aligner.argtypes = %5Bc_char_p%5D%0Aalign_lib.align.restype = POINTER(_LandMarks)%0Aalign_lib.align.argtypes = %5Bc_void_p, POINTER(_Image), POINTER(_Face)%5D%0A%0A%0Aclass Aligner(object):%0A    %22%22%22 Class for Face Alignment%0A    %22%22%22%0A    def __init__(self, model_path):%0A        byte_model_path = bytes(model_path, encoding='utf-8')%0A        self.aligner = align_lib.get_face_aligner(byte_model_path)%0A    %0A    def align(self, image, face):%0A        if image.ndim != 2:%0A            raise ValueError('The input not a gray scale image!')%0A        #prepare image data%0A        image_data = _Image()%0A        image_data.height, image_data.width = image.shape%0A        image_data.channels = 1%0A        data = (c_ubyte * image.size)(*image.tobytes())%0A        image_data.data = cast(data, c_void_p)%0A        # prepare face data%0A        face_data = _Face()%0A        face_data.left   = face.left%0A        face_data.top    = face.top%0A        face_data.right  = face.right%0A        face_data.bottom = face.bottom%0A        face_data.score  = face.score%0A        # call align function%0A        root = align_lib.align(self.aligner, byref(image_data), byref(face_data))%0A        # read face%0A        for i in range(5):%0A            face.landmarks%5Bi%5D = (root.contents.x%5Bi%5D, root.contents.y%5Bi%5D) %0A        # free landmarks%0A        align_lib.free_landmarks(root)%0A%0A        return face%0A%0A    def close(self):%0A        align_lib.free_aligner(self.aligner)%0A%0Aif __name__ == '__main__':%0A    from detector import Detector%0A    import cv2%0A    %0A    im_color = cv2.imread('/Users/tuxiaokang/Downloads/2.png')%0A    im_gray = cv2.cvtColor(im_color, cv2.COLOR_BGR2GRAY)%0A%0A    detector = Detector('../SeetaFaceEngine/model/seeta_fd_frontal_v1.0.bin')%0A    aligner = Aligner('../SeetaFaceEngine/model/seeta_fa_v1.1.bin')%0A    %0A    faces = detector.detect(im_gray)%0A    %0A    for face in faces:%0A        aligner.align(im_gray, face)%0A        #print(face.left, face.top, face.right, face.bottom, face.score)%0A        #for point in face.landmarks:%0A        #    cv2.circle(im_color, point, 1, (0,255,0), 1)%0A        #cv2.rectangle(im_color, (face.left,face.top),(face.right, face.bottom), (255,0,0),3)%0A    #cv2.imshow('x', im_color)%0A    #cv2.waitKey(0)

remove numpy dependence