From 839245e420f940a8bc3aa7f77d99603a15dd317a Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sun, 27 Oct 2013 12:58:22 +0400 Subject: [PATCH] fixed tests for ocl::warpAffine and ocl::warpPerspective --- modules/ocl/test/test_warp.cpp | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/modules/ocl/test/test_warp.cpp b/modules/ocl/test/test_warp.cpp index bfe5b63..05554ce 100644 --- a/modules/ocl/test/test_warp.cpp +++ b/modules/ocl/test/test_warp.cpp @@ -86,17 +86,17 @@ PARAM_TEST_CASE(WarpTestBase, MatType, Interpolation, bool, bool) void random_roi() { + dsize = randomSize(1, MAX_VALUE); + Size roiSize = randomSize(1, MAX_VALUE); Border srcBorder = randomBorder(0, useRoi ? MAX_VALUE : 0); randomSubMat(src, src_roi, roiSize, srcBorder, type, -MAX_VALUE, MAX_VALUE); Border dstBorder = randomBorder(0, useRoi ? MAX_VALUE : 0); - randomSubMat(dst_whole, dst_roi, roiSize, dstBorder, type, -MAX_VALUE, MAX_VALUE); + randomSubMat(dst_whole, dst_roi, dsize, dstBorder, type, -MAX_VALUE, MAX_VALUE); generateOclMat(gsrc_whole, gsrc_roi, src, roiSize, srcBorder); - generateOclMat(gdst_whole, gdst_roi, dst_whole, roiSize, dstBorder); - - dsize = randomSize(1, MAX_VALUE); + generateOclMat(gdst_whole, gdst_roi, dst_whole, dsize, dstBorder); } void Near(double threshold = 0.0) @@ -116,18 +116,13 @@ typedef WarpTestBase WarpAffine; OCL_TEST_P(WarpAffine, Mat) { - static const double coeffs[2][3] = - { - { cos(CV_PI / 6), -sin(CV_PI / 6), 100.0 }, - { sin(CV_PI / 6), cos(CV_PI / 6), -100.0 } - }; - - static Mat M(2, 3, CV_64FC1, (void *)coeffs); - for (int j = 0; j < LOOP_TIMES; j++) { random_roi(); + Mat M = getRotationMatrix2D(Point2f(src_roi.cols / 2.0f, src_roi.rows / 2.0f), + rng.uniform(-180.f, 180.f), rng.uniform(0.4f, 2.0f)); + warpAffine(src_roi, dst_roi, M, dsize, interpolation); ocl::warpAffine(gsrc_roi, gdst_roi, M, dsize, interpolation); @@ -141,19 +136,19 @@ typedef WarpTestBase WarpPerspective; OCL_TEST_P(WarpPerspective, Mat) { - static const double coeffs[3][3] = - { - { cos(CV_PI / 6), -sin(CV_PI / 6), 100.0 }, - { sin(CV_PI / 6), cos(CV_PI / 6), -100.0 }, - { 0.0, 0.0, 1.0 } - }; - - static Mat M(3, 3, CV_64FC1, (void *)coeffs); - for (int j = 0; j < LOOP_TIMES; j++) { random_roi(); + float cols = static_cast(src_roi.cols), rows = static_cast(src_roi.rows); + float cols2 = cols / 2.0f, rows2 = rows / 2.0f; + Point2f sp[] = { Point2f(0.0f, 0.0f), Point2f(cols, 0.0f), Point2f(0.0f, rows), Point2f(cols, rows) }; + Point2f dp[] = { Point2f(rng.uniform(0.0f, cols2), rng.uniform(0.0f, rows2)), + Point2f(rng.uniform(cols2, cols), rng.uniform(0.0f, rows2)), + Point2f(rng.uniform(0.0f, cols2), rng.uniform(rows2, rows)), + Point2f(rng.uniform(cols2, cols), rng.uniform(rows2, rows)) }; + Mat M = getPerspectiveTransform(sp, dp); + warpPerspective(src_roi, dst_roi, M, dsize, interpolation); ocl::warpPerspective(gsrc_roi, gdst_roi, M, dsize, interpolation); -- 2.7.4