cv::Mat and cv::cuda::GpuMat containers

asked 2019-11-16 09:28:36 -0600

I am writing a class that uses PLK optical flow and I want it to be able to use either the CPU cv::Mat version or the GPU cv::cuda::GpuMat version of the PLK optical flow algorithm. I want to "pipeline" my computation and so I need to store an image pyramid to prevent redundant computation.

My question is: How can I store an image pyramid in a polymorphic way? I want a single variable to not care if it is std::vector<cv::Mat> or std::vector<cv::cuda::GpuMat>. I have tried abusing cv::OutputArray, but I am stumped. Is this an impossible task? Do I really need conditional compilation or templates?

edit retag flag offensive close merge delete

Comments

I guess you want UMat but for CUDA, however this doesn't exist. On the plus side you get finer grained control of where the data sits by explicitly allocating, uploading and downloading via GPUMat.

Therefore I would have to agree with you. Templates seems like the best option, ascv::OutputArray has different methods for getting the arrays from different types.

cudawarped gravatar imagecudawarped ( 2019-11-20 04:19:26 -0600 )edit