Ask Your Question
0

Opencv LBPHFaceRecognizer Train data in Python

asked 2015-11-22 12:16:55 -0600

Gkan gravatar image

updated 2015-11-22 13:02:09 -0600

I am working on face recognition with LBPH algorithm and i need to save train data to database.

   recognizer =  cv2.createLBPHFaceRecognizer()
   recognizer.train(images, np.array(labels))

i need to see this train data for each image.

How can I make this ?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2018-06-10 04:44:58 -0600

sudik gravatar image

updated 2018-06-10 04:56:26 -0600

berak gravatar image

hope this will help:

recognizer = cv2.face.LBPHFaceRecognizer_create();
path="dataset"

def getImagesWithID(path):
    imagePaths=[os.path.join(path,f) for f in os.listdir(path)]
    faces=[]
    IDs=[]
    for imagePath in imagePaths:
        faceImg=Image.open(imagePath).convert('L');
        faceNp=np.array(faceImg,'uint8')
        ID=int(os.path.split(imagePath)[-1].split('.')[1])
        faces.append(faceNp)
        IDs.append(ID)
        cv2.imshow("training",faceNp)
        cv2.waitKey(10)
    return np.array(IDs), faces

Ids, faces = getImagesWithID(path)
recognizer.train(faces, Ids)
recognizer.save('recognizer/trainningData.yml')
edit flag offensive delete link more
0

answered 2017-02-05 04:22:52 -0600

recognizer.save("filename.yml"), file name is in quote and to load the trained recognizer you will need recognizer.load("filename.yml")..

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-11-22 12:16:55 -0600

Seen: 6,817 times

Last updated: Jun 10 '18