17

I think I have some issues with the windows system or python 3.6 version. I am facing some attribute error. I have checked and double checked my code and there is no error and i also compare my code to others and i have seen there is no error. then why i am facing this kind of error. I am adding my code here:

recognizer module

and i am facing following error.

C:\Users\MAN\AppData\Local\Programs\Python\Python36\python.exe C:/Users/MAN/PycharmProjects/facerecognition/Recognise/recognizerr.py Traceback (most recent call last): File "C:/Users/MAN/PycharmProjects/facerecognition/Recognise/recognizerr.py", line 11, in font = cv2.cv.InitFont(cv2.cv.CV_FONT_HERSHEY_SIMPLEX, 1, 1, 0, 1, 1) AttributeError: module 'cv2.cv2' has no attribute 'cv'

Process finished with exit code 1

Is this the Windows issue or it shows only error in Python 3.6 version? for you kind information I am using Python 3.6 in Windows platform.

Dharmang
  • 3,018
  • 35
  • 38
Manjurul Ahsan
  • 917
  • 2
  • 7
  • 8
  • 8
    Please do *not* post a *screenshot* of the code, but the *actual* code. – Willem Van Onsem Jun 19 '17 at 22:29
  • 1
    Possible duplicate of [AttributeError: 'module' object has no attribute 'InitFont'](https://stackoverflow.com/questions/44021999/attributeerror-module-object-has-no-attribute-initfont) – alkasm Jun 20 '17 at 00:26

3 Answers3

24

in Opencv3 the cv module is deprecated. So, in line 11 you can initialize the font like following:

font = cv2.FONT_HERSHEY_SIMPLEX
Nuhil Mehdy
  • 2,424
  • 1
  • 21
  • 23
7

font = cv2.cv.CV_FONT_HERSHEY_SIMPLEX

I worked on different variable (CV_CAP_PROP_FRAME_WIDTH), and it took me soo long to understand that you also need to remove the "CV_".

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
Yam Shargil
  • 445
  • 5
  • 9
0

Worked for me with font = cv2.FONT_HERSHEY_SIMPLEX as the best answer suggested.

A.Salim
  • 11
  • 1