From 55cbe767acaf8dcc4ec078255d6c02f2182657be Mon Sep 17 00:00:00 2001 From: cudawarped <12133430+cudawarped@users.noreply.github.com> Date: Wed, 2 Feb 2022 14:26:56 +0000 Subject: [PATCH] Add locateROI test case to check GpuMat::dataend calculation. --- modules/cudaarithm/test/test_gpumat.cpp | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/modules/cudaarithm/test/test_gpumat.cpp b/modules/cudaarithm/test/test_gpumat.cpp index b4d59b1644..b9dba371dc 100644 --- a/modules/cudaarithm/test/test_gpumat.cpp +++ b/modules/cudaarithm/test/test_gpumat.cpp @@ -386,6 +386,49 @@ INSTANTIATE_TEST_CASE_P(CUDA, GpuMat_ConvertTo, testing::Combine( ALL_DEPTH, WHOLE_SUBMAT)); +//////////////////////////////////////////////////////////////////////////////// +// locateROI + +PARAM_TEST_CASE(GpuMat_LocateROI, cv::cuda::DeviceInfo, cv::Size, MatDepth, UseRoi) +{ + cv::cuda::DeviceInfo devInfo; + cv::Size size; + int depth; + bool useRoi; + + virtual void SetUp() + { + devInfo = GET_PARAM(0); + size = GET_PARAM(1); + depth = GET_PARAM(2); + useRoi = GET_PARAM(3); + + cv::cuda::setDevice(devInfo.deviceID()); + } +}; + +CUDA_TEST_P(GpuMat_LocateROI, locateROI) +{ + Point ofsGold; + Size wholeSizeGold; + GpuMat src = createMat(size, depth, wholeSizeGold, ofsGold, useRoi); + + Point ofs; + Size wholeSize; + src.locateROI(wholeSize, ofs); + ASSERT_TRUE(ofs == ofsGold && wholeSize == wholeSizeGold); + + GpuMat srcPtr(src.size(), src.type(), src.data, src.step); + src.locateROI(wholeSize, ofs); + ASSERT_TRUE(ofs == ofsGold && wholeSize == wholeSizeGold); +} + +INSTANTIATE_TEST_CASE_P(CUDA, GpuMat_LocateROI, testing::Combine( + ALL_DEVICES, + DIFFERENT_SIZES, + ALL_DEPTH, + WHOLE_SUBMAT)); + //////////////////////////////////////////////////////////////////////////////// // ensureSizeIsEnough