Pytorch tensor to opencv GPUMat

Hi,

I compiled OpenCV 4 with cuda and python bindings which makes it possible to use certain opencv algorithms on GPU. I am doing some post processing on output of a neural network. I was wondering if there is a way to directly convert a pytorch tensor on the GPU to opencv GPUMat ?

I could first bring tensor to cpu and then convert it into numpy and then to GPUMat but that will bring put extra penalty due to GPU->CPU->GPU transfer.

So is there any direct way to utilize pytorch tensor’s pointer or something ?

Best Regards,

I am looking for something similar. This would definitely be useful for directly importing CV algorithms as CPP extensions.

Hi,

Did you find a reasonable solution ? I did convert the GPUMat but the algorithm still did’nt work. As it was not a crucial thing so I just left it out.