Commit 1983991d authored by Alexander Alekhin's avatar Alexander Alekhin

photo(test): update test checks

- allow 5% of changed pixels with intensity difference <= 1
parent bb8ff2c4
...@@ -53,7 +53,7 @@ namespace opencv_test { namespace { ...@@ -53,7 +53,7 @@ namespace opencv_test { namespace {
#define SAVE(x) #define SAVE(x)
#endif #endif
static const double numerical_precision = 1000.; static const double numerical_precision = 0.05; // 95% of pixels should have exact values
TEST(Photo_SeamlessClone_normal, regression) TEST(Photo_SeamlessClone_normal, regression)
{ {
...@@ -82,8 +82,10 @@ TEST(Photo_SeamlessClone_normal, regression) ...@@ -82,8 +82,10 @@ TEST(Photo_SeamlessClone_normal, regression)
SAVE(result); SAVE(result);
double error = cvtest::norm(reference, result, NORM_L1); double errorINF = cvtest::norm(reference, result, NORM_INF);
EXPECT_LE(error, numerical_precision); EXPECT_LE(errorINF, 1);
double errorL1 = cvtest::norm(reference, result, NORM_L1);
EXPECT_LE(errorL1, reference.total() * numerical_precision) << "size=" << reference.size();
} }
TEST(Photo_SeamlessClone_mixed, regression) TEST(Photo_SeamlessClone_mixed, regression)
...@@ -113,9 +115,10 @@ TEST(Photo_SeamlessClone_mixed, regression) ...@@ -113,9 +115,10 @@ TEST(Photo_SeamlessClone_mixed, regression)
Mat reference = imread(reference_path); Mat reference = imread(reference_path);
ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path; ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path;
double error = cvtest::norm(reference, result, NORM_L1); double errorINF = cvtest::norm(reference, result, NORM_INF);
EXPECT_LE(error, numerical_precision); EXPECT_LE(errorINF, 1);
double errorL1 = cvtest::norm(reference, result, NORM_L1);
EXPECT_LE(errorL1, reference.total() * numerical_precision) << "size=" << reference.size();
} }
TEST(Photo_SeamlessClone_featureExchange, regression) TEST(Photo_SeamlessClone_featureExchange, regression)
...@@ -145,9 +148,10 @@ TEST(Photo_SeamlessClone_featureExchange, regression) ...@@ -145,9 +148,10 @@ TEST(Photo_SeamlessClone_featureExchange, regression)
Mat reference = imread(reference_path); Mat reference = imread(reference_path);
ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path; ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path;
double error = cvtest::norm(reference, result, NORM_L1); double errorINF = cvtest::norm(reference, result, NORM_INF);
EXPECT_LE(error, numerical_precision); EXPECT_LE(errorINF, 1);
double errorL1 = cvtest::norm(reference, result, NORM_L1);
EXPECT_LE(errorL1, reference.total() * numerical_precision) << "size=" << reference.size();
} }
TEST(Photo_SeamlessClone_colorChange, regression) TEST(Photo_SeamlessClone_colorChange, regression)
...@@ -171,9 +175,10 @@ TEST(Photo_SeamlessClone_colorChange, regression) ...@@ -171,9 +175,10 @@ TEST(Photo_SeamlessClone_colorChange, regression)
Mat reference = imread(reference_path); Mat reference = imread(reference_path);
ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path; ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path;
double error = cvtest::norm(reference, result, NORM_L1); double errorINF = cvtest::norm(reference, result, NORM_INF);
EXPECT_LE(error, numerical_precision); EXPECT_LE(errorINF, 1);
double errorL1 = cvtest::norm(reference, result, NORM_L1);
EXPECT_LE(errorL1, reference.total() * numerical_precision) << "size=" << reference.size();
} }
TEST(Photo_SeamlessClone_illuminationChange, regression) TEST(Photo_SeamlessClone_illuminationChange, regression)
...@@ -195,9 +200,12 @@ TEST(Photo_SeamlessClone_illuminationChange, regression) ...@@ -195,9 +200,12 @@ TEST(Photo_SeamlessClone_illuminationChange, regression)
SAVE(result); SAVE(result);
Mat reference = imread(reference_path); Mat reference = imread(reference_path);
double error = cvtest::norm(reference, result, NORM_L1); ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path;
EXPECT_LE(error, numerical_precision);
double errorINF = cvtest::norm(reference, result, NORM_INF);
EXPECT_LE(errorINF, 1);
double errorL1 = cvtest::norm(reference, result, NORM_L1);
EXPECT_LE(errorL1, reference.total() * numerical_precision) << "size=" << reference.size();
} }
TEST(Photo_SeamlessClone_textureFlattening, regression) TEST(Photo_SeamlessClone_textureFlattening, regression)
...@@ -221,9 +229,10 @@ TEST(Photo_SeamlessClone_textureFlattening, regression) ...@@ -221,9 +229,10 @@ TEST(Photo_SeamlessClone_textureFlattening, regression)
Mat reference = imread(reference_path); Mat reference = imread(reference_path);
ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path; ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path;
double error = cvtest::norm(reference, result, NORM_L1); double errorINF = cvtest::norm(reference, result, NORM_INF);
EXPECT_LE(error, numerical_precision); EXPECT_LE(errorINF, 1);
double errorL1 = cvtest::norm(reference, result, NORM_L1);
EXPECT_LE(errorL1, reference.total() * numerical_precision) << "size=" << reference.size();
} }
}} // namespace }} // namespace
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment