Skip to content

Commit

Permalink
Merge pull request #2900 from spirraw:master
Browse files Browse the repository at this point in the history
  • Loading branch information
alalek committed Apr 1, 2021
2 parents 4739973 + 068b6c7 commit a124db8
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions modules/aruco/src/aruco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,34 +306,36 @@ static void _filterTooCloseCandidates(const vector< vector< Point2f > > &candida
vector< vector< Point > > smallerContours;

// save possible candidates
for( unsigned int i = 0; i < groupedCandidates.size(); i++ ) {
int smallerIdx = groupedCandidates[i][0];
int biggerIdx = -1;
for(unsigned int i = 0; i < groupedCandidates.size(); i++) {
unsigned int smallerIdx = groupedCandidates[i][0];
unsigned int biggerIdx = smallerIdx;
double smallerArea = contourArea(candidatesIn[smallerIdx]);
double biggerArea = smallerArea;

// evaluate group elements
for( unsigned int j = 1; j < groupedCandidates[i].size(); j++ ) {
size_t currPerim = contoursIn[ groupedCandidates[i][j] ].size();
for(unsigned int j = 1; j < groupedCandidates[i].size(); j++) {
unsigned int currIdx = groupedCandidates[i][j];
double currArea = contourArea(candidatesIn[currIdx]);

// check if current contour is bigger
if ( biggerIdx < 0 )
biggerIdx = groupedCandidates[i][j];
else if(currPerim >= contoursIn[ biggerIdx ].size())
biggerIdx = groupedCandidates[i][j];
if(currArea >= biggerArea) {
biggerIdx = currIdx;
biggerArea = currArea;
}

// check if current contour is smaller
if(currPerim < contoursIn[ smallerIdx ].size() && detectInvertedMarker)
smallerIdx = groupedCandidates[i][j];
if(currArea < smallerArea && detectInvertedMarker) {
smallerIdx = currIdx;
smallerArea = currArea;
}
}
// add contours und candidates
if(biggerIdx > -1){

biggerCandidates.push_back(candidatesIn[biggerIdx]);
biggerContours.push_back(contoursIn[biggerIdx]);

if( detectInvertedMarker ){
smallerCandidates.push_back(alignContourOrder(candidatesIn[biggerIdx][0], candidatesIn[smallerIdx]));
smallerContours.push_back(contoursIn[smallerIdx]);
}
// add contours and candidates
biggerCandidates.push_back(candidatesIn[biggerIdx]);
biggerContours.push_back(contoursIn[biggerIdx]);
if(detectInvertedMarker) {
smallerCandidates.push_back(alignContourOrder(candidatesIn[biggerIdx][0], candidatesIn[smallerIdx]));
smallerContours.push_back(contoursIn[smallerIdx]);
}
}
// to preserve the structure :: candidateSet< defaultCandidates, whiteCandidates >
Expand Down

0 comments on commit a124db8

Please sign in to comment.