Reputation: 31
Please can anyone help with what to change on installing opencv 3.0.0-beta on ubuntu 14.04 having GPU running theano so that it doesn't remove my nvidia as it did intially. I use anaconda python 2.7 and after installing opencv, it works with c++ example but not with python example because of Error importing module cv2. Figured out its not linking with python and "install conda cv2" but it asks to make cmake. I did but that does not complete successfully anymore. Any help. Thanks on what to change in cmake in the link https://askubuntu.com/questions/537268/installing-opencv-in-ubuntu-14-04
Upvotes: 3
Views: 3456
Reputation: 51
I was having a similar issue getting OpenCV 3.0 beta to compile with the python wrappers using Anaconda. I ended up using the following call to cmake:
cd <open_cv_source_directory>
mkdir RELEASE
cd RELEASE
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/home/<user>/opencv \
-D PYTHON_INCLUDE_DIR=/home/<user>/anaconda/include/python2.7/ \
-D PYTHON_INCLUDE_DIR2=/home/<user>/anaconda/include/python2.7 \
-D PYTHON_LIBRARY=/home/<user>/anaconda/lib/libpython2.7.so \
-D PYTHON_PACKAGES_PATH=/home/<user>/anaconda/lib/python2.7/site-packages/ \
-D BUILD_EXAMPLES=ON \
-D BUILD_NEW_PYTHON_SUPPORT=ON \
-D PYTHON2_LIBRARY=/home/lm/anaconda/lib/libpython2.7.so \
-D BUILD_opencv_python3=OFF \
-D BUILD_opencv_python2=ON ..
I'm not sure if all of that was needed, but it now configures correctly and then builds/installs correctly.
Upvotes: 5
Reputation: 1
Yes, there is something wrong with the cmake script of opencv3.0.0, when dealing with anaconda installed in a local directory. I tried to config the cmake build options as instructed in http://docs.opencv.org/3.0.0/d7/d9f/tutorial_linux_install.html , but it turned out that python libs could not be correctly found. Then, i tried multiple combinations of cmake build options and found the following works:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/home/css/opencv-3.0.0 -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=/home/css/opencv-code/opencv_contrib/modules -D BUILD_EXAMPLES=ON -D BUILD_opencv_python2=ON -D PYTHON2_EXECUTABLE=/home/css/anaconda2/bin/python -D PYTHON_INCLUDE_DIR=/home/css/anaconda2/include/python2.7 -D PYTHON_INCLUDE_DIR2=/home/css/anaconda2/include/python2.7 -D PYTHON_LIBRARY=/home/css/anaconda2/lib/libpython2.7.so -D PYTHON2_NUMPY_INCLUDE_DIRS=/home/css/anaconda2/lib/python2.7/site-packages/numpy/core/include ..
When finish make & make install, just link cv2.so under /lib/python2.7/site-packages/cv2.so into anaconda's site-packages
Upvotes: 0
Reputation: 2903
I was facing similar problem as you. OpenCV 3.0 beta has to be built from source and there is some bug in CMake due to which the CMake will not link the Python libs.
One option is to follow this excelent tutorial Install opencv for Python 3.3 It is for Python 3.3 but I was able to compile against 2.7.9 just fine. If you are using CMake GUI you can check in the output, after you run generete, which modules will be built and which won't.
When I just launched the CMake it successfully found all required libs and all was fine. But when I changed some settings it failed to find Python. So I think you are better off using the command line tool and specify manually all the options you need.
Upvotes: 0