mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Merge pull request #24829 from vrabaud:aruco_fix
Make aruco detector deterministic.
This commit is contained in:
commit
26c44aa7c6
@ -684,7 +684,7 @@ struct ArucoDetector::ArucoDetectorImpl {
|
|||||||
contours.clear();
|
contours.clear();
|
||||||
|
|
||||||
// sort candidates from big to small
|
// sort candidates from big to small
|
||||||
std::sort(candidateTree.begin(), candidateTree.end());
|
std::stable_sort(candidateTree.begin(), candidateTree.end());
|
||||||
// group index for each candidate
|
// group index for each candidate
|
||||||
vector<int> groupId(candidateTree.size(), -1);
|
vector<int> groupId(candidateTree.size(), -1);
|
||||||
vector<vector<size_t> > groupedCandidates;
|
vector<vector<size_t> > groupedCandidates;
|
||||||
@ -728,11 +728,11 @@ struct ArucoDetector::ArucoDetectorImpl {
|
|||||||
|
|
||||||
for (vector<size_t>& grouped : groupedCandidates) {
|
for (vector<size_t>& grouped : groupedCandidates) {
|
||||||
if (detectorParams.detectInvertedMarker) // if detectInvertedMarker choose smallest contours
|
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;
|
return a > b;
|
||||||
});
|
});
|
||||||
else // if detectInvertedMarker==false choose largest contours
|
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];
|
size_t currId = grouped[0];
|
||||||
isSelectedContours[currId] = true;
|
isSelectedContours[currId] = true;
|
||||||
for (size_t i = 1ull; i < grouped.size(); i++) {
|
for (size_t i = 1ull; i < grouped.size(); i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user