-1

I am Building the Face Recognition and Identification model in python using the OpenCV library but when creating the recognizer I am getting this error I am new to OpenCV can anyone help me in this.

 import os
 import cv2 
 import numpy as np
 from PIL import Image
 import pickle
 BASE_DIR=os.path.dirname(os.path.abspath(__file__))
 IMG_DIR=os.path.join(BASE_DIR,"images")
 y_labels=[]
 current_ID=0
 labels_ids={}
 x_train=[]
 face_cascade=cv2.CascadeClassifier('cascades/data
      /haarcascade_frontalface_alt2.xml')
 recognizer = cv2.face.LBPHFaceRecognizer_create()

The error:

Open CV:AttributeError: module 'cv2.cv2' has no attribute 'face' 

LBPHFaceRecognizer is not Working

0

1 Answer 1

1

You need to install opencv-contrib:

pip install opencv-contrib-python

See this Github issue and this SO thread.

Sign up to request clarification or add additional context in comments.

2 Comments

I have tried this does not work
@Muhammad It is good practice to include what you have already tried and didn't work in your post...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.