Ask Your Question
0

problem with library openCV contrib has no 'face' attribute

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

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'

C:\fakepath\2018-12-10-093014_1824x984_scrot.png

edit retag flag offensive close merge delete

Comments

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 -0600 )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/02_face_training.py", 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 opencv_contrib.zip https://github.com/Itseez/opencv_cont... unzip opencv_contrib.zip 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 -0600 )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 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

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

supra56 gravatar image

updated 2018-12-12 12:34:03 -0600

Change this:

recognizer = cv2.face.LBPHFaceRecognizer_create()

ref:(documentation)

edit flag offensive delete link more

Comments

2

this kind of answers should have a link to documentation

sturkmen gravatar imagesturkmen ( 2018-12-12 10:47:33 -0600 )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()
recognizer.setRadius(5)
sturkmen gravatar imagesturkmen ( 2018-12-12 11:05:39 -0600 )edit

@sturkmen . Thank you for comment.

supra56 gravatar imagesupra56 ( 2018-12-12 11:18:32 -0600 )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 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 1,848 times

Last updated: Dec 12 '18