Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Attribute Error: module 'cv2' has no attribute 'face'

Hi all,

First of all, I am quite a newbie with the Raspberry Pi, Python and OpenCV so please forgive me for likely asking "stupid" questions at times.

Following is my setup: I have a Kuman pi camera connecting to a Raspberry Pi 3 Model B for some experiments with OpenCV Facial Recognition.

I followed the instructions on Pyimagesearch and was able to get OpenCV to install and running on the pi (or so I thought). As far as I know, the pi cam allowed me to take images and save them (i.e. cv2.imwrite, etc) as positive images for recognition training step.

The training step is where i run into the problem when I tried to execute the following line in the script:

model = cv2.face.createEigenFaceRecognizer()

The error message is: AttributeError: module 'cv2' has no attribute 'face'

Every where that I searched on the internet present the problem as needing "extra modules" in the opencv_contrib which I thought I already have (I have populated folders of ~/opencv-3.3.0/build/modules and ~/opencv_contrib-3.3.0/modules). The problem seems to be that python does not know to look for "face" attribute in the opencv_contrib-3.3.0 folder for some reason.

Any suggestions would be very appreciated! Thanks in advance!

Also note that I created a virtualenv and virtualenvwrapper while installing opencv. Does this have anything to do with it?