From 4633e624fdc4e61928b8c7743d9bbd50c5d75a6a Mon Sep 17 00:00:00 2001 From: Saumit Dinesan Date: Sat, 22 Apr 2023 23:23:31 +0530 Subject: face-detection cleanup+Adding .gitignore --- face-detection/02_face_training.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'face-detection/02_face_training.py') diff --git a/face-detection/02_face_training.py b/face-detection/02_face_training.py index 938761b..68b21fe 100644 --- a/face-detection/02_face_training.py +++ b/face-detection/02_face_training.py @@ -6,8 +6,8 @@ import os path = 'dataset' # Using LBPH(Local Binary Patterns Histograms) recognizer recognizer = cv2.face.LBPHFaceRecognizer_create() -detector = cv2.CascadeClassifier("haarcascade_frontalface_default.xml"); -# function to get the images and label data +detector = cv2.CascadeClassifier("haarcascade_frontalface_default.xml"); #create an instance +# function to read the images in the dataset, convert them to grayscale values, return samples def getImagesAndLabels(path): imagePaths = [os.path.join(path,f) for f in os.listdir(path)] faceSamples=[] @@ -24,8 +24,9 @@ def getImagesAndLabels(path): print ("\n [INFO] Training faces. It will take a few seconds. Wait ...") #returns two arrays faces and ids faces,ids = getImagesAndLabels(path) +#Train the LBPH recognizer using the face samples and their corresponding labels recognizer.train(faces, np.array(ids)) #save the model into trainer/trainer.yml recognizer.write('trainer/trainer.yml') -# Print the numer of faces trained and end program +# Print the numer of faces trained and then exit the program print("\n [INFO] {0} faces trained. Exiting Program".format(len(np.unique(ids)))) -- cgit v1.2.3