Skip to content

Instantly share code, notes, and snippets.

@Prady96
Created October 21, 2018 05:23
Show Gist options
  • Save Prady96/f06c37d9ea937bb0891bbd850cfb59ee to your computer and use it in GitHub Desktop.
Save Prady96/f06c37d9ea937bb0891bbd850cfb59ee to your computer and use it in GitHub Desktop.
HaarCascade Code Error
import cv2
# mathematical calculations
import numpy as np
# os module class hai
from os import listdir
# fetching data from dir and path
from os.path import isfile, join
data_path = "newFaces/" #saved images
onlyFiles = [f for f in listdir(data_path) if isfile(join(data_path,f))]
Training_data, Labels = [],[]
for i,files in enumerate(onlyFiles):
image_path = data_path + onlyFiles[i]
images = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
Training_data.append(np.asarray(images, dtype=np.uint8))
Labels.append(i)
Labels = np.asarray(Labels, dtype=np.int32)
# LBPG Linear Binary Phase Histogram Face Recognizer
model = cv2.face.LBPHFaceRecognizer_create()
model.train(np.asarray(Training_data),np.asarray(Labels))
print("Model Training Complete")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment