Ask Your Question

GPU matcher on Python

asked 2018-12-06 06:13:19 -0500

marqueewinq gravatar image

Hello, i have compiled OpenCV for Python with cudafeatures2d installed. Unfortunately, i could find any succinct documentation on cuda module in general and on cudafeatures2d with Python.

My final task is to use gpu-based matcher for AKAZE descriptors (in Python). I haven't been able to google any reasonable answer to how to do it with OpenCV without manual software carpentry. Please advice how to do it.

Here's output of getBuildInformation():

General configuration for OpenCV 3.3.1 =====================================
Version control:               3.3.1

Extra modules:
  Location (extra):            /opt/opencv/opencv_contrib/modules
  Version control (extra):     3.3.1

  Timestamp:                   2018-11-23T15:10:05Z
  Host:                        Linux 4.4.0-98-generic x86_64
  CMake:                       3.5.1
  CMake generator:             Unix Makefiles
  CMake build tool:            /usr/bin/make
  Configuration:               RELEASE

CPU/HW features:
  Baseline:                    SSE SSE2 SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 AVX
    requested:                 SSE3
    required:                  AVX
  Dispatched code generation:  FP16 AVX2
    requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2
    FP16 (1 files):            + FP16
    AVX2 (8 files):            + FP16 FMA3 AVX2

  Built as dynamic libs?:      YES
  C++ Compiler:                /usr/bin/c++  (ver 5.4.0)
  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 -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections  -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -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 -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections  -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -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 -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections  -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -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 -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections  -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
  Linker flags (Release):
  Linker flags (Debug):
  ccache:                      NO
  Precompiled headers:         YES
  Extra dependencies:          dl m pthread rt cudart nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/local/cuda/lib64
  3rdparty dependencies:

OpenCV modules:
  To be built:                 cudev core cudaarithm flann hdf imgproc ml objdetect phase_unwrapping plot reg surface_matching video xphoto bgsegm cudabgsegm cudafilters cudaimgproc cudawarping dnn face fuzzy img_hash imgcodecs photo shape videoio xobjdetect cudacodec highgui bioinspired dpm features2d line_descriptor saliency text calib3d ccalib cudafeatures2d cudalegacy cudaobjdetect cudaoptflow cudastereo datasets rgbd stereo structured_light superres tracking videostab xfeatures2d ximgproc aruco optflow stitching python2
  Disabled:                    js world contrib_world
  Disabled by dependency:      -
  Unavailable:                 java python3 ts viz cnn_3dobj cvv dnn_modern freetype matlab ...
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2018-12-06 06:18:10 -0500

berak gravatar image

updated 2018-12-06 06:52:56 -0500

while there is rudimentary (experimental) support for CUDA from python on opencv's master branch, there is no such thing at all in opencv 3.3.1 (you can't use ANY cuda functions from python there)

you can try to use openCL / cv2.UMat, though (there is opencl code for the BF Matcher)

edit flag offensive delete link more


Is it available in 4.0? Couldn't find any documentation either

marqueewinq gravatar imagemarqueewinq ( 2018-12-06 07:12:21 -0500 )edit

ok, correction: there's support for GPUMat , but (probably, idk) no such thing for the cuda::DescriptorMatcher.

so, again, try with cv2.UMat.

berak gravatar imageberak ( 2018-12-06 07:23:38 -0500 )edit

Where is any documentation for UMat? Should i call usual matcher with UMat instead of Mats?

marqueewinq gravatar imagemarqueewinq ( 2018-12-06 07:51:37 -0500 )edit

yes, that's all you need there

berak gravatar imageberak ( 2018-12-06 08:42:55 -0500 )edit

answered 2019-08-11 09:40:40 -0500

Some examples have been given in opencv repository for cuda support in python . But unfortunately , there is still no cuda version of Akaze . A separate implementation of akaze cuda is available at

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-12-06 06:13:19 -0500

Seen: 233 times

Last updated: Dec 06 '18