mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 06:03:15 +08:00
cuda::polarToCart: test double precision and tune tolerance
This commit is contained in:
parent
6203c95d31
commit
9932612373
@ -1346,6 +1346,7 @@ PERF_TEST_P(Sz, MagnitudeSqr,
|
||||
// Phase
|
||||
|
||||
DEF_PARAM_TEST(Sz_AngleInDegrees, cv::Size, bool);
|
||||
DEF_PARAM_TEST(Sz_Type_AngleInDegrees, cv::Size, MatType, bool);
|
||||
|
||||
PERF_TEST_P(Sz_AngleInDegrees, Phase,
|
||||
Combine(CUDA_TYPICAL_MAT_SIZES,
|
||||
@ -1423,17 +1424,19 @@ PERF_TEST_P(Sz_AngleInDegrees, CartToPolar,
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// PolarToCart
|
||||
|
||||
PERF_TEST_P(Sz_AngleInDegrees, PolarToCart,
|
||||
PERF_TEST_P(Sz_Type_AngleInDegrees, PolarToCart,
|
||||
Combine(CUDA_TYPICAL_MAT_SIZES,
|
||||
testing::Values(CV_32FC1, CV_64FC1),
|
||||
Bool()))
|
||||
{
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const bool angleInDegrees = GET_PARAM(1);
|
||||
const int type = GET_PARAM(1);
|
||||
const bool angleInDegrees = GET_PARAM(2);
|
||||
|
||||
cv::Mat magnitude(size, CV_32FC1);
|
||||
cv::Mat magnitude(size, type);
|
||||
declare.in(magnitude, WARMUP_RNG);
|
||||
|
||||
cv::Mat angle(size, CV_32FC1);
|
||||
cv::Mat angle(size, type);
|
||||
declare.in(angle, WARMUP_RNG);
|
||||
|
||||
if (PERF_RUN_CUDA())
|
||||
|
@ -2754,10 +2754,11 @@ INSTANTIATE_TEST_CASE_P(CUDA_Arithm, CartToPolar, testing::Combine(
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// polarToCart
|
||||
|
||||
PARAM_TEST_CASE(PolarToCart, cv::cuda::DeviceInfo, cv::Size, AngleInDegrees, UseRoi)
|
||||
PARAM_TEST_CASE(PolarToCart, cv::cuda::DeviceInfo, cv::Size, MatType, AngleInDegrees, UseRoi)
|
||||
{
|
||||
cv::cuda::DeviceInfo devInfo;
|
||||
cv::Size size;
|
||||
int type;
|
||||
bool angleInDegrees;
|
||||
bool useRoi;
|
||||
|
||||
@ -2765,8 +2766,9 @@ PARAM_TEST_CASE(PolarToCart, cv::cuda::DeviceInfo, cv::Size, AngleInDegrees, Use
|
||||
{
|
||||
devInfo = GET_PARAM(0);
|
||||
size = GET_PARAM(1);
|
||||
angleInDegrees = GET_PARAM(2);
|
||||
useRoi = GET_PARAM(3);
|
||||
type = GET_PARAM(2);
|
||||
angleInDegrees = GET_PARAM(3);
|
||||
useRoi = GET_PARAM(4);
|
||||
|
||||
cv::cuda::setDevice(devInfo.deviceID());
|
||||
}
|
||||
@ -2774,24 +2776,26 @@ PARAM_TEST_CASE(PolarToCart, cv::cuda::DeviceInfo, cv::Size, AngleInDegrees, Use
|
||||
|
||||
CUDA_TEST_P(PolarToCart, Accuracy)
|
||||
{
|
||||
cv::Mat magnitude = randomMat(size, CV_32FC1);
|
||||
cv::Mat angle = randomMat(size, CV_32FC1);
|
||||
cv::Mat magnitude = randomMat(size, type);
|
||||
cv::Mat angle = randomMat(size, type);
|
||||
const double tol = (type == CV_32FC1 ? 1.6e-4 : 1e-4) * (angleInDegrees ? 1.0 : 19.0);
|
||||
|
||||
cv::cuda::GpuMat x = createMat(size, CV_32FC1, useRoi);
|
||||
cv::cuda::GpuMat y = createMat(size, CV_32FC1, useRoi);
|
||||
cv::cuda::GpuMat x = createMat(size, type, useRoi);
|
||||
cv::cuda::GpuMat y = createMat(size, type, useRoi);
|
||||
cv::cuda::polarToCart(loadMat(magnitude, useRoi), loadMat(angle, useRoi), x, y, angleInDegrees);
|
||||
|
||||
cv::Mat x_gold;
|
||||
cv::Mat y_gold;
|
||||
cv::polarToCart(magnitude, angle, x_gold, y_gold, angleInDegrees);
|
||||
|
||||
EXPECT_MAT_NEAR(x_gold, x, 1e-4);
|
||||
EXPECT_MAT_NEAR(y_gold, y, 1e-4);
|
||||
EXPECT_MAT_NEAR(x_gold, x, tol);
|
||||
EXPECT_MAT_NEAR(y_gold, y, tol);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(CUDA_Arithm, PolarToCart, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
DIFFERENT_SIZES,
|
||||
testing::Values(CV_32FC1, CV_64FC1),
|
||||
testing::Values(AngleInDegrees(false), AngleInDegrees(true)),
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user