Ask Your Question
0

Build OpenCV for Python

asked 2016-01-24 06:22:48 -0600

peter_cz gravatar image

Dears,

I'm trying to build OpenCV including with CMAKE option "BUILD_opencv_python2" - I finshed always with errors:

CMAKE configurtion says:

Detected version of GNU GCC: 53 (503)
CUDA compilation is disabled (due to only Visual Studio compiler supported on your platform).
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)

General configuration for OpenCV 3.1.0-dev =====================================
  Version control:               1cd3c6f

  Platform:
    Host:                        Windows 6.1.7601 AMD64
    CMake:                       3.4.2
    CMake generator:             MinGW Makefiles
    CMake build tool:            C:/mingw-w64/i686-5.3.0-posix-dwarf-rt_v4-rev0/mingw32/bin/mingw32-make.exe
    Configuration:               Release
  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                C:/mingw-w64/i686-5.3.0-posix-dwarf-rt_v4-rev0/mingw32/bin/g++.exe  (ver 5.3.0)
    C++ flags (Release):         -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -O2 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  C:/mingw-w64/i686-5.3.0-posix-dwarf-rt_v4-rev0/mingw32/bin/gcc.exe
    C flags (Release):           -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -fvisibility=hidden -O2 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      
    Linker flags (Debug):        
    Precompiled headers:         YES
    Extra dependencies:          comctl32 gdi32 ole32 setupapi ws2_32 vfw32 winmm
    3rdparty dependencies:       zlib libjpeg libwebp libpng libtiff libjasper IlmImf

  OpenCV modules:
    To be built:                 core flann imgproc ml photo video imgcodecs shape videoio highgui objdetect superres ts features2d calib3d stitching videostab python2
    Disabled:                    world
    Disabled by dependency:      -
    Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python3 viz

  Python 2:
    Interpreter:                 C:/Python27/python.exe (ver 2.7.10)
    Libraries:                   C:/Python27/libs/libpython27.a (ver 2.7.10+)
    numpy:                       C:/Python27/Lib/site-packages/numpy/core/include (ver 1.9.2)
    packages path:               C:/Python27/Lib/site-packages

  Python (for build):            C:/Python27/python.exe

I have installed python, numpy - it's working.

First question: Do not understand why CMAKE says: Found unsuitable version "2.7.10", but required is at least "3.4" ?

Secondly - when "make" runs to build it ends up with:

[ 98%] Linking CXX shared module ..\..\lib\cv2.pyd
C:/Python27/libs/libpython27.a: error adding symbols: File format not recognized
collect2.exe: error ...
(more)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-01-24 14:09:03 -0600

valentine gravatar image

Dear Peter,

To build opencv 3.1 for python you need python 3.4 installed on computer. Currently i guess you have python 2.7 installed. To use opencv for python 2.7 just copy the pre-built file \build\python\2.7\x64\cv2.pyd from your opencv path to site-packages folder of your python installation folder (windows OS). However to build opencv for python you require python 3.0 and above installed on your system.

edit flag offensive delete link more

Comments

Dear Valentine

Are you sure about that?, and if you did it and it worked, do you have xfeatures2d? because this is the module I need the most to use for my own project

tes gravatar imagetes ( 2016-01-25 08:07:46 -0600 )edit

Since I am building python2 why should I need to have python3.4? Does it mean that opencv 3.1 does not support python2?

peter_cz gravatar imagepeter_cz ( 2016-02-05 15:29:32 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-01-24 06:22:48 -0600

Seen: 987 times

Last updated: Jan 24 '16