Merge pull request #24829 from vrabaud:aruco_fix

Make aruco detector deterministic.
pull/24837/head
Alexander Smorkalov 1 year ago committed by GitHub
commit 26c44aa7c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      modules/objdetect/src/aruco/aruco_detector.cpp

@ -684,7 +684,7 @@ struct ArucoDetector::ArucoDetectorImpl {
contours.clear();
// sort candidates from big to small
std::sort(candidateTree.begin(), candidateTree.end());
std::stable_sort(candidateTree.begin(), candidateTree.end());
// group index for each candidate
vector<int> groupId(candidateTree.size(), -1);
vector<vector<size_t> > groupedCandidates;
@ -728,11 +728,11 @@ struct ArucoDetector::ArucoDetectorImpl {
for (vector<size_t>& grouped : groupedCandidates) {
if (detectorParams.detectInvertedMarker) // if detectInvertedMarker choose smallest contours
std::sort(grouped.begin(), grouped.end(), [](const size_t &a, const size_t &b) {
std::stable_sort(grouped.begin(), grouped.end(), [](const size_t &a, const size_t &b) {
return a > b;
});
else // if detectInvertedMarker==false choose largest contours
std::sort(grouped.begin(), grouped.end());
std::stable_sort(grouped.begin(), grouped.end());
size_t currId = grouped[0];
isSelectedContours[currId] = true;
for (size_t i = 1ull; i < grouped.size(); i++) {

Loading…
Cancel
Save