Mercurial > hg > match-vamp
changeset 109:fef3160ff0e2 adaptive_diagonals
Return distances through retrievePath
author | Chris Cannam |
---|---|
date | Thu, 04 Dec 2014 14:19:35 +0000 |
parents | 4b263ef50c9b |
children | bca0802191fe |
files | src/Finder.cpp src/Finder.h src/MatchVampPlugin.cpp |
diffstat | 3 files changed, 25 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Finder.cpp Thu Dec 04 13:54:05 2014 +0000 +++ b/src/Finder.cpp Thu Dec 04 14:19:35 2014 +0000 @@ -332,11 +332,14 @@ } #endif -int -Finder::retrievePath(bool smooth, vector<int> &pathx, vector<int> &pathy) +void +Finder::retrievePath(vector<int> &pathx, + vector<int> &pathy, + vector<float> &distances) { pathx.clear(); pathy.clear(); + distances.clear(); #ifdef PERFORM_ERROR_CHECKS checkAndReport(); @@ -346,7 +349,7 @@ int ey = m_m->getFrameCount() - 1; if (ex < 0 || ey < 0) { - return 0; + return; } int x = ex; @@ -381,6 +384,7 @@ pathx.push_back(x); pathy.push_back(y); + distances.push_back(m_m->getDistance(y, x)); switch (m_m->getAdvance(y, x)) { case Matcher::AdvanceThis: @@ -414,13 +418,7 @@ reverse(pathx.begin(), pathx.end()); reverse(pathy.begin(), pathy.end()); - - if (smooth) { - int smoothedLen = Path().smooth(pathx, pathy, pathx.size()); - return smoothedLen; - } else { - return pathx.size(); - } + reverse(distances.begin(), distances.end()); } void
--- a/src/Finder.h Thu Dec 04 13:54:05 2014 +0000 +++ b/src/Finder.h Thu Dec 04 14:19:35 2014 +0000 @@ -58,13 +58,13 @@ * Track back after all of the matchers have been fed in order to * obtain the lowest cost path available. Path x and y coordinate * pairs are returned in corresponding elements of pathx and - * pathy. Return value is the length of the returned path: only - * this many elements from pathx and pathy are valid (any - * subsequent ones may be spurious). - * - * @param smooth whether to smooth the path before returning it + * pathy, and the corresponding elements of the returned distance + * vector contain the distance between the pair of features + * selected at each step in the path. */ - int retrievePath(bool smooth, std::vector<int> &pathx, std::vector<int> &pathy); + void retrievePath(std::vector<int> &pathx, + std::vector<int> &pathy, + std::vector<float> &distances); void smoothWithPinPoints(const std::map<int, int> &);
--- a/src/MatchVampPlugin.cpp Thu Dec 04 13:54:05 2014 +0000 +++ b/src/MatchVampPlugin.cpp Thu Dec 04 14:19:35 2014 +0000 @@ -574,11 +574,16 @@ Finder *finder = m_pipeline->getFinder(); vector<int> pathx; vector<int> pathy; - int len = finder->retrievePath(false, pathx, pathy); //!!! smooth + vector<float> distances; + finder->retrievePath(pathx, pathy, distances); int prevx = 0; int prevy = 0; + int len = pathx.size(); +//!!! +// m_smooth = true; + if (m_smooth) { vector<float> confidence; @@ -588,8 +593,7 @@ int y = pathy[i]; if (x != prevx) { double magSum = m_mag1[y] + m_mag2[x]; -// double distance = m_pm1->getDistance(y, x); - double distance = 0;///!!! + double distance = distances[i]; float c = magSum - distance; confidence.push_back(c); } @@ -627,7 +631,9 @@ pathx.clear(); pathy.clear(); - len = finder->retrievePath(false, pathx, pathy); //!!! smooth + distances.clear(); + finder->retrievePath(pathx, pathy, distances); + len = pathx.size(); } for (int i = 0; i < len; ++i) { @@ -661,8 +667,7 @@ returnFeatures[m_abDivOutNo].push_back(feature); double magSum = m_mag1[y] + m_mag2[x]; -// double distance = m_pm1->getDistance(y, x); - double distance = 0;///!!! + double distance = distances[i]; feature.values.clear(); feature.values.push_back(distance);