Ask Your Question

Revision history [back]

Python accessibility for the xfeatures2d functions (from `opencv_extra`)

I'm trying to use the some of the functions from the opencv_extra repo, from python 3.

I'm building OpenCV from source:

   durr@mainnas:~/b_opencv/opencv/build$ cmake -D CMAKE_BUILD_TYPE=RELEASE                                                              \
          -D BUILD_PYTHON_SUPPORT=ON                                                               \
          -D WITH_XINE=ON                                                                          \
          -D WITH_OPENGL=ON                                                                        \
          -D WITH_TBB=ON                                                                           \
          -D BUILD_EXAMPLES=ON                                                                     \
          -D BUILD_NEW_PYTHON_SUPPORT=ON                                                           \
          -D PYTHON_EXECUTABLE=/usr/bin/python3                                                    \
          -D INSTALL_C_EXAMPLES=ON                                                                 \
          -D INSTALL_PYTHON_EXAMPLES=ON                                                            \
          -D PYTHON_INCLUDE_DIR=/usr/include/python3.4                                             \
          -D PYTHON_INCLUDE_DIR2=/usr/include/x86_64-linux-gnu/python3.4m                          \
          -D PYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.4m.so                             \
          -D PYTHON_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.4/dist-packages/numpy/core/include/  \
          -D PYTHON_PACKAGES_PATH=/usr/local/lib/python3.4/dist-packages/numpy/core/include/       \
          -D BUILD_OPENCV_JAVA=NO                                                                  \
          -D OPENCV_EXTRA_MODULES_PATH=~/b_opencv/opencv_contrib/modules                           \
          -D OPENCV_TEST_DATA_PATH=~/b_opencv/opencv_extra/testdata                                \
          -D PYTHON3_EXECUTABLE=/usr/bin/python3                                                   \
          -D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.4/dist-packages/numpy/core/include/ \
          ..

cmake is correctly finding my python dir, and is claiming it's building xfeatures2d:

-- General configuration for OpenCV 3.0.0-dev =====================================
--   Version control:               3.0.0-beta-41-g50c9367
--
--   Platform:
--     Host:                        Linux 3.13.0-40-generic x86_64
--     CMake:                       2.8.12.2
--     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 4.8.2)
--     C++ flags (Release):         -fsigned-char -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 -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -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 -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /usr/bin/cc
--     C flags (Release):           -fsigned-char -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 -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -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 -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):
--     Linker flags (Debug):
--     Precompiled headers:         YES
--
--   OpenCV modules:
--     To be built:                 core imgproc imgcodecs videoio highgui xobjdetect adas video bgsegm bioinspired flann ml features2d calib3d ccalib face text datasets objdetect latentsvm line_descriptor optflow photo reg rgbd saliency shape xfeatures2d stitching superres surface_matching videostab ximgproc xphoto python2 python3 tracking ts
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 androidcamera cuda cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaoptflow cudastereo cudawarping cudev java viz cvv matlab
--
--   GUI:
--     QT:                          NO
--     GTK+ 2.x:                    YES (ver 2.24.23)
--     GThread :                    YES (ver 2.40.2)
--     GtkGlExt:                    NO
--     OpenGL support:              NO
--     VTK support:                 NO
--
--   Media I/O:
--     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
--     JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
--     WEBP:                        /usr/lib/x86_64-linux-gnu/libwebp.so (ver encoder: 0x0202)
--     PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.50)
--     TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.0.3)
--     JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
--     OpenEXR:                     /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 1.6.1)
--     GDAL:                        NO
--
--   Video I/O:
--     DC1394 1.x:                  NO
--     DC1394 2.x:                  YES (ver 2.2.1)
--     FFMPEG:                      YES
--       codec:                     YES (ver 54.35.0)
--       format:                    YES (ver 54.20.4)
--       util:                      YES (ver 52.3.0)
--       swscale:                   YES (ver 2.1.1)
--       gentoo-style:              YES
--     GStreamer:
--       base:                      YES (ver 1.2.4)
--       video:                     YES (ver 1.2.4)
--       app:                       YES (ver 1.2.4)
--       riff:                      YES (ver 1.2.4)
--       pbutils:                   YES (ver 1.2.4)
--     OpenNI:                      NO
--     OpenNI PrimeSensor Modules:  NO
--     OpenNI2:                     NO
--     PvAPI:                       NO
--     GigEVisionSDK:               NO
--     UniCap:                      NO
--     UniCap ucil:                 NO
--     V4L/V4L2:                    Using libv4l (ver 1.0.1)
--     XIMEA:                       NO
--     Xine:                        YES (ver 1.2.4)
--
--   Other third-party libraries:
--     Use IPP:                     8.2.1 [8.2.1]
--          at:                     /home/durr/b_opencv/opencv/3rdparty/ippicv/unpack/ippicv_lnx
--     Use IPP Async:               NO
--     Use Eigen:                   YES (ver 3.2.0)
--     Use TBB:                     YES (ver 4.2 interface 7000)
--     Use OpenMP:                  NO
--     Use GCD                      NO
--     Use Concurrency              NO
--     Use C=:                      NO
--     Use Cuda:                    NO
--     Use OpenCL:                  YES
--
--   OpenCL:
--     Version:                     dynamic
--     Include path:                /home/durr/b_opencv/opencv/3rdparty/include/opencl/1.2
--     Use AMDFFT:                  NO
--     Use AMDBLAS:                 NO
--
--   Python 2:
--     Interpreter:                 /usr/bin/python3 (ver 3.4)
--     Libraries:                   /usr/lib/x86_64-linux-gnu/libpython3.4m.so (ver 3.4.0)
--     numpy:                       /usr/local/lib/python3.4/dist-packages/numpy/core/include (ver 1.9.1)
--     packages path:               lib/python3.4/dist-packages
--
--   Python 3:
--     Interpreter:                 /usr/bin/python3 (ver 3.4)
--     Libraries:                   /usr/lib/x86_64-linux-gnu/libpython3.4m.so (ver 3.4.0)
--     numpy:                       /usr/local/lib/python3.4/dist-packages/numpy/core/include (ver 1.9.1)
--     packages path:               lib/python3.4/dist-packages
--
--   Python (for build):            /usr/bin/python3
--
--   Java:
--     ant:                         NO
--     JNI:                         NO
--     Java wrappers:               NO
--     Java tests:                  NO
--
--   Matlab:
--     mex:                         NO
--
--   Documentation:
--     Build Documentation:         NO
--     Sphinx:                      NO
--     PdfLaTeX compiler:           NO
--     PlantUML:                    NO
--     Doxygen:                     NO
--
--   Tests and samples:
--     Tests:                       YES
--     Performance tests:           YES
--     C/C++ Examples:              YES
--
--   Install path:                  /usr/local
--
--   cvconfig.h is in:              /home/durr/b_opencv/opencv/build
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    BUILD_NEW_PYTHON_SUPPORT
    BUILD_OPENCV_JAVA
    BUILD_PYTHON_SUPPORT


-- Build files have been written to: /home/durr/b_opencv/opencv/build

Building even succeeds, and I can install the built OpenCV fine. However, while the cv2 module is available and functional, there is no cv2.xfeatures2d module available.

What's going on? Is it possible cv2.xfeatures2d is broken on python 3? There is a guy on stack-exchange who appears to have a functional build that includes cv2.xfeatures2d, though I don't know if it's on python 3 or python 2.