[opencv] 60/89: test: tvl1 test check update
Nobuhiro Iwamatsu
iwamatsu at moszumanska.debian.org
Sat May 13 09:57:25 UTC 2017
This is an automated email from the git hooks/post-receive script.
iwamatsu pushed a commit to annotated tag 2.4.13.2
in repository opencv.
commit a05444618c6888e9e5c0f6ffd24c79f9ee12fb8f
Author: Alexander Alekhin <alexander.alekhin at intel.com>
Date: Thu Nov 10 15:39:18 2016 +0300
test: tvl1 test check update
---
modules/video/test/test_tvl1optflow.cpp | 37 ++++++++++++++++++---------------
1 file changed, 20 insertions(+), 17 deletions(-)
diff --git a/modules/video/test/test_tvl1optflow.cpp b/modules/video/test/test_tvl1optflow.cpp
index 67dc7fe..bf7e835 100644
--- a/modules/video/test/test_tvl1optflow.cpp
+++ b/modules/video/test/test_tvl1optflow.cpp
@@ -115,35 +115,39 @@ namespace
return !cvIsNaN(u.x) && !cvIsNaN(u.y) && (fabs(u.x) < 1e9) && (fabs(u.y) < 1e9);
}
- double calcRMSE(const Mat_<Point2f>& flow1, const Mat_<Point2f>& flow2)
+ void check(const Mat_<Point2f>& gold, const Mat_<Point2f>& flow, double threshold = 0.1, double expectedAccuracy = 0.95)
{
- double sum = 0.0;
- int counter = 0;
+ threshold = threshold*threshold;
- for (int i = 0; i < flow1.rows; ++i)
+ size_t gold_counter = 0;
+ size_t valid_counter = 0;
+
+ for (int i = 0; i < gold.rows; ++i)
{
- for (int j = 0; j < flow1.cols; ++j)
+ for (int j = 0; j < gold.cols; ++j)
{
- const Point2f u1 = flow1(i, j);
- const Point2f u2 = flow2(i, j);
+ const Point2f u1 = gold(i, j);
+ const Point2f u2 = flow(i, j);
- if (isFlowCorrect(u1) && isFlowCorrect(u2))
+ if (isFlowCorrect(u1))
{
- const Point2f diff = u1 - u2;
- sum += diff.ddot(diff);
- ++counter;
+ gold_counter++;
+ if (isFlowCorrect(u2))
+ {
+ const Point2f diff = u1 - u2;
+ double err = diff.ddot(diff);
+ if (err <= threshold)
+ valid_counter++;
+ }
}
}
}
-
- return sqrt(sum / (1e-9 + counter));
+ EXPECT_GE(valid_counter, expectedAccuracy * gold_counter);
}
}
TEST(Video_calcOpticalFlowDual_TVL1, Regression)
{
- const double MAX_RMSE = 0.02;
-
const string frame1_path = TS::ptr()->get_data_path() + "optflow/RubberWhale1.png";
const string frame2_path = TS::ptr()->get_data_path() + "optflow/RubberWhale2.png";
const string gold_flow_path = TS::ptr()->get_data_path() + "optflow/tvl1_flow.flo";
@@ -167,7 +171,6 @@ TEST(Video_calcOpticalFlowDual_TVL1, Regression)
ASSERT_EQ(gold.rows, flow.rows);
ASSERT_EQ(gold.cols, flow.cols);
- const double err = calcRMSE(gold, flow);
- EXPECT_LE(err, MAX_RMSE);
+ check(gold, flow);
#endif
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/opencv.git
More information about the debian-science-commits
mailing list