1.Face_Recognition库介绍
face_recognition基于dlib进行了二次封装,号称世界上最简洁的人脸识别库。
(1)github地址:
https://github.com/ageitgey/face_recognition
(2)官方指南:
Face Recognition — Face Recognition 1.4.0 documentation
2.load_image_file方法
主要用于加载要识别的人脸图像,加载返回的数据是Numpy数组。记录了图片的所有像素的特征向量。
源码:
def load_image_file(file, mode='RGB'):
"""
Loads an image file (.jpg, .png, etc) into a numpy array
:param file: image file name or file object to load
:param mode: format to convert the image to. Only 'RGB' (8-bit RGB, 3 channels) and 'L' (black and white) are supported.
:return: image contents as numpy array
"""
im = PIL.Image.open(file)
if mode:
im = im.con