Skip to content

Commit fbdb8b2

Browse files
authored
Merge pull request #4051 from timeuser4:feature/lanczos4
Add CUDA implementation for resize with Lanczos interpolation #4051 OpenCV Extra: opencv/opencv_extra#1294 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
1 parent 6fdda2d commit fbdb8b2

File tree

5 files changed

+594
-3
lines changed

5 files changed

+594
-3
lines changed

modules/cudawarping/perf/perf_warping.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,57 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Scale, Resize,
180180
}
181181
}
182182

183+
//////////////////////////////////////////////////////////////////////
184+
// ResizeLanczos
185+
186+
PERF_TEST_P(Sz_Depth_Cn_Inter_Scale, ResizeLanczos,
187+
Combine(CUDA_TYPICAL_MAT_SIZES,
188+
Values(CV_8U, CV_32F),
189+
CUDA_CHANNELS_1_3_4,
190+
Values(Interpolation(cv::INTER_LANCZOS4)),
191+
Values(0.5, 1.5, 2.0)))
192+
{
193+
declare.time(20.0);
194+
195+
const cv::Size size = GET_PARAM(0);
196+
const int depth = GET_PARAM(1);
197+
const int channels = GET_PARAM(2);
198+
const int interpolation = GET_PARAM(3);
199+
const double f = GET_PARAM(4);
200+
201+
const int type = CV_MAKE_TYPE(depth, channels);
202+
203+
cv::Mat src(size, type);
204+
declare.in(src, WARMUP_RNG);
205+
206+
if (PERF_RUN_CUDA())
207+
{
208+
const cv::cuda::GpuMat d_src(src);
209+
cv::cuda::GpuMat dst;
210+
cv::Size dsize(cv::saturate_cast<int>(src.cols * f), cv::saturate_cast<int>(src.rows * f));
211+
cv::Mat host_dst(dsize, type);
212+
213+
declare.out(host_dst);
214+
215+
TEST_CYCLE() cv::cuda::resize(d_src, dst, cv::Size(), f, f, interpolation);
216+
217+
dst.download(host_dst);
218+
219+
CUDA_SANITY_CHECK(dst, 1e-3, ERROR_RELATIVE);
220+
}
221+
else
222+
{
223+
cv::Size dsize(cv::saturate_cast<int>(src.cols * f), cv::saturate_cast<int>(src.rows * f));
224+
cv::Mat dst(dsize, type);
225+
226+
declare.out(dst);
227+
228+
TEST_CYCLE() cv::resize(src, dst, cv::Size(), f, f, interpolation);
229+
230+
CPU_SANITY_CHECK(dst);
231+
}
232+
}
233+
183234
//////////////////////////////////////////////////////////////////////
184235
// ResizeArea
185236

0 commit comments

Comments
 (0)