diff c/test_feature.cpp @ 201:f7ddfc4aeb1e

added tests for graphs
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 05 Mar 2012 01:52:56 -0500
parents aeab0b88c9b6
children f0f800b95765
line wrap: on
line diff
--- a/c/test_feature.cpp	Fri Mar 02 19:32:54 2012 -0500
+++ b/c/test_feature.cpp	Mon Mar 05 01:52:56 2012 -0500
@@ -1,15 +1,31 @@
 #define BOOST_TEST_MODULE traffic intelligence
 
+#include "Motion.hpp"
+#include "testutils.hpp"
+
+#include "opencv2/core/core.hpp"
+
 #include <boost/test/unit_test.hpp>
 #include <boost/test/floating_point_comparison.hpp>
 
 using namespace std;
+using namespace cv;
 
 BOOST_AUTO_TEST_SUITE(test_feature)
 
-BOOST_AUTO_TEST_CASE(feature_stationary) {
-  int i=5;
-  BOOST_CHECK_EQUAL(i, 5);
+BOOST_AUTO_TEST_CASE(feature_similarity) {
+  FeatureTrajectoryPtr ft1 = createFeatureTrajectory(1, 10, 20, Point2f(1,1), Point2f(0, 1));
+  FeatureTrajectoryPtr ft2 = createFeatureTrajectory(2, 10, 20, Point2f(2,1), Point2f(0, 1));
+
+  BOOST_CHECK(!ft1->minMaxSimilarity(*ft2, 10, 20, 0.5, 0.1));
+  BOOST_CHECK(ft1->minMaxSimilarity(*ft2, 10, 20, 1, 0.1));
+
+  ft2 = createFeatureTrajectory(2, 10, 19, Point2f(1,1), Point2f(0, 1));
+  Mat homography;
+  ft2->addPoint(20, Point2f(1,11.5), homography);
+  
+  BOOST_CHECK(!ft1->minMaxSimilarity(*ft2, 10, 20, 0, 0.4));
+  BOOST_CHECK(ft1->minMaxSimilarity(*ft2, 10, 20, 0, 0.5));
 }
 
 BOOST_AUTO_TEST_SUITE_END()