# HG changeset patch # User Chris Cannam # Date 1417792788 0 # Node ID c7aa54343131206c1119b64da3a28826143a3d40 # Parent 96c2191a85cc5a6b084e20d1a10811338fcaf964 Use end point when recalculating with pin points diff -r 96c2191a85cc -r c7aa54343131 src/Finder.cpp --- a/src/Finder.cpp Fri Dec 05 14:49:57 2014 +0000 +++ b/src/Finder.cpp Fri Dec 05 15:19:48 2014 +0000 @@ -308,7 +308,13 @@ for (int j = -4; j <= 0; ++j) { cerr << setw(w) << j; for (int i = -4; i <= 0; ++i) { - cerr << setw(ww) << m_m->getDistance(err.r + j, err.c + i); + int r = err.r + j; + int c = err.c + i; + float dist = 0.f; + if (r >= 0 && c >= 0) { + dist = m_m->getDistance(r, c); + } + cerr << setw(ww) << dist; } cerr << endl; } @@ -323,7 +329,13 @@ for (int j = -4; j <= 0; ++j) { cerr << setw(w) << j; for (int i = -4; i <= 0; ++i) { - cerr << setw(ww) << m_m->getPathCost(err.r + j, err.c + i); + int r = err.r + j; + int c = err.c + i; + double cost = 0.0; + if (r >= 0 && c >= 0) { + cost = m_m->getPathCost(r, c); + } + cerr << setw(ww) << cost; } cerr << endl; } @@ -333,18 +345,8 @@ #endif void -Finder::retrievePath(vector &pathx, - vector &pathy, - vector &distances) +Finder::getEndPoint(int &x, int &y) { - pathx.clear(); - pathy.clear(); - distances.clear(); - -#ifdef PERFORM_ERROR_CHECKS -// checkAndReport(); -#endif - int ex = m_m->getOtherFrameCount() - 1; int ey = m_m->getFrameCount() - 1; @@ -352,8 +354,8 @@ return; } - int x = ex; - int y = ey; + x = ex; + y = ey; if (m_duration2 > 0 && m_duration2 < m_m->getOtherFrameCount()) { x = m_duration2 - 1; @@ -373,10 +375,25 @@ x = ex; y = ey; } +} -// recalculatePathCostMatrix(0, 0, y, x); +void +Finder::retrievePath(vector &pathx, + vector &pathy, + vector &distances) +{ + pathx.clear(); + pathy.clear(); + distances.clear(); + +#ifdef PERFORM_ERROR_CHECKS + checkAndReport(); +#endif // cerr << "start: x = " << x << ", y = " << y << endl; + + int x, y; + getEndPoint(x, y); while (m_m->isAvailable(y, x) && (x > 0 || y > 0)) { @@ -436,6 +453,9 @@ if (pinpoints.size() < 2) return; + int ex, ey; + getEndPoint(ex, ey); + pair prev = *pinpoints.begin(); for (PPMap::const_iterator i = pinpoints.begin(); i != pinpoints.end(); ++i) { @@ -443,8 +463,16 @@ pair curr = *i; - recalculatePathCostMatrix(prev.second, prev.first, - curr.second, curr.first, 1.0); + if (curr.first > ex || curr.second > ey) { + + recalculatePathCostMatrix(prev.second, prev.first, + ey, ex, 1.0); + + } else { + + recalculatePathCostMatrix(prev.second, prev.first, + curr.second, curr.first, 1.0); + } prev = curr; } diff -r 96c2191a85cc -r c7aa54343131 src/Finder.h --- a/src/Finder.h Fri Dec 05 14:49:57 2014 +0000 +++ b/src/Finder.h Fri Dec 05 15:19:48 2014 +0000 @@ -89,6 +89,8 @@ void recalculatePathCostMatrix(int r1, int c1, int r2, int c2, float diagonalWeight); + + void getEndPoint(int &x, int &y); Matcher *m_m; int m_duration1;