comparison src/Matcher.cpp @ 89:7785bb8a1be6 refactors

Fix diagonal handling: there was an implicit fixed diagonal weight of 2 in comparison of diagmin+distance to othermin directly
author Chris Cannam
date Thu, 27 Nov 2014 12:59:23 +0000
parents fca28ed15c6e
children 35e50f28720f
comparison
equal deleted inserted replaced
88:1f5291760ed9 89:7785bb8a1be6
276 276
277 float distance = (float) m_metric.calcDistance 277 float distance = (float) m_metric.calcDistance
278 (m_frames[frameIndex], 278 (m_frames[frameIndex],
279 m_otherMatcher->m_frames[index % m_blockSize]); 279 m_otherMatcher->m_frames[index % m_blockSize]);
280 280
281 float diagDistance = distance * m_params.diagonalWeight;
282
281 if ((m_frameCount == 0) && (index == 0)) { // first element 283 if ((m_frameCount == 0) && (index == 0)) { // first element
282 284
283 updateValue(0, 0, AdvanceNone, 285 updateValue(0, 0, AdvanceNone,
284 0, 286 0,
285 distance); 287 distance);
315 min2, distance); 317 min2, distance);
316 318
317 } else { 319 } else {
318 320
319 double min1 = getPathCost(m_frameCount - 1, index - 1); 321 double min1 = getPathCost(m_frameCount - 1, index - 1);
320 if (min1 + distance <= min2) { 322 if (min1 + diagDistance <= min2 + distance) {
321 updateValue(m_frameCount, index, AdvanceBoth, 323 updateValue(m_frameCount, index, AdvanceBoth,
322 min1, distance); 324 min1, distance);
323 } else { 325 } else {
324 updateValue(m_frameCount, index, AdvanceThis, 326 updateValue(m_frameCount, index, AdvanceThis,
325 min2, distance); 327 min2, distance);
336 cerr << "i = "<< m_frameCount << ", j = " << index << ", " 338 cerr << "i = "<< m_frameCount << ", j = " << index << ", "
337 << " min1 = " << min1 << ", " 339 << " min1 = " << min1 << ", "
338 << " min2 = " << min2 << ", " 340 << " min2 = " << min2 << ", "
339 << " min3 = " << min3 << endl; 341 << " min3 = " << min3 << endl;
340 } 342 }
343
344 double cost1 = min1 + distance;
345 double cost2 = min2 + distance;
346 double cost3 = min3 + diagDistance;
341 347
342 if (min1 <= min2) { 348 if (cost1 <= cost2) {
343 if (min3 + distance <= min1) { 349 if (cost3 <= cost1) {
344 updateValue(m_frameCount, index, AdvanceBoth, 350 updateValue(m_frameCount, index, AdvanceBoth,
345 min3, distance); 351 min3, distance);
346 } else { 352 } else {
347 updateValue(m_frameCount, index, AdvanceOther, 353 updateValue(m_frameCount, index, AdvanceOther,
348 min1, distance); 354 min1, distance);
349 } 355 }
350 } else { 356 } else {
351 if (min3 + distance <= min2) { 357 if (cost3 <= cost2) {
352 updateValue(m_frameCount, index, AdvanceBoth, 358 updateValue(m_frameCount, index, AdvanceBoth,
353 min3, distance); 359 min3, distance);
354 } else { 360 } else {
355 updateValue(m_frameCount, index, AdvanceThis, 361 updateValue(m_frameCount, index, AdvanceThis,
356 min2, distance); 362 min2, distance);