From 85f7cd5ad2928b36041ba811dc73c2fdb9c90285 Mon Sep 17 00:00:00 2001 From: chacha21 Date: Thu, 30 Nov 2023 10:25:18 +0100 Subject: [PATCH] first proposal of cv::remap with relative displacement field (#24621, #24603) CUDA implementation of the feature --- modules/cudawarping/src/cuda/remap.cu | 88 +++++++++++++++++-------- modules/cudawarping/src/remap.cpp | 9 ++- modules/cudawarping/test/test_remap.cpp | 74 +++++++++++++++++++++ 3 files changed, 140 insertions(+), 31 deletions(-) diff --git a/modules/cudawarping/src/cuda/remap.cu b/modules/cudawarping/src/cuda/remap.cu index 38edf19ae24..8f698a2ffb4 100644 --- a/modules/cudawarping/src/cuda/remap.cu +++ b/modules/cudawarping/src/cuda/remap.cu @@ -68,9 +68,23 @@ namespace cv { namespace cuda { namespace device } } + template __global__ void remap_relative(const Ptr2D src, const PtrStepf mapx, const PtrStepf mapy, PtrStepSz dst) + { + const int x = blockDim.x * blockIdx.x + threadIdx.x; + const int y = blockDim.y * blockIdx.y + threadIdx.y; + + if (x < dst.cols && y < dst.rows) + { + const float xcoo = x+mapx.ptr(y)[x]; + const float ycoo = y+mapy.ptr(y)[x]; + + dst.ptr(y)[x] = saturate_cast(src(ycoo, xcoo)); + } + } + template