Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use GPU under Python #28

Open
ruanhailiang opened this issue Jul 7, 2019 · 5 comments
Open

How to use GPU under Python #28

ruanhailiang opened this issue Jul 7, 2019 · 5 comments

Comments

@ruanhailiang
Copy link

How to use GPU under Python ? Thanks.

@filipemansano
Copy link

filipemansano commented Aug 28, 2019

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)

@ruanhailiang
Copy link
Author

thanks.

@Algabri
Copy link

Algabri commented May 28, 2020

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

OpenCV 3.3.1

@filipemansano
Copy link

@Algabri
Copy link

Algabri commented Jul 6, 2020

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants