How to give priority to cv::myModule functions ?

asked 2018-03-27 00:05:12 -0600

mochi gravatar image

Hi,

I am working on a very specific hardware I would like to use to accelerate OpenCV. Some OpenCV functions have already been re-implemented, but I am a bit lost on the way I should integrate them into a custom module. For instance, I have written a function cv::myModule::resize() for the hardware I'm working on. How can I make sure that when a user calls cv::resize() it's my version of resize which will be called? I have looked at the gpu submodule (it's more or less the same thing I'm trying to do), but I couldn't find where the magic is done.

Thank you!

edit retag flag offensive close merge delete

Comments

By using namespaces you solve the issue in my opinion. cv::resize() will be the version of the library, but yourNameSpace::resize() will be yours. I just do not see why you would push it also under the cv namespace?

StevenPuttemans gravatar imageStevenPuttemans ( 2018-03-27 02:51:55 -0600 )edit

In all the OpenCV-based project I have seen so far, it seems to me that only the cv:: namespace is used (I have never seen cv::gpu or cv::ocl for instance). I assume then that if you have a gpu and CUDA, OpenCV will always try to use the cuda implementation of the function if it has been defined under cv::gpu (even if the user simply calls cv::resize()). Where is that mechanism managed? Or am I just wrong?

mochi gravatar imagemochi ( 2018-03-27 03:50:00 -0600 )edit

You are just wrong, if a user does not specify specifically that he wants to use the gpu implementation, through the proper namespace, then it will not be used. thats why OpenCV 3.x has these cuda related namespaces!

StevenPuttemans gravatar imageStevenPuttemans ( 2018-03-27 04:04:23 -0600 )edit