From 0a3aab288a37b58121055f7890e2c0954e114518 Mon Sep 17 00:00:00 2001 From: Adrien BAK Date: Fri, 26 Sep 2014 09:55:11 +0900 Subject: [PATCH] improved cloning test --- modules/photo/test/test_cloning.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/modules/photo/test/test_cloning.cpp b/modules/photo/test/test_cloning.cpp index 62fe243954..ab84b89cbf 100644 --- a/modules/photo/test/test_cloning.cpp +++ b/modules/photo/test/test_cloning.cpp @@ -47,6 +47,7 @@ using namespace cv; using namespace std; +static const double numerical_precision = 1.; TEST(Photo_SeamlessClone_normal, regression) { @@ -69,8 +70,9 @@ TEST(Photo_SeamlessClone_normal, regression) p.y = destination.size().height/2; seamlessClone(source, destination, mask, p, result, 1); - imwrite(folder + "cloned.png", result); - + Mat reference = imread(folder + "reference.png"); + double error = norm(reference, result, NORM_L1); + EXPECT_LE(error, numerical_precision); } TEST(Photo_SeamlessClone_mixed, regression) @@ -94,7 +96,9 @@ TEST(Photo_SeamlessClone_mixed, regression) p.y = destination.size().height/2; seamlessClone(source, destination, mask, p, result, 2); - imwrite(folder + "cloned.png", result); + Mat reference = imread(folder + "reference.png"); + double error = norm(reference, result, NORM_L1); + EXPECT_LE(error, numerical_precision); } @@ -119,7 +123,9 @@ TEST(Photo_SeamlessClone_featureExchange, regression) p.y = destination.size().height/2; seamlessClone(source, destination, mask, p, result, 3); - imwrite(folder + "cloned.png", result); + Mat reference = imread(folder + "reference.png"); + double error = norm(reference, result, NORM_L1); + EXPECT_LE(error, numerical_precision); } @@ -138,7 +144,9 @@ TEST(Photo_SeamlessClone_colorChange, regression) Mat result; colorChange(source, mask, result, 1.5, .5, .5); - imwrite(folder + "cloned.png", result); + Mat reference = imread(folder + "reference.png"); + double error = norm(reference, result, NORM_L1); + EXPECT_LE(error, numerical_precision); } @@ -157,7 +165,9 @@ TEST(Photo_SeamlessClone_illuminationChange, regression) Mat result; illuminationChange(source, mask, result, 0.2f, 0.4f); - imwrite(folder + "cloned.png", result); + Mat reference = imread(folder + "reference.png"); + double error = norm(reference, result, NORM_L1); + EXPECT_LE(error, numerical_precision); } @@ -176,6 +186,8 @@ TEST(Photo_SeamlessClone_textureFlattening, regression) Mat result; textureFlattening(source, mask, result, 30, 45, 3); - imwrite(folder + "cloned.png", result); + Mat reference = imread(folder + "reference.png"); + double error = norm(reference, result, NORM_L1); + EXPECT_LE(error, numerical_precision); }