Is there a cuda version of cv::FillConvexPoly()?

Hi, I am currently trying to turn into my CPU code into GPU one. I had to use cv::fillConvexPoly in my CPU code. But i dont seem to find one in GPU. What am i supposed to do?

P.S I actually want to create a simple mask like this.cropped_triangle1_mask
I know the coordinates of points A,B,C already. I used cv::fillConvexPoly in CPU version OpenCV. I was wondering how to create a such one on cv::cuda::GpuMat.

It depends, why are you filling the polygon is it for eventual display? If so depending on the runtimes of your other CUDA functions and your processing pipeline you could do the easy thing and dload the image asynchronously as early in you pipeline as possilbe and run the CPU (or maybe opencl with UMat) version of cv::fillConvexPoly() asynchronously with your remaining CUDA routines. This is my apporach because all my image display routines are passed host images. Obviously this is not the most efficient approach, it would be much more efficient to display directly through the GPU using opengl etc. But if you are doing the also displaying your output by passing host images to opencv or other display functions there “may” be little benefit to drawing on your images using the GPU.

So I would guess if that approach isn’t efficient enough you would need to implement or find an implementation in CUDA or use opengl for display and draw the polygon there.

Thx for the answer. I edited my question again. I actually used cv::fillConvexPoly for creating a mask on cv::Mat. I want to now create one on cv::cuda::GpuMat directly.

Are the points a result of a GPU operation or is the mask fixed? If fixed I would precompute the mask using the CPU version and copy to the GPU for the entirety of the program.

Points are given conditions . Say i have 3 points Point(0,0),(0,199),(199,0) on a GpuMat of 200x200. I want to make a mask directly on GpuMat . Making mask on cv::Mat and then upload on Gpu is not what i want, as it takes time.

If the points are given at the start the most efficient approach is to pre-load the mask onto the GPU regardless of whether you create the mask on the CPU or GPU. There is always a substantial start up cost of using CUDA which can’t be avoided so adding the small cost of uploading an image should not cost you anything. I am only mentioning this because implementing your own CUDA routine to draw the mask seems unecessary (as it won’t lower the execution time, unless I am missing something) and unless you are familiar with CUDA will most likely take you more than a day to complete/test up to the level of OpenCV etc.

related:

preloading the mask seems a good approach. I would like to take a try for that. Great Thx again.