This source file includes following definitions.
- generateTestData
- Near
- OCL_TEST_F
- OCL_TEST_F
- OCL_TEST_F
#include "../test_precomp.hpp"
#include "opencv2/ts/ocl_test.hpp"
#include "opencv2/stitching/warpers.hpp"
#ifdef HAVE_OPENCL
namespace cvtest {
namespace ocl {
struct WarperTestBase :
public Test, public TestUtils
{
Mat src, dst, xmap, ymap;
UMat usrc, udst, uxmap, uymap;
Mat K, R;
virtual void generateTestData()
{
Size size = randomSize(1, MAX_VALUE);
src = randomMat(size, CV_32FC1, -500, 500);
src.copyTo(usrc);
K = Mat::eye(3, 3, CV_32FC1);
float angle = (float)(30.0 * CV_PI / 180.0);
float rotationMatrix[9] = {
(float)cos(angle), (float)sin(angle), 0,
(float)-sin(angle), (float)cos(angle), 0,
0, 0, 1
};
Mat(3, 3, CV_32FC1, rotationMatrix).copyTo(R);
}
void Near(double threshold = 0.)
{
EXPECT_MAT_NEAR(xmap, uxmap, threshold);
EXPECT_MAT_NEAR(ymap, uymap, threshold);
EXPECT_MAT_NEAR(dst, udst, threshold);
}
};
typedef WarperTestBase SphericalWarperTest;
OCL_TEST_F(SphericalWarperTest, Mat)
{
for (int j = 0; j < test_loop_times; j++)
{
generateTestData();
Ptr<WarperCreator> creator = makePtr<SphericalWarper>();
Ptr<detail::RotationWarper> warper = creator->create(2.0);
OCL_OFF(warper->buildMaps(src.size(), K, R, xmap, ymap));
OCL_ON(warper->buildMaps(usrc.size(), K, R, uxmap, uymap));
OCL_OFF(warper->warp(src, K, R, INTER_LINEAR, BORDER_REPLICATE, dst));
OCL_ON(warper->warp(usrc, K, R, INTER_LINEAR, BORDER_REPLICATE, udst));
Near(1e-4);
}
}
typedef WarperTestBase CylindricalWarperTest;
OCL_TEST_F(CylindricalWarperTest, Mat)
{
for (int j = 0; j < test_loop_times; j++)
{
generateTestData();
Ptr<WarperCreator> creator = makePtr<CylindricalWarper>();
Ptr<detail::RotationWarper> warper = creator->create(2.0);
OCL_OFF(warper->buildMaps(src.size(), K, R, xmap, ymap));
OCL_ON(warper->buildMaps(usrc.size(), K, R, uxmap, uymap));
OCL_OFF(warper->warp(src, K, R, INTER_LINEAR, BORDER_REPLICATE, dst));
OCL_ON(warper->warp(usrc, K, R, INTER_LINEAR, BORDER_REPLICATE, udst));
Near(1e-4);
}
}
typedef WarperTestBase PlaneWarperTest;
OCL_TEST_F(PlaneWarperTest, Mat)
{
for (int j = 0; j < test_loop_times; j++)
{
generateTestData();
Ptr<WarperCreator> creator = makePtr<PlaneWarper>();
Ptr<detail::RotationWarper> warper = creator->create(2.0);
OCL_OFF(warper->buildMaps(src.size(), K, R, xmap, ymap));
OCL_ON(warper->buildMaps(usrc.size(), K, R, uxmap, uymap));
OCL_OFF(warper->warp(src, K, R, INTER_LINEAR, BORDER_REPLICATE, dst));
OCL_ON(warper->warp(usrc, K, R, INTER_LINEAR, BORDER_REPLICATE, udst));
Near(1.5e-4);
}
}
} }
#endif