Hi i need your help

Hi there, i was buy camera module and i was try facial recognition i have some problem need you guys help me to figure out,

i got error “recognizer = cv2.face.LBPHFaceRecognizer_create()” error was ">>> %Run 03_face_recognition.py
Traceback (most recent call last):
File “/home/tory/Desktop/piFace-master/FacialRecognition/03_face_recognition.py”, line 17, in
recognizer = cv2.face.LBPHFaceRecognizer_create()
AttributeError: module ‘cv2.cv2’ has no attribute ‘face’

Hey @Toan270541, Welcome to the forums!

The error you are getting “‘cv2.cv2’ has no attribute ‘face’” indicates that cv2.face module is not recognized by the dataset. Usually it’s because the required library for OpenCV was not properly installed.

First you need to check your OpenCV version. The following lines of code will help you do that:

import cv2

If OpenCV contrib libraries are not properly installed or not installed at all, you can install them by using the following commands:

sudo pip3 install opencv-contrib-python

If this does not solve it, you may need to uninstall and reinstall opencv, then install opencv-contrib-python:

sudo pip3 uninstall opencv-python
sudo pip3 install opencv-contrib-python

If this doesn’t work its possible that Thonny is not looking in the right place for your libraries. You should be able to fix this by changing your Python interpreter (the environment Thonny uses to run Python).

Alternatively you can reinstall the required packages (opencv-python, numpy, etc) in Thonny directly using the Tools → Manage packages menu.

If these suggestions don’t work for you would you be able to share your code so we can see line 17 (the one that is triggering this error)

Hope this helps!