cv::Mat and cv::cuda::GpuMat containers
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?
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 viaGPUMat
.Therefore I would have to agree with you. Templates seems like the best option, as
cv::OutputArray
has different methods for getting the arrays from different types.