Mercurial > hg > match-vamp
diff src/MatchFeatureFeeder.cpp @ 167:28c73e5db2eb structure
Allow querying the best-estimate reference frame for the current feed point; don't heap-allocate finder
| author | Chris Cannam |
|---|---|
| date | Thu, 05 Feb 2015 14:06:57 +0000 |
| parents | 2b61e0cb6847 |
| children | 70636e3c5a46 |
line wrap: on
line diff
--- a/src/MatchFeatureFeeder.cpp Thu Jan 29 13:29:48 2015 +0000 +++ b/src/MatchFeatureFeeder.cpp Thu Feb 05 14:06:57 2015 +0000 @@ -19,21 +19,21 @@ using std::vector; MatchFeatureFeeder::MatchFeatureFeeder(Matcher *m1, Matcher *m2) : - m_pm1(m1), m_pm2(m2) + m_pm1(m1), + m_pm2(m2), + m_finder(m_pm1) { - m_finder = new Finder(m1); } MatchFeatureFeeder::~MatchFeatureFeeder() { - delete m_finder; } MatchFeatureFeeder::MatchFeatureFeeder(const MatchFeatureFeeder &other) : - m_pm1(other.m_pm1), m_pm2(other.m_pm2) + m_pm1(other.m_pm1), + m_pm2(other.m_pm2), + m_finder(m_pm1) { - //!!! This is gross. Finder should probably not be heap allocated at all - m_finder = new Finder(*other.m_finder); } MatchFeatureFeeder & @@ -41,7 +41,7 @@ { m_pm1 = other.m_pm1; m_pm2 = other.m_pm2; - m_finder = new Finder(*other.m_finder); + m_finder = Finder(m_pm1); return *this; } @@ -50,7 +50,7 @@ { m_pm1 = m1; m_pm2 = m2; - m_finder->setMatcher(m_pm1); + m_finder.setMatcher(m_pm1); } void @@ -75,6 +75,21 @@ } } +int +MatchFeatureFeeder::getEstimatedReferenceFrame() +{ + if (m_pm1->getFrameCount() == 0 || m_pm2->getFrameCount() == 0) { + return 0; + } + int bestRow = 0; + double bestCost = 0; + if (!m_finder.getBestColCost(m_pm2->getFrameCount()-1, bestRow, bestCost)) { + return -1; + } else { + return bestRow; + } +} + void MatchFeatureFeeder::finish() { @@ -98,7 +113,7 @@ } else if (m_pm2->isOverrunning()) { feed1(); } else { - switch (m_finder->getExpandDirection + switch (m_finder.getExpandDirection (m_pm1->getFrameCount()-1, m_pm2->getFrameCount()-1)) { case Matcher::AdvanceThis: feed1();
