# HG changeset patch # User Nicolas Saunier # Date 1324359097 18000 # Node ID aeab0b88c9b690070cb1294c82dae3578f4b4a8e # Parent 1247e26a8b5ee58dbc9be03d5e693ff8210b04fe began testing of FeatureGraph diff -r 1247e26a8b5e -r aeab0b88c9b6 c/Makefile --- a/c/Makefile Fri Dec 16 11:34:07 2011 -0500 +++ b/c/Makefile Tue Dec 20 00:31:37 2011 -0500 @@ -51,11 +51,11 @@ #GUI_OBJS = CV_OBJS = cvutils.o -COMMON_OBJS = utils.o +COMMON_OBJS = utils.o Motion.o Parameters.o utils.o OBJS = $(COMMON_OBJS) $(CV_OBJS) -TESTS_OBJS = test_feature.o +TESTS_OBJS = test_feature.o test_graph.o ifeq ($(UNAME), Linux) - TESTS_OBJS += $(LINUX_BOOST_PREFIX)/lib/libboost_unit_test_framework-mt.a + TESTS_OBJS += $(LINUX_BOOST_PREFIX)/lib/libboost_unit_test_framework.a endif @@ -75,7 +75,7 @@ $(CXX) $(CFLAGS) $(LIBS) -o $(EXE_DIR)/$@ $^ $(LDFLAGS) $(EXE_DIR)/$@ -feature-based-tracking: feature-based-tracking.o cvutils.o Motion.o Parameters.o utils.o +feature-based-tracking: feature-based-tracking.o $(OBJS) $(CXX) $(CFLAGS) $(LIBS) $^ -o $(EXE_DIR)/$@ $(LDFLAGS) track-features.o: track-features.cpp diff -r 1247e26a8b5e -r aeab0b88c9b6 c/Motion.cpp --- a/c/Motion.cpp Fri Dec 16 11:34:07 2011 -0500 +++ b/c/Motion.cpp Tue Dec 20 00:31:37 2011 -0500 @@ -217,12 +217,16 @@ return featureGroups; } -string FeatureGraph::informationString(void) { +string FeatureGraph::informationString(void) const { stringstream ss; ss << num_vertices(graph) << " vertices, " << num_edges(graph) << " edges"; return ss.str(); } +int FeatureGraph::getNVertices(void) const { return num_vertices(graph);} + +int FeatureGraph::getNEdges(void) const { return num_edges(graph);} + void FeatureGraph::computeVertexIndex(void) { graph_traits::vertex_iterator vi, vend; graph_traits::vertices_size_type cnt = 0; diff -r 1247e26a8b5e -r aeab0b88c9b6 c/test_feature.cpp --- a/c/test_feature.cpp Fri Dec 16 11:34:07 2011 -0500 +++ b/c/test_feature.cpp Tue Dec 20 00:31:37 2011 -0500 @@ -5,7 +5,7 @@ using namespace std; -BOOST_AUTO_TEST_SUITE(test_process) +BOOST_AUTO_TEST_SUITE(test_feature) BOOST_AUTO_TEST_CASE(feature_stationary) { int i=5; diff -r 1247e26a8b5e -r aeab0b88c9b6 c/test_graph.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c/test_graph.cpp Tue Dec 20 00:31:37 2011 -0500 @@ -0,0 +1,30 @@ +#include "Motion.hpp" +#include "testutils.hpp" + +#include "opencv2/core/core.hpp" + +#include +#include + +using namespace std; +using namespace cv; + +BOOST_AUTO_TEST_SUITE(test_graph) + +BOOST_AUTO_TEST_CASE(graph_add_delete) { + FeatureGraph featureGraph(5, 1, 5, 1.); + FeatureTrajectoryPtr ft1 = createFeatureTrajectory(10, 20, Point2f(1,1), Point2f(0.5, 0.)); + FeatureTrajectoryPtr ft2 = createFeatureTrajectory(10, 20, Point2f(1.1,1), Point2f(0.5, 0.)); + + featureGraph.addFeature(ft1); + BOOST_CHECK_EQUAL(featureGraph.getNVertices(), 1); + BOOST_CHECK_EQUAL(featureGraph.getNEdges(), 0); + + // featureGraph.addFeature(ft2); + // BOOST_CHECK_EQUAL(featureGraph.getNVertices(), 2); + // BOOST_CHECK_EQUAL(featureGraph.getNEdges(), 1); + + +} + +BOOST_AUTO_TEST_SUITE_END() diff -r 1247e26a8b5e -r aeab0b88c9b6 include/Motion.hpp --- a/include/Motion.hpp Fri Dec 16 11:34:07 2011 -0500 +++ b/include/Motion.hpp Tue Dec 20 00:31:37 2011 -0500 @@ -124,7 +124,10 @@ */ std::vector > getFeatureGroups(void); - std::string informationString(void); + std::string informationString(void) const; + + int getNVertices(void) const; + int getNEdges(void) const; protected: float connectionDistance; diff -r 1247e26a8b5e -r aeab0b88c9b6 include/testutils.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/testutils.hpp Tue Dec 20 00:31:37 2011 -0500 @@ -0,0 +1,21 @@ +#ifndef TEST_UTILS_HPP +#define TEST_UTILS_HPP + +#include "Motion.hpp" + +#include "opencv2/core/core.hpp" + +#include + +inline boost::shared_ptr createFeatureTrajectory(const int& firstInstant, const int& lastInstant, const cv::Point2f& firstPosition, const cv::Point2f& velocity) { + cv::Mat emptyHomography; + boost::shared_ptr t = boost::shared_ptr(new FeatureTrajectory(firstInstant, firstPosition, emptyHomography)); + cv::Point2f p = firstPosition; + for (int i=firstInstant+1; i<=lastInstant; ++i) { + p = p+velocity; + t->addPoint(i, p, emptyHomography); + } + return t; +} + +#endif