python sample script error : AttributeError: 'module' object has no attribute 'LINE_AA' (OpenCV 3.1, python 2.7.9)
Hi, posting the content below. Executed, as python facedetect.py in sample scripts of opencv version 3.1:
face detection using haar cascades
USAGE: facedetect.py [--cascade <cascade_fn>] [--nested-cascade <cascade_fn>] [<video_source>]
Traceback (most recent call last): File "facedetect.py", line 68, in <module> draw_str(vis, (20, 20), 'time: %.1f ms' % (dt*1000)) File "/media/bhargav/Bhargav_WD1/temp_dir/home_bhargav/OpenCV/samples/python/common.py", line 83, in draw_str cv2.putText(dst, s, (x+1, y+1), cv2.FONT_HERSHEY_PLAIN, 1.0, (0, 0, 0), thickness = 2, lineType=cv2.LINE_AA) AttributeError: 'module' object has no attribute 'LINE_AA'
Kindly help. Thanks in advance.
please try a
cv2.__version__
Thank you Berak. It outputs: '2.4.9.1'
But i have version 3.1 installed (checked library files as *.so.3.1). The sample program opencv_version.py also is showing 2.4.9.1 in output.
cv2.LINE_AA is only available in opencv3. and well, now you have to find out, why python prefers the wrong cv2.so ....
Used steps: clone source from https://github.com/opencv/opencv.git. sudo apt-get update sudo apt install python-pip sudo pip install --upgrade pip sudo apt-get upgrade libv4l-dev cd /usr/include/linux sudo ln -s ../libv4l1-videodev.h videodev.h // This didnt exist before.But videodev2.h exists in my folder. sudo apt-get install python-setuptools python-dev build-essential sudo apt-get install cmake sudo apt-get install python-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy subversion libportmidi-dev ffmpeg libswscale-dev libavformat-dev libavcodec-dev cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON .. sudo make sudo make install sudo apt-get install python-opencv
Sorry, not readable format as shrinked due to limit on length. That is the setup steps I followed. Using python 2.7 From OpenCV source git repository, did cmake and built make file. Used makefile to install OpenCV. The sample file is from the same source code, so it should work right? Or sample python files are not updated along with python versions?
I believe I have installed OpenCV 3.1 because of which 3.1 so files are installed. Not sure why __vesion__ is printing differently.
Oh sorry. I understand your answer now. I am checking why wrong cv2 got installed/picked. ie cv2.so corresponding to 2.4.x version rather than 3.1.
Hi, I got the lib file which one is picked up. the cv2.so is picked up as : /usr/lib/python2.7/dist-packages/cv2.x86_64-linux-gnu.so
This .so is getting created through the command: sudo apt-get install python-opencv
Can I get help on resolving this... how do I make sure the so file corresponds to openCV3.1 and not 2.4.x