GMS-Feature-Matcher icon indicating copy to clipboard operation
GMS-Feature-Matcher copied to clipboard

How to use GPU under Python

Open ruanhailiang opened this issue 5 years ago • 5 comments

How to use GPU under Python ? Thanks.

ruanhailiang avatar Jul 07 '19 05:07 ruanhailiang

its necessary compile your opencv with cuda cmake -D CMAKE_BUILD_TYPE=RELEASE
-D CMAKE_INSTALL_PREFIX=/usr/local
-D WITH_CUDA=ON
-D ENABLE_FAST_MATH=1
-D CUDA_FAST_MATH=1
-D WITH_CUBLAS=1
-D OPENCV_ENABLE_NONFREE=ON
-D INSTALL_PYTHON_EXAMPLES=ON
-D OPENCV_GENERATE_PKGCONFIG=ON
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_build/opencv_contrib/modules
-D BUILD_EXAMPLES=ON .

change default matcher matcher = cv2.BFMatcher(cv2.NORM_HAMMING)

for cuda matcher matcher = cv2.cuda.DescriptorMatcher_createBFMatcher(cv2.NORM_HAMMING)

and it all_matches = self.matcher.match(descriptors_image1, descriptors_image2)

for it

cuMatDesc2 = cv2.cuda_GpuMat()

cuMatDesc1.upload(descriptors_image1)
cuMatDesc2.upload(descriptors_image2)

all_matches = self.matcher.match(cuMatDesc1, cuMatDesc2)

filipemansano avatar Aug 28 '19 19:08 filipemansano

thanks.

ruanhailiang avatar Sep 03 '19 08:09 ruanhailiang

 matcher = cv2.cuda.DescriptorMatcher_createBFMatcher(cv2.NORM_HAMMING)
AttributeError: 'module' object has no attribute 'DescriptorMatcher_createBFMatcher'

OpenCV 3.3.1

Algabri avatar May 28 '20 04:05 Algabri

@Algabri try using OpenCV 4

https://docs.opencv.org/master/dd/dc5/classcv_1_1cuda_1_1DescriptorMatcher.html

filipemansano avatar May 28 '20 13:05 filipemansano

I installed OpenCV 4.2, it is already run on GPU but I did not observe any differences between CPU and GPU. The same speed (Frame per second), it is running at 30 fps for whole image with 50000 points, but when I use it with deep learning, it made dropping the fps to 6 instead of 23 fps because of matching with every object instead of one (if deep learning only run is 23 fps and if GMS-Feature-Matcher only run is 30 fps)

Algabri avatar Jul 06 '20 12:07 Algabri