Ask Your Question

Windows Python opencv_contrib install doesn't work

asked 2015-09-08 10:42:29 -0500

cs gravatar image

updated 2015-09-09 09:37:35 -0500

Hey everyone,

I've got following problem, I want to use sift/surf feature detection with Python OpenCV 3.

I followed the install-guide for installing "OpenCV from source" and built the ALL_BUILD and the INSTALL project. But nothing happened to my Python27 directory (no errors in the builds, everything was successful).

My question is: how can I install the INSTALL project to my python directory or how can I get the new cv2.pyd file which I could copy to the python directory? Or is there a known problem with a python-opencv3-contrib installation?

I deleted the cv2.pyd file which I copied to the python directory in a previous installation (prebuild binaries installation) before and after a INSTALL build but nothing changed. If I delete the file, following error will occur: "ImportError: No module named cv2".

Thank you for your help!

Looking for Mfapi.h
Looking for Mfapi.h - found
Could NOT find PythonInterp: Found unsuitable version "2.7.10", but required is at least "3.4" (found C:/Python27/python.exe)
Could NOT find PythonInterp: Found unsuitable version "2.7.10", but required is at least "3.2" (found C:/Python27/python.exe)
The system was unable to find the specified registry key or value.

The system was unable to find the specified registry key or value.

Tesseract:   NO
  videoio: Removing WinRT API headers by default

General configuration for OpenCV 3.0.0 =====================================
  Version control:               unknown

    Host:                        Windows 6.2 AMD64
    CMake:                       3.3.1
    CMake generator:             Visual Studio 12 2013 Win64
    CMake build tool:            C:/Program Files (x86)/MSBuild/12.0/bin/MSBuild.exe
    MSVC:                        1800

    Built as dynamic libs?:      NO
    C++ Compiler:                C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/x86_amd64/cl.exe  (ver 18.0.21005.1)
    C++ flags (Release):         /DWIN32 /D_WINDOWS /W4 /GR /EHa  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /wd4251 /wd4324 /MP8  /MT /O2 /Ob2 /D NDEBUG  /Zi
    C++ flags (Debug):           /DWIN32 /D_WINDOWS /W4 /GR /EHa  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /wd4251 /wd4324 /MP8  /D_DEBUG /MTd /Zi /Ob0 /Od /RTC1 
    C Compiler:                  C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/x86_amd64/cl.exe
    C flags (Release):           /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi    /MP8  /MT /O2 /Ob2 /D NDEBUG  /Zi
    C flags (Debug):             /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi    /MP8  /D_DEBUG /MTd /Zi /Ob0 /Od /RTC1 
    Linker flags (Release):      /machine:x64  /NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrtd.lib /INCREMENTAL:NO  /debug /NODEFAULTLIB:libcmtd.lib
    Linker flags (Debug):        /machine:x64  /NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrtd.lib /debug /INCREMENTAL  /NODEFAULTLIB:libcmt.lib
    Precompiled headers:         YES
    Extra dependencies:          comctl32 gdi32 ole32 setupapi ws2_32 vfw32
    3rdparty dependencies:       zlib libjpeg libwebp libpng libtiff libjasper IlmImf

  OpenCV modules:
    To be built:                 hal core ...
edit retag flag offensive close merge delete



you will need (since SIFT/SURF/nonfree was moved to xfeatures2d there). please see readme there, on how to add it to your cmake, and rebuild.

berak gravatar imageberak ( 2015-09-08 11:03:32 -0500 )edit

I followed the readme and did exactly what is written there. I configured/generated it with CMake, I followed these instruction link text, as well as I added OPENCV_EXTRA_MODULES_PATH like explained in the readme. Then I built it with VS13 (ALL_BUILD) and I buitl the install project (INSTALL) like explained in the instructions. But it didn't change anything to my Python folder, just to the opencv/build folder. And now I don't know how to install it correctly to Python with the .pyd file. But even though thank you for your fast reply

cs gravatar imagecs ( 2015-09-09 05:59:38 -0500 )edit

please go back to your VS13 .sln, and build the INSTALL project. this will do all the copying.

berak gravatar imageberak ( 2015-09-09 06:04:17 -0500 )edit

Done again.... But nothing has changed. The INSTALL didn't any copying. It only changed the opencv/build folder but nothing in the python folder... What could I do? Do I have to change something in the project? Thank you

cs gravatar imagecs ( 2015-09-09 06:46:45 -0500 )edit

carefully check your build logs again for errors, they are hard to spot in such a large output.

you should try a cv2.getBuildInformation() , to see, if anything changed.

then, it's not in the root python folder, but in lib/site-packages (you can even try to copy it manually there)

berak gravatar imageberak ( 2015-09-09 06:51:14 -0500 )edit

I checked all build logs, all the entries are like that one (no errors): Up-to-date: C:/opencv/build/install/include/opencv2/cvconfig.h and finished with that line: 1>Done Building Project "C:\opencv\build\INSTALL.vcxproj" (Build target(s)). And my cv2.getBuildInformation() is the same after the installation, it's still the prebuild binaries one. I would like to copy it manually, but the INSTALL didn't create the cv2.pyd file. Should I send you the logs? Or is there any chance to download the cv2.pyd file with included xfeatures2d?

cs gravatar imagecs ( 2015-09-09 07:12:20 -0500 )edit

"Should I send you the logs ?" - well, you could append the cmake output to your question (it won't fit in a comment) . maybe the problem already shows up there.

berak gravatar imageberak ( 2015-09-09 08:55:06 -0500 )edit

Thank you very much! I attached the configuration output to the question. I suppose there is a problem because of python version 2.7.10 ("Could NOT find PythonInterp.....") but for my project I can't use python 3.x

cs gravatar imagecs ( 2015-09-09 09:30:23 -0500 )edit

ah, thanks, that's indeed helpful:

 Disabled:                    python2

it found your python exe, but not the required headers, or the python27.lib to lnk to. try to add path to those manually.

unless, " Disabled: python2 " goes away, there will be no progress. atm. it's still a cmake (find the dependancies)problem.

you will have to set:

  • PYTHON2_NUMPY_INCLUDE_DIRS //yes, numpy is required

on my box, outcome looks like this:

  Python 2:
    Interpreter:                 D:/Programme/Python27/python.exe (ver 2.7.3)
    Libraries:                   D:/Programme/Python27/libs/python27.lib (ver 2.7.3)
    numpy:                       D:/Programme/Python27/lib/site-packages/numpy-1.7.0-py2.7-win32.egg/numpy/core/include (ver 1.7.0)
berak gravatar imageberak ( 2015-09-09 09:31:39 -0500 )edit

Yes I'm using the cmake-gui. I already added the paths manually as you can see in the recently attached image above. Nevertheless python2 is disabled.. Do I need to add more paths?

cs gravatar imagecs ( 2015-09-09 09:40:33 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2015-09-16 08:28:30 -0500

cs gravatar image

The first problem was that I forgot enable BUILD_opencv_python2. It's required to enable these value, because it will build your Python opencv file.

The second problem was that I choosen VS2013 x64 in CMake, because I installed these version. But the correct VS version for Python 2.7.xx is VS2013 x86, because Python is 32bit and not 64bit.

After I changed the VS2013 type everthing went well and I could install OpenCV_contrib without problems.

Thank you for your help ;)

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-09-08 10:42:29 -0500

Seen: 3,135 times

Last updated: Sep 16 '15