-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

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Muhammad
  • 1
  • 4

1 Answers1

1

You need to install opencv-contrib:

pip install opencv-contrib-python

See this Github issue and this SO thread.

desertnaut
  • 57,590
  • 26
  • 140
  • 166