3

I am currently working on a project that add a new module to OpenCV 3.0 beta so I am trying to use my own compiled version with Python (just as a remark, the C++ version works).

Since I don't want to mess up with versions of OpenCV and Python already installed, I did not add to ldconfig my specific build/installation of OpenCV 3.0 beta and I would like to use it in a python virtualenv if possible.

So far I have setup the venv and since cv2 is not accessible in it, I update the PYTHONPATH to add the folder containing the cv2.so file (created with sudo apt-get install python-opencv). However, it is not the right version of opencv binding that are loaded :

$ python -c "import cv2; print cv2.__version__"
2.4.8

Have any idea on what I could do ?

EDIT (thanks @otibom):

My build seems to be the reason why I don't have the right cv2.so file. The results of cmake are :

--   Python 2:
--     Interpreter:                 /usr/bin/python2.7 (ver 2.7.6)
--     Libraries:                   NO
--     numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.8.2)
--     packages path:               lib/python2.7/dist-packages

Is there a way to correct that ?

2 Answers 2

1

Regarding the "libraries not found" problem, I removed the file CMakeCache.txt and at the following cmake command it found python libraries. (but I have no idea why that happened)

Sign up to request clarification or add additional context in comments.

1 Comment

I had the same problem under Windows (Python library keeps getting disabled); in the end, I had a look at the CMakeLists.txt of the Python module, and found out that enabling the option "Build_opencv_world" would disable the Python library.
0

Compiling OpenCV 3.0 will create its own cv2.so file containing your new module, typically in your opencv3-0-0-beta/build directory. You need to add the OpenCV 3.0 build directory to PYTHONPATH instead of the one created by apt-get.

3 Comments

Thank you it helps that you confirm that. Actually I realized that that file is not created with my build. It might be because I think I have another issue (just realized it since I was not using OpenCV with Python before) : cmake does find the binaries of Python but not the libraries. I will update my question with that so it is clearer
Actually I solved the "finding library" problem and recompiled but I did not find that file in the build directory : find -iname "cv2.so" gave me nothing. Where exactly should it be ?
Nevermind, I forgot to compile in RELEASE mode, maybe that's why the file was not generated

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.