GPU Affine Warp

Heya! I’m trying to write some code using cv::cuda::warpAffine and although it seems to be working fine, I’d like to have some guarantees that I understand correctly what is happening.

For one, in most tutorials online (e.g. OpenCV: Affine Transformations) I find people setting the size parameter just to the size of the dst image. I’m very happy to do that, but can I be in such a case certain that it’s not going to reallocate the underlying data? I already have the data allocated (the Mat object is just a shallow wrapper on top of it) and want to have the result in the memory where I expect it; is that going to always happen?

Second question is about in-place safety. If my src and dst are the same image, will OpenCV sort any possible issues for me, or do I need to deal with that explicitly in my wrapper function? The CPU-based warp (OpenCV: Geometric Image Transformations) can NOT operate in-place, can the GPU variant?

Many thanks!

seing your current code (snippet) would be helpful, esp. this part:

Oh, that one is nothing fancy just a little:

cv::cuda::GpuMat dMat(
      CV_MAKETYPE(cv::traits::Depth<float>::value, 3),

where dImg is of my GpuImage class.
(it’s in a templated function, so the float and 3 are not usually fixed, they’re just here for sake of simplicity!)

P.S. it should be a reinterpret_cast, shouldn’t it? :stuck_out_tongue:

1 Like