0

I want to work on this face recognition project but when I run the train.py, I get the following error:

recognizer = cv2.face.createFisherFaceRecognizer()
AttributeError: 'module' object has no attribute 'face'

I've googled it but I didn't find anything useful.

I'm running python 2.7 and OpenCV 3.2.0.

Any help would be appreciated.

rayryeng
  • 102,964
  • 22
  • 184
  • 193
mohamad danesh
  • 326
  • 1
  • 6
  • 21
  • probably your "import cv2" never imported correctly – user1767754 Feb 19 '17 at 12:21
  • @user1767754 it is installed correctly, but I think this is because of the OpenCV version. I haven't found anything helpful on the web. – mohamad danesh Feb 19 '17 at 14:32
  • The "face" module is from [opencv_contrib](https://github.com/opencv/opencv_contrib/tree/master/modules/face). Are you sure that the build of OpenCV you're using contains this? AFAIK most of the standard builds don't contain the contrib modules. – Dan Mašek Feb 19 '17 at 16:37
  • @DanMašek I tried `brew install opencv --with-contrib --with-ffmpeg --with-tbb --without-tests --HEAD` but it says: `Warning: homebrew/science/opencv: this formula has no --with-contrib option so it will be ignored!`. What should I do now? – mohamad danesh Feb 19 '17 at 18:52
  • Sorry, don't have any experience with `brew`. Search around a bit, I'd assume you're not the first person trying to do this. Another option might be to just try to build it straight from sources just using CMake. – Dan Mašek Feb 19 '17 at 19:48
  • 1
    @DanMašek Thanks man, your first comment helped a lot. The answer is to use OpenCV3 to work. Something like this: `brew install opencv3 --with-contrib` – mohamad danesh Feb 19 '17 at 22:12
  • 1
    @mohamaddanesh Great. However, instead of editing your title as you have, you should write your own answer to your question (and accept it). – Dan Mašek Feb 19 '17 at 22:14

1 Answers1

1

As @DanMašek in the comments said, the answer is to add the open_contrib module in the OpenCV to use face module. It can be done while installing OpenCV, like this:

brew install opencv3 --with-contrib
mohamad danesh
  • 326
  • 1
  • 6
  • 21