the code attached below
import cv2
import numpy as np
recognizer = cv2.face
recognizer.loadTrainingData('trainer/example.yml')
#recognizer.read()
cascadePath = "haarcascade_frontalface_default.xml"
faceCascade = cv2.CascadeClassifier(cascadePath);
cam = cv2.VideoCapture(1)
font = cv2.FONT_HERSHEY_SIMPLEX
while True:
ret, im =cam.read()
gray=cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
faces=faceCascade.detectMultiScale(gray, 1.3,5)
for(x,y,w,h) in faces:
cv2.rectangle(im,(x,y),(x+w,y+h),(225,0,0),2)
Id, conf = recognizer.predict(gray[y:y+h,x:x+w])
cv2.PutText(cv2.cv.fromarray(im),str(Id), (x,y+h),font, 255)
cv2.imshow('face',im)
if cv2.waitKey(10) == ord('q'):
break
cam.release()
cv2.destroyAllWindows()
I find out it is impossible to write code like below in this opencv version
recognizer = cv2.createLBPHFaceRecognizer()
recognizer.load('trainer/example.yml')
The goal is to load the data collected before in example.yml. However I'm not sure how to do that and the attached code has few incomplete parameters.