1

I have a problem with face detection.

code:

import cv2
import os
import numpy as np
from PIL import Image 

path = 'dataSet'
cascadePath = "Classifiers/face.xml"

faceCascade = cv2.CascadeClassifier(cascadePath);
cam = cv2.VideoCapture(0)
recognizer = cv2.face.LBPHFaceRecognizer_create()
recognizer.load('trainer/trainer.yml')

AttributeError:

'cv2.face_LBPHFaceRecognizer' object has no attribute 'Load'

Help me, I already researched and still have not found an answer.

I am using python 3.6.1 and opencv 3.0

4
  • Im pretty sure if you are using OpenCV3 that it has been deprecated, I don't know what the solution is though Commented Oct 27, 2017 at 14:19
  • i am use python 3.6.1 and opencv 3.0 Commented Oct 27, 2017 at 14:28
  • @GPPK OpenCV 3 is definitely not deprecated. Commented Oct 27, 2017 at 14:46
  • @cwallenpoole not opencv3, LBPHFaceRecognizer class. I think it's been replaced and can only be used in Opencv2. Sorry if that wasn't clear Commented Oct 27, 2017 at 14:47

1 Answer 1

1

That's because it doesn't have that property. You mean read.

recognizer = cv2.face.LBPHFaceRecognizer_create()
recognizer.read('trainer/trainer.yml')

Here's the help:

 |  read(...)
 |      read(filename) -> None
 |      .   @brief Loads a FaceRecognizer and its model state.
 |      .
 |      .   Loads a persisted model and state from a given XML or YAML file . Every FaceRecognizer has to
 |      .   overwrite FaceRecognizer::load(FileStorage& fs) to enable loading the model state.
 |      .   FaceRecognizer::load(FileStorage& fs) in turn gets called by
 |      .   FaceRecognizer::load(const String& filename), to ease saving a model.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.