OpenCV and GPU
Hello
I Built OpenCV 3.4.0 with CUDA. Now my OpenCV works right but I do not know how I can run OpenCV functions on GPU. For example I want run "connectedComponentsWithStats" on GPU.
Thank you for helping me
Hi, I think you are looking for labelcomponents, but this is legacy and the tests for it have been disabled so it probably doesn't work correctly, see here.
I don't think OpenCV has a working GPU version of exactly what you are looking for (WithStats). ArrayFire did have but it was pretty slow as the part which calculates the size of the connected component blobs was not well optimized.
Have you included the following header?
#include "opencv2/cudalegacy.hpp"
see https://github.com/opencv/opencv/blob... line 165 for its usage.
Thank you. I include it now . But I have some errors now. error : Severity Code Description Project File Line Suppression State Error C1083 Cannot open include file: 'cuda_runtime.h': No such file or directory ConsoleApplication3 c:\opencv 3.4.0\build\install\include\opencv2\core\cuda\common.hpp 46
As I said above the code is legacy and probably doesn't work correctly.
Are you sure you need connected components with stats on the GPU? I ask because from memory the CPU routine is not that slow. Additionally if you need to know the size of your connected regions before you can do any additional processing on the GPU (which is usually the case with CCL, at least in my experience) you will have to either a) stall the GPU to retrieve this information, possibly loosing any gain you have made, or b) come up with a strategy to hide this latency by performing some additional processing on the GPU, while you wait.
I understand that your data may already be on the GPU but if your workflow represents case b) then an async copy back to the host for processing there may be a better option.
I solved my problem with these two steps :
1) Project->Build Dependencies->Build Customisazions...-> Tick CUDA 9.1
2) Project->Properties->Linker->Input->Additional Dependencies-> "cudart.lib"
Asked: 2018-03-14 05:43:45 -0600
Seen: 2,857 times
Last updated: Mar 16 '18
Please refer to the doc.
did you see the samples here ?