comparison 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
comparison
equal deleted inserted replaced
480:f43bc0b0ba74 481:b6ad86ee7033
7 7
8 #include "catch.hpp" 8 #include "catch.hpp"
9 9
10 using namespace std; 10 using namespace std;
11 using namespace cv; 11 using namespace cv;
12
13 TEST_CASE("trajectory/smoothing", "test trajectory smoothing (from trajectory management library)") {
14 TrajectoryPoint2f t1;
15 for(int i=0; i<20;++i)
16 t1.add(i, cv::Point2f(1+i, 1+0.5*i));
17
18 TrajectoryPoint2f t2(t1);
19 t2.movingAverage(3);
20 for(int i=0; i<20;++i)
21 REQUIRE(t1.getPoint(i) == t2.getPoint(i));
22 t1.clear();
23 cv::Point2f p0(1,1);
24 cv::Point2f p1(2,2);
25 cv::Point2f p2(2.4,3);
26 cv::Point2f p3(3.1,3.4);
27 cv::Point2f p4(3.4,4);
28 cv::Point2f p5(3.6,4.5);
29
30 t1.add(0, p0);
31 t1.add(1, p1);
32 t1.add(2, p2);
33 t1.add(3, p3);
34 t1.add(4, p4);
35 t1.add(5, p5);
36 t1.movingAverage(2);
37 REQUIRE(t1.getPoint(0) == p0);
38 REQUIRE(t1.getPoint(1) == (p0+p1+p2)*(1./3.));
39 REQUIRE(t1.getPoint(2) == (p0+p1+p2+p3+p4)*(1./5.));
40 REQUIRE(t1.getPoint(3) == (p1+p2+p3+p4+p5)*(1./5.));
41 REQUIRE(t1.getPoint(4) == (p3+p4+p5)*(1./3.));
42 REQUIRE(t1.getPoint(5) == p5);
43 }
12 44
13 TEST_CASE("features/similarity", "test feature similarity measure") { 45 TEST_CASE("features/similarity", "test feature similarity measure") {
14 FeatureTrajectoryPtr ft1 = createFeatureTrajectory(1, 10, 20, Point2f(1,1), Point2f(0, 1)); 46 FeatureTrajectoryPtr ft1 = createFeatureTrajectory(1, 10, 20, Point2f(1,1), Point2f(0, 1));
15 FeatureTrajectoryPtr ft2 = createFeatureTrajectory(2, 10, 20, Point2f(2,1), Point2f(0, 1)); 47 FeatureTrajectoryPtr ft2 = createFeatureTrajectory(2, 10, 20, Point2f(2,1), Point2f(0, 1));
16 48