Skip to content

Commit

Permalink
sort tags by ID
Browse files Browse the repository at this point in the history
  • Loading branch information
amquake committed Oct 20, 2023
1 parent a163ac2 commit dc14106
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.photonvision.vision.aruco;

import java.util.ArrayList;
import java.util.Arrays;
import org.opencv.core.Mat;
import org.opencv.objdetect.ArucoDetector;
import org.opencv.objdetect.DetectorParameters;
Expand Down Expand Up @@ -89,6 +90,17 @@ public ArucoDetectionResult[] detect(Mat grayscaleImg) {

ids.release();

// sort tags by ID
Arrays.sort(
toReturn,
(ArucoDetectionResult a, ArucoDetectionResult b) -> {
if (a.getId() > b.getId()) {
return 1;
} else if (a.getId() < b.getId()) {
return -1;
} else return 0;
});

return toReturn;
}
}

0 comments on commit dc14106

Please sign in to comment.