Skip to content

Commit 3fb1bb5

Browse files
author
AleksandrPanov
committed
fix search for one contour in _filterTooCloseCandidates()
1 parent a10b397 commit 3fb1bb5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

modules/aruco/src/aruco.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ static void _filterTooCloseCandidates(const vector< vector< Point2f > > &candida
284284
candGroup.resize(candidatesIn.size(), -1);
285285
vector< vector<unsigned int> > groupedCandidates;
286286
for(unsigned int i = 0; i < candidatesIn.size(); i++) {
287+
bool isSingleContour = true;
287288
for(unsigned int j = i + 1; j < candidatesIn.size(); j++) {
288289

289290
int minimumPerimeter = min((int)contoursIn[i].size(), (int)contoursIn[j].size() );
@@ -304,6 +305,7 @@ static void _filterTooCloseCandidates(const vector< vector< Point2f > > &candida
304305
// if mean square distance is too low, remove the smaller one of the two markers
305306
double minMarkerDistancePixels = double(minimumPerimeter) * minMarkerDistanceRate;
306307
if(distSq < minMarkerDistancePixels * minMarkerDistancePixels) {
308+
isSingleContour = false;
307309
// i and j are not related to a group
308310
if(candGroup[i]<0 && candGroup[j]<0){
309311
// mark candidates with their corresponding group number
@@ -334,6 +336,14 @@ static void _filterTooCloseCandidates(const vector< vector< Point2f > > &candida
334336
}
335337
}
336338
}
339+
if (isSingleContour && candGroup[i] < 0)
340+
{
341+
candGroup[i] = (int)groupedCandidates.size();
342+
vector<unsigned int> grouped;
343+
grouped.push_back(i);
344+
grouped.push_back(i);
345+
groupedCandidates.push_back( grouped );
346+
}
337347
}
338348

339349
// save possible candidates

0 commit comments

Comments
 (0)