face alignment algorithm on images

后端 未结 4 1160
有刺的猬
有刺的猬 2021-02-08 23:05

How can I do a basic face alignment on a 2-dimensional image with the assumption that I have the position/coordinates of the mouth and eyes.

Is there any algorithm that

4条回答
  •  情歌与酒
    2021-02-08 23:51

    Face detection could be handled based on the just eye positions.

    Herein, OpenCV, Dlib and MTCNN offers to detect faces and eyes. Besides, it is a python based framework but deepface wraps those methods and offers an out-of-the box detection and alignment function.

    detectFace function applies detection and alignment in the background respectively.

    #!pip install deepface
    from deepface import DeepFace
    backends = ['opencv', 'ssd', 'dlib', 'mtcnn']
    DeepFace.detectFace("img.jpg", detector_backend = backends[0])
    

    Besides, you can apply detection and alignment manually.

    from deepface.commons import functions
    img = functions.load_image("img.jpg")
    backends = ['opencv', 'ssd', 'dlib', 'mtcnn']
    
    detected_face = functions.detect_face(img = img, detector_backend = backends[3])
    plt.imshow(detected_face)
    
    aligned_face = functions.align_face(img = img, detector_backend = backends[3])
    plt.imshow(aligned_face)
    
    processed_img = functions.detect_face(img = aligned_face, detector_backend = backends[3])
    plt.imshow(processed_img)
    

提交回复
热议问题