Isn't there a OpenCV Cuda function similar to findContours?

asked 2016-01-22 03:20:21 -0600

muglikar gravatar image

There are several OpenCV CPU functions which have a direct (GPU) Cuda counterpart like cv::cvtColor & cv::cuda::cvtColor.

But I found no direct or indirect (GPU) Cuda counterpart for cv::findContours CPU.

Isn't there a OpenCV Cuda function similar to findContours? Or does findContours work on both cv::Mat and cv::cuda::GpuMat?

edit retag flag offensive close merge delete

Comments

1

Nope, it is not there :)

StevenPuttemans gravatar imageStevenPuttemans ( 2016-01-22 04:12:10 -0600 )edit

Does findContours work on both cv::Mat and cv::cuda::GpuMat, @StevenPuttemans ?

muglikar gravatar imagemuglikar ( 2016-01-22 05:25:07 -0600 )edit
1

No it does not ... if there is no CUDA implementation then you cannot call it on GpuMat. You might be able to try an OpenCL optimized version by supplying a UMat container.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-01-22 05:53:59 -0600 )edit
2

Actually, there is but it doesn't work and is undocumented. It looks like somebody tried to write it and gave up during debugging - see here.

I futzed with it a bit and got it to work for my application. I will gladly share my code, with the caveat that it is not fully debugged and may not work properly for other scenarios.

Furthermore, In the tests I did, it was not actually faster than the non-GPU version. Connected component labeling is actually not very paralelizable for largish objects, since you need to trace a path from each pixel to an "origin" pixel in that blob. So the gains from going to GPU processing are not huge and do not justify the extra overhead and the slower "per CPU" speed.

guy

Guyygarty gravatar imageGuyygarty ( 2016-01-22 07:51:26 -0600 )edit

Ok, any nudging link for the said method documentation @StevenPuttemans. Actually, I've begun GPU porting for my entire project and this precisely is my bottle neck roadblocking pain point!

@Guyygarty, that seems exciting but why are you calling yourself 'somebody'? :) It'd be a pleasure if I could get to see how you did it. And btw, I'm not in this pursuit only for gains from this exact finding contours thing, but the overall gains from all the functions. :)

Surprisingly, findContours() doesn't give any compilation error even when the input is a GpuMat. I'm curious why.

muglikar gravatar imagemuglikar ( 2016-01-22 08:50:26 -0600 )edit

@StevenPuttemans Are you sure about the cv::UMat and cv::findCountours part? i traced the code and there is no call for any OpenCL code? did I miss something? thanks

Humam Helfawi gravatar imageHumam Helfawi ( 2016-11-07 14:49:53 -0600 )edit

Did you read my post? Back in the day I said, you can try and see. I did not check the code at that time :D So I guess the answer is no.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-11-08 02:26:29 -0600 )edit

Oh :( I thought there is a hope

Humam Helfawi gravatar imageHumam Helfawi ( 2016-11-08 02:58:02 -0600 )edit