Ask Your Question

Revision history [back]

Build Opencv 3 alpha with Python support

I looked up how homebrew builds opencv 2 and I made this line

cmake -DCMAKE_OSX_DEPLOYMENT_TARGET= -DPYTHON_LIBRARY="`python-config --prefix`/lib/libpython2.7.dylib" -DPYTHON_INCLUDE_DIR="`python-config --prefix`/include/python2.7" ..

With this cmake I get following result: (only important parts)

Found PythonInterp: /usr/local/bin/python2.7 (found suitable version "2.7.8", minimum required is "2.7")
-- Found PythonInterp: /usr/local/bin/python3 (found suitable version "3.4.1", minimum required is "3.4")
-- Could NOT find PythonLibs: Found unsuitable version "2.7.5", but required is exact version "3.4.1" (found PYTHON_LIBRARY-NOTFOUND)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named 'numpy'
....
....
....
--
-- General configuration for OpenCV 3.0.0-dev =====================================
--   Version control:               458bde5
--
--   Platform:
--     Host:                        Darwin 13.3.0 x86_64
--     CMake:                       3.0.1
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               Release
--
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ Compiler:                /usr/bin/c++  (ver 5.1.0.5030040)
--     C++ flags (Release):         -fsigned-char -W -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 -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -Wno-long-long -fno-omit-frame-pointer -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -W -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 -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -Wno-long-long -fno-omit-frame-pointer -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /usr/bin/cc
--     C flags (Release):           -fsigned-char -W -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 -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -Wno-long-long -fno-omit-frame-pointer -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -W -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 -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -Wno-long-long -fno-omit-frame-pointer -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):
--     Linker flags (Debug):
--     Precompiled headers:         NO
--
--   OpenCV modules:
--     To be built:                 core flann imgproc imgcodecs videoio highgui ml features2d calib3d objdetect photo video shape stitching superres ts videostab
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 androidcamera cuda cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaoptflow cudastereo cudawarping cudev java python2 python3 viz
--
--   GUI:
--     QT:                          NO
--     Cocoa:                       YES
--     OpenGL support:              NO
--     VTK support:                 NO
--
--   Media I/O:
--     ZLib:                        build (ver 1.2.8)
--     JPEG:                        build (ver 90)
--     WEBP:                        build (ver 0.3.1)
--     PNG:                         build (ver 1.5.12)
--     TIFF:                        build (ver 42 - 4.0.2)
--     JPEG 2000:                   build (ver 1.900.1)
--     OpenEXR:                     build (ver 1.7.1)
--     GDAL:                        NO
--
--   Video I/O:
--     DC1394 1.x:                  NO
--     DC1394 2.x:                  NO
--     FFMPEG:                      YES
--       codec:                     YES (ver Unknown)
--       format:                    YES (ver Unknown)
--       util:                      YES (ver Unknown)
--       swscale:                   YES (ver Unknown)
--       gentoo-style:              YES
--     OpenNI:                      NO
--     OpenNI PrimeSensor Modules:  NO
--     OpenNI2:                     NO
--     PvAPI:                       NO
--     GigEVisionSDK:               NO
--     QuickTime:                   NO
--     QTKit:                       YES
--     V4L/V4L2:                    NO/NO
--     XIMEA:                       NO
--
--   Other third-party libraries:
--     Use IPP:                     8.1.1 [8.1.1]
--          at:                     /Users/amotsjonov/work/opencv/3rdparty/ippicv/unpack/ippicv_osx
--     Use IPP Async:               NO
--     Use Eigen:                   NO
--     Use TBB:                     NO
--     Use OpenMP:                  NO
--     Use GCD                      YES
--     Use Concurrency              NO
--     Use C=:                      NO
--     Use Cuda:                    NO
--     Use OpenCL:                  YES
--
--   OpenCL:
--     Version:                     static
--     libraries:                   -framework OpenCL
--     Use AMDFFT:                  NO
--     Use AMDBLAS:                 NO
--
--   Python 2:
--     Interpreter:                 /usr/local/bin/python2.7 (ver 2.7.8)
--
--   Python 3:
--     Interpreter:                 /usr/local/bin/python3 (ver 3.4.1)
--
--   Python (for build):            /usr/local/bin/python2.7
--
--   Java:
--     ant:                         NO
--     JNI:                         /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/include /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/include/darwin /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/include
--     Java tests:                  NO
--
--   Matlab:
--     mex:                         NO
--
--   Documentation:
--     Build Documentation:         YES (only HTML and without math expressions)
--     Sphinx:                      /usr/local/bin/sphinx-build (ver 1.2.3)
--     PdfLaTeX compiler:           NO
--     PlantUML:                    NO
--
--   Tests and samples:
--     Tests:                       YES
--     Performance tests:           YES
--     C/C++ Examples:              NO
--
--   Install path:                  /usr/local
--
--   cvconfig.h is in:              /Users/amotsjonov/work/opencv/build
-- -----------------------------------------------------------------
--
-- Configuring done
CMake Warning (dev):
  Policy CMP0042 is not set: MACOSX_RPATH is enabled by default.  Run "cmake
  --help-policy CMP0042" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  MACOSX_RPATH is not specified for the following targets:

   opencv_calib3d
   opencv_core
   opencv_features2d
   opencv_flann
   opencv_highgui
   opencv_imgcodecs
   opencv_imgproc
   opencv_ml
   opencv_objdetect
   opencv_photo
   opencv_shape
   opencv_stitching
   opencv_superres
   opencv_video
   opencv_videoio
   opencv_videostab

This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /Users/amotsjonov/work/opencv/build

I have numpy installed for Python 2.7, but not for Python 3. I need actually python 2.7 support only.

Do I understand correctly, that OpenCV modules: section is important. And If I see python modules in "Unavailable" this means I won't have Python integration in the end?