Skip to content

Commit 90becbc

Browse files
author
AleksandrPanov
committed
fix
1 parent e3ea0a3 commit 90becbc

File tree

2 files changed

+18
-23
lines changed

2 files changed

+18
-23
lines changed

modules/aruco/perf/perf_aruco.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -152,22 +152,19 @@ class MarkerPainter
152152
}
153153
};
154154

155-
static inline vector<double> getDistanceVector(map<int, vector<Point2f> > &golds, const vector<int>& ids,
155+
static inline double getMaxDistance(map<int, vector<Point2f> > &golds, const vector<int>& ids,
156156
const vector<vector<Point2f> >& corners)
157157
{
158-
vector<double> distVector(ids.size(), numeric_limits<double>::max());
158+
double distance = 0.;
159159
for (size_t i = 0; i < ids.size(); i++)
160160
{
161161
int id = ids[i];
162162
const auto gold_corners = golds.find(id);
163163
if (gold_corners != golds.end())
164164
for (int c = 0; c < 4; c++)
165-
{
166-
double distance = cv::norm(gold_corners->second[c] - corners[i][c]);
167-
distVector[i] = distance;
168-
}
165+
distance = std::max(distance, cv::norm(gold_corners->second[c] - corners[i][c]));
169166
}
170-
return distVector;
167+
return distance;
171168
}
172169

173170
PERF_TEST_P(EstimateAruco, ArucoFirst, ESTIMATE_PARAMS)
@@ -180,7 +177,7 @@ PERF_TEST_P(EstimateAruco, ArucoFirst, ESTIMATE_PARAMS)
180177
detectorParams->cornerRefinementMethod = cv::aruco::CORNER_REFINE_SUBPIX;
181178

182179
const int markerSize = 100;
183-
const size_t numMarkersInRow = 9;
180+
const int numMarkersInRow = 9;
184181
//USE_ARUCO3
185182
detectorParams->useAruco3Detection = get<0>(testParams);
186183
if (detectorParams->useAruco3Detection) {
@@ -197,9 +194,10 @@ PERF_TEST_P(EstimateAruco, ArucoFirst, ESTIMATE_PARAMS)
197194
{
198195
aruco::detectMarkers(image_map.first, dictionary, corners, ids, detectorParams);
199196
}
200-
ASSERT_EQ(numMarkersInRow*numMarkersInRow, ids.size());
201-
auto distVector = getDistanceVector(image_map.second, ids, corners);
202-
SANITY_CHECK(distVector, 3.0*4.0, ERROR_ABSOLUTE);
197+
ASSERT_EQ(numMarkersInRow*numMarkersInRow, static_cast<int>(ids.size()));
198+
double maxDistance = getMaxDistance(image_map.second, ids, corners);
199+
ASSERT_LT(maxDistance, 3.);
200+
SANITY_CHECK_NOTHING();
203201
}
204202

205203
PERF_TEST_P(EstimateAruco, ArucoSecond, ESTIMATE_PARAMS)
@@ -218,7 +216,7 @@ PERF_TEST_P(EstimateAruco, ArucoSecond, ESTIMATE_PARAMS)
218216
detectorParams->minMarkerLengthRatioOriginalImg = 0.f;
219217
}
220218
const int markerSize = 200;
221-
const size_t numMarkersInRow = 11;
219+
const int numMarkersInRow = 11;
222220
MarkerPainter painter(markerSize);
223221
auto image_map = painter.getProjectMarkersTile(numMarkersInRow, detectorParams, dictionary);
224222

@@ -229,9 +227,10 @@ PERF_TEST_P(EstimateAruco, ArucoSecond, ESTIMATE_PARAMS)
229227
{
230228
aruco::detectMarkers(image_map.first, dictionary, corners, ids, detectorParams);
231229
}
232-
ASSERT_EQ(numMarkersInRow*numMarkersInRow, ids.size());
233-
auto distVector = getDistanceVector(image_map.second, ids, corners);
234-
SANITY_CHECK(distVector, 3.0*4.0, ERROR_ABSOLUTE);
230+
ASSERT_EQ(numMarkersInRow*numMarkersInRow, static_cast<int>(ids.size()));
231+
double maxDistance = getMaxDistance(image_map.second, ids, corners);
232+
ASSERT_LT(maxDistance, 3.);
233+
SANITY_CHECK_NOTHING();
235234
}
236235

237236
struct Aruco3Params
@@ -284,8 +283,9 @@ PERF_TEST_P(EstimateLargeAruco, ArucoFHD, ESTIMATE_FHD_PARAMS)
284283
aruco::detectMarkers(image_map.first, dictionary, corners, ids, detectorParams);
285284
}
286285
ASSERT_EQ(numMarkersInRow*numMarkersInRow, static_cast<int>(ids.size()));
287-
auto distVector = getDistanceVector(image_map.second, ids, corners);
288-
SANITY_CHECK(distVector, 3.0*4.0, ERROR_ABSOLUTE);
286+
double maxDistance = getMaxDistance(image_map.second, ids, corners);
287+
ASSERT_LT(maxDistance, 3.);
288+
SANITY_CHECK_NOTHING();
289289
}
290290

291291
}

modules/aruco/perf/perf_main.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
#include "perf_precomp.hpp"
22

3-
static void initTests()
4-
{
5-
cvtest::addDataSearchSubDirectory("contrib/aruco");
6-
}
7-
8-
CV_PERF_TEST_MAIN(aruco, initTests())
3+
CV_PERF_TEST_MAIN(aruco)

0 commit comments

Comments
 (0)