Mercurial Hosting > traffic-intelligence
diff c/test_feature.cpp @ 481:b6ad86ee7033
implemented smoothing (requires latest trajectory management library version)
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 02 Apr 2014 01:45:53 -0400 |
parents | f0f800b95765 |
children | 05ccd8ef150c |
line wrap: on
line diff
--- a/c/test_feature.cpp Tue Apr 01 17:42:40 2014 -0400 +++ b/c/test_feature.cpp Wed Apr 02 01:45:53 2014 -0400 @@ -10,6 +10,38 @@ using namespace std; using namespace cv; +TEST_CASE("trajectory/smoothing", "test trajectory smoothing (from trajectory management library)") { + TrajectoryPoint2f t1; + for(int i=0; i<20;++i) + t1.add(i, cv::Point2f(1+i, 1+0.5*i)); + + TrajectoryPoint2f t2(t1); + t2.movingAverage(3); + for(int i=0; i<20;++i) + REQUIRE(t1.getPoint(i) == t2.getPoint(i)); + t1.clear(); + cv::Point2f p0(1,1); + cv::Point2f p1(2,2); + cv::Point2f p2(2.4,3); + cv::Point2f p3(3.1,3.4); + cv::Point2f p4(3.4,4); + cv::Point2f p5(3.6,4.5); + + t1.add(0, p0); + t1.add(1, p1); + t1.add(2, p2); + t1.add(3, p3); + t1.add(4, p4); + t1.add(5, p5); + t1.movingAverage(2); + REQUIRE(t1.getPoint(0) == p0); + REQUIRE(t1.getPoint(1) == (p0+p1+p2)*(1./3.)); + REQUIRE(t1.getPoint(2) == (p0+p1+p2+p3+p4)*(1./5.)); + REQUIRE(t1.getPoint(3) == (p1+p2+p3+p4+p5)*(1./5.)); + REQUIRE(t1.getPoint(4) == (p3+p4+p5)*(1./3.)); + REQUIRE(t1.getPoint(5) == p5); +} + TEST_CASE("features/similarity", "test feature similarity measure") { FeatureTrajectoryPtr ft1 = createFeatureTrajectory(1, 10, 20, Point2f(1,1), Point2f(0, 1)); FeatureTrajectoryPtr ft2 = createFeatureTrajectory(2, 10, 20, Point2f(2,1), Point2f(0, 1));