我在识别代码时遇到一些属性错误。第一次将人脸带入数据库代码可以完美运行。但是当我尝试运行人脸识别代码时,它显示了一些属性错误。我用谷歌搜索并尝试遵循所有步骤。但是,它仍然显示相同的错误。这是我的代码:
import numpy as np
import cv2
class Recognizer:
def __init__(self):
self.images=[]
self.lables=np.array([])
def train(self,images,lables,recogType=0):
self.images = images
self.lables = np.array(lables)
'arg=recogType:[createLBPHFaceRecognizer,createFisherFaceRecognizer,createEigenFaceRecognizer]'
recogs=[cv2.createLBPHFaceRecognizer,cv2.createFisherFaceRecognizer,cv2.createEigenFaceRecognizer]
self.recognizer = recogs[recogType]()
self.recognizer.train(self.images,self.lables)
def getLable(self,sampleImage): # image is gray
predictedLable , conf = self.recognizer.predict(sampleImage)
return predictedLable , conf