Ask Your Question
0

IMREAD_GRAYSCALE error in facerec_demo.py

asked 2012-08-07 22:52:08 -0600

rkappler gravatar image

updated 2018-10-05 23:18:01 -0600

Trying to run FaceRecognizer in Python (see (http://code.opencv.org/projects/opencv/repository/revisions/master/entry/samples/python2/facerec_demo.py) and (http://answers.opencv.org/question/253/broken-python-bindings-with/), but I'm stuck.

I'm running python 2.7 in Ubuntu Precise on a 64 bit HP G62. I opened up a terminal, cd'd to the working directory, entered:

python facerec_demo.py path/to/orl_faces path/to/empty/data/directory

I created for out_dir and I'm getting the following error:

Unexpected error: 
<type 'exceptions.AttributeError'>
Traceback (most recent call last): File "facerec_demo.py", 
line 100, in <module> [X,y] = read_images(sys.argv[1]) File "facerec_demo.py", 
line 75, in read_images im = cv2.imread(os.path.join(subject_path, filename), cv2.IMREAD_GRAYSCALE) 
AttributeError: 'module' object has no attribute 'IMREAD_GRAYSCALE'

Any guidance? regards, Richard

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2012-08-08 10:49:03 -0600

Which OpenCV version are you using? I have built my OpenCV some days ago and it doesn't have problems with cv2.IMREAD_GRAYSCALE, see:

philipp@mango:~$ python
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) 
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.IMREAD_GRAYSCALE
0L

If something like the above already fails for you, chances are good your OpenCV version is too old.

edit flag offensive delete link more

Comments

Right. I should have thought of that. The IMREAD_GRAYSCALE is no longer throwing an error, now I'm getting: Traceback (most recent call last): File "facerec_demo.py", line 106, in <module> model = cv2.createEigenFaceRecognizer() AttributeError: 'module' object has no attribute 'createEigenFaceRecognizer'

rkappler gravatar imagerkappler ( 2012-08-08 15:32:42 -0600 )edit

No, wait. I didn't realize there was a new rev out. I'm on 2.4.1 Do I need to upgrade to 2.4.2?

regards, Richard

rkappler gravatar imagerkappler ( 2012-08-08 15:52:05 -0600 )edit

Okay, the answer to that question would be no. I installed 2.4.2, still getting the same error. I'm going to post this as a new question. regards, Richard

rkappler gravatar imagerkappler ( 2012-08-08 16:54:45 -0600 )edit

Question Tools

Stats

Asked: 2012-08-07 22:52:08 -0600

Seen: 1,488 times

Last updated: Aug 08 '12