pythonopencv

TypeError: 'cv2.face_EigenFaceRecognizer' object is not callable


I ran into an error which i do not know where and what is causing it. Please i need help.

def train(self,images,lables, recogType=0):
        self.images = images
        self.lables = np.array(lables)

        'arg = recogType:[cv2.face.LBPHFaceRecognizer_create(),cv2.face.FisherFaceRecognizer_create(),cv2.face.EigenFaceRecognizer_create()'
        recogs = cv2.face.LBPHFaceRecognizer_create(),cv2.face.FisherFaceRecognizer_create(),cv2.face.EigenFaceRecognizer_create()
        self.recognizer = recogs[recogType]()    
        self.recognizer.train(self.images,self.lables)

Solution

  • The specific problem is with this line:

    self.recognizer = recogs[recogType]() 
    

    By placing braces () on the end, you are trying to call the recognizer, as the error says. Change this to

    self.recognizer = recogs[recogType]
    

    //Disclaimer - there may be other problems.