From f9c9aacdd7a072a6735ae44e892b7e3cf506660c Mon Sep 17 00:00:00 2001 From: Andres Rios-Tascon Date: Fri, 12 Apr 2024 11:58:20 -0400 Subject: [PATCH] Added extra comparisons to not rely on ordering for duplicate removal --- SDL/Kernels.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/SDL/Kernels.h b/SDL/Kernels.h index 909ee561..db98fdb0 100644 --- a/SDL/Kernels.h +++ b/SDL/Kernels.h @@ -233,7 +233,7 @@ namespace SDL { if (nMatched >= 7) { if (score_rphisum1 > score_rphisum2) { rmQuintupletFromMemory(quintupletsInGPU, ix); - } else if ((score_rphisum1 == score_rphisum2) && (ix < jx)) { + } else if ((score_rphisum1 == score_rphisum2) && (quintupletsInGPU.pt[ix] < quintupletsInGPU.pt[jx])) { rmQuintupletFromMemory(quintupletsInGPU, ix); } } @@ -306,7 +306,7 @@ namespace SDL { rmQuintupletFromMemory(quintupletsInGPU, ix); continue; } - if ((score_rphisum1 == score_rphisum2) && (ix < jx)) { + if ((score_rphisum1 == score_rphisum2) && (quintupletsInGPU.pt[ix] < quintupletsInGPU.pt[jx])) { rmQuintupletFromMemory(quintupletsInGPU, ix); continue; } @@ -341,7 +341,8 @@ namespace SDL { rmPixelTripletFromMemory(pixelTripletsInGPU, ix); break; } else if (pixelTripletsInGPU.logicalLayers[5 * ix + 2] == pixelTripletsInGPU.logicalLayers[5 * jx + 2] && - (__H2F(pixelTripletsInGPU.score[ix]) == __H2F(pixelTripletsInGPU.score[jx])) && (ix < jx)) { + (__H2F(pixelTripletsInGPU.score[ix]) == __H2F(pixelTripletsInGPU.score[jx])) && + (pixelTripletsInGPU.pt[ix] < pixelTripletsInGPU.pt[jx])) { rmPixelTripletFromMemory(pixelTripletsInGPU, ix); break; } @@ -367,7 +368,8 @@ namespace SDL { int nMatched = checkHitspT5(ix, jx, pixelQuintupletsInGPU); float score2 = __H2F(pixelQuintupletsInGPU.score[jx]); if (nMatched >= 7) { - if (score1 > score2 or ((score1 == score2) and (ix > jx))) { + if (score1 > score2 or ((score1 == score2) and (pixelQuintupletsInGPU.quintupletRadius[ix] < + pixelQuintupletsInGPU.quintupletRadius[jx]))) { rmPixelQuintupletFromMemory(pixelQuintupletsInGPU, ix); break; } @@ -417,7 +419,7 @@ namespace SDL { char quad_diff = segmentsInGPU.isQuad[ix] - segmentsInGPU.isQuad[jx]; float score_diff = segmentsInGPU.score[ix] - segmentsInGPU.score[jx]; // Always keep quads over trips. If they are the same, we want the object with better score - int idxToRemove; + int idxToRemove = -1; if (quad_diff > 0) idxToRemove = jx; else if (quad_diff < 0) @@ -426,9 +428,12 @@ namespace SDL { idxToRemove = jx; else if (score_diff > 0) idxToRemove = ix; - else + else if (segmentsInGPU.circleRadius[ix] < segmentsInGPU.circleRadius[jx]) idxToRemove = ix; + if (idxToRemove == -1) + continue; + unsigned int phits2[4]; phits2[0] = segmentsInGPU.pLSHitsIdxs[jx].x; phits2[1] = segmentsInGPU.pLSHitsIdxs[jx].y;