Ask Your Question

problem with library openCV contrib has no 'face' attribute

asked 2018-12-10 08:40:58 -0500

I have installed the openCV library contrib however when I want to use the section called face I always get the same error, I have tried with different versions of the library and I check that it contains all the elements of the same one between them "face" but really I have not made it work, I want help, please. the error that I get in python is the following: AttributeError: module 'cv2' has no attribute 'face'


edit retag flag offensive close merge delete


would you be so kind to replace the (useless here) screenshot with a TEXT version of your code & errors so we can quote you properly / it can be indexed for search, etc.? thank you !

also, opencv version ? how did you install that ?

berak gravatar imageberak ( 2018-12-10 09:21:58 -0500 )edit

The error that comes out to me already as it specifies it in the part above is this: Tracking (recent calls latest):

File "/home/pi/recognition/", line 10, in <module> recognizer = cv2.face.LBPHFaceRecognizer_create () AttributeError: module 'cv2' has no 'face' attribute

I have a raspberry pi3 and the python version is 3.5. At the moment I am using the operating system and I have version 3.4.0 of openCV contrib installed. download it from here: wget -O unzip This library is installed within python 3.5, as well as it is well installed and in another code is not well, however, when using the "face" does not work I remain attentive to any possible help, in advance.

Anderson96 gravatar imageAnderson96 ( 2018-12-10 11:11:27 -0500 )edit

possible reasons:

  • you did not install it properly, and now you're using a previous cv2 version
  • the face module was never built ( try a print(cv2.getBuildInformation())
  • there is more than 1 python, andyou're using the wrong one
berak gravatar imageberak ( 2018-12-10 23:04:55 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-12-12 10:18:08 -0500

supra56 gravatar image

updated 2018-12-12 12:34:03 -0500

Change this:

recognizer = cv2.face.LBPHFaceRecognizer_create()


edit flag offensive delete link more



this kind of answers should have a link to documentation

sturkmen gravatar imagesturkmen ( 2018-12-12 10:47:33 -0500 )edit

either the documentation is wrong or something else but @supra56 is right (OpenCV 4.0.0)

the code below is worked to me

import numpy as np
import cv2 as cv

recognizer = cv.face_LBPHFaceRecognizer.create()
sturkmen gravatar imagesturkmen ( 2018-12-12 11:05:39 -0500 )edit

@sturkmen . Thank you for comment.

supra56 gravatar imagesupra56 ( 2018-12-12 11:18:32 -0500 )edit

I appreciate the help given but unfortunately both the code and the answers that have been given, since my code can not be operated right by the library.

Anderson96 gravatar imageAnderson96 ( 2018-12-13 14:23:18 -0500 )edit

Question Tools

1 follower


Asked: 2018-12-10 08:40:58 -0500

Seen: 1,190 times

Last updated: Dec 12 '18