import cv2 import numpy as np images=[] #刘诗诗 images.append(cv2.imread("./lss/1.png",0)) images.append(cv2.imread("./lss/2.png",0)) images.append(cv2.imread("./lss/3.png",0)) images.append(cv2.imread("./lss/4.png",0)) images.append(cv2.imread("./lss/5.png",0)) #刘亦菲 images.append(cv2.imread("./lyf/1.jpg",0)) images.append(cv2.imread("./lyf/2.jpg",0)) images.append(cv2.imread("./lyf/3.jpg",0)) images.append(cv2.imread("./lyf/4.jpg",0)) images.append(cv2.imread("./lyf/5.jpg",0)) #标签 labels=[0,0,0,0,0,1,1,1,1,1] #获取识别器 recognizer = cv2.face.LBPHFaceRecognizer_create() #训练 recognizer.train(images, np.array(labels)) #待识别照片 predict_image=cv2.imread("001.jpg",0) #识别 label,confidence= recognizer.predict(predict_image) print("label=",label) print("confidence=",confidence)
基于opencv的人脸识别
内容版权声明:除非注明,否则皆为本站原创文章。