Skip to content

Commit 592b376

Browse files
committed
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
2 parents d2581b4 + b01f2f9 commit 592b376

File tree

2 files changed

+34
-17
lines changed

2 files changed

+34
-17
lines changed

modules/xfeatures2d/test/test_surf.cuda.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ CUDA_TEST_P(CUDA_SURF, Detector)
9999
std::vector<cv::KeyPoint> keypoints_gold;
100100
surf_gold->detect(image, keypoints_gold);
101101

102-
ASSERT_EQ(keypoints_gold.size(), keypoints.size());
102+
int lengthDiff = abs((int)keypoints_gold.size()) - ((int)keypoints.size());
103+
EXPECT_LE(lengthDiff, 1);
103104
int matchedCount = getMatchedPointsCount(keypoints_gold, keypoints);
104105
double matchedRatio = static_cast<double>(matchedCount) / keypoints_gold.size();
105106

@@ -130,7 +131,8 @@ CUDA_TEST_P(CUDA_SURF, Detector_Masked)
130131
std::vector<cv::KeyPoint> keypoints_gold;
131132
surf_gold->detect(image, keypoints_gold, mask);
132133

133-
ASSERT_EQ(keypoints_gold.size(), keypoints.size());
134+
int lengthDiff = abs((int)keypoints_gold.size()) - ((int)keypoints.size());
135+
EXPECT_LE(lengthDiff, 1);
134136
int matchedCount = getMatchedPointsCount(keypoints_gold, keypoints);
135137
double matchedRatio = static_cast<double>(matchedCount) / keypoints_gold.size();
136138

@@ -171,19 +173,11 @@ CUDA_TEST_P(CUDA_SURF, Descriptor)
171173
EXPECT_GT(matchedRatio, 0.6);
172174
}
173175

174-
#if defined (__x86_64__) || defined (_M_X64)
175176
testing::internal::ValueArray3<SURF_HessianThreshold, SURF_HessianThreshold, SURF_HessianThreshold> thresholdValues =
176177
testing::Values(
177178
SURF_HessianThreshold(100.0),
178179
SURF_HessianThreshold(500.0),
179180
SURF_HessianThreshold(1000.0));
180-
#else
181-
// hessian computation is not bit-exact and lower threshold causes different count of detection
182-
testing::internal::ValueArray2<SURF_HessianThreshold, SURF_HessianThreshold> thresholdValues =
183-
testing::Values(
184-
SURF_HessianThreshold(830.0),
185-
SURF_HessianThreshold(1000.0));
186-
#endif
187181

188182
INSTANTIATE_TEST_CASE_P(CUDA_Features2D, CUDA_SURF, testing::Combine(
189183
thresholdValues,

modules/xfeatures2d/test/test_surf.ocl.cpp

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,35 @@ static int getMatchedPointsCount(std::vector<cv::KeyPoint>& gold, std::vector<cv
7878

7979
int validCount = 0;
8080

81-
for (size_t i = 0; i < gold.size(); ++i)
81+
if (actual.size() == gold.size())
8282
{
83-
const cv::KeyPoint& p1 = gold[i];
84-
const cv::KeyPoint& p2 = actual[i];
85-
86-
if (keyPointsEquals(p1, p2))
87-
++validCount;
83+
for (size_t i = 0; i < gold.size(); ++i)
84+
{
85+
const cv::KeyPoint& p1 = gold[i];
86+
const cv::KeyPoint& p2 = actual[i];
87+
88+
if (keyPointsEquals(p1, p2))
89+
++validCount;
90+
}
91+
}
92+
else
93+
{
94+
std::vector<cv::KeyPoint>& shorter = gold;
95+
std::vector<cv::KeyPoint>& longer = actual;
96+
if (actual.size() < gold.size())
97+
{
98+
shorter = actual;
99+
longer = gold;
100+
}
101+
for (size_t i = 0; i < shorter.size(); ++i)
102+
{
103+
const cv::KeyPoint& p1 = shorter[i];
104+
const cv::KeyPoint& p2 = longer[i];
105+
const cv::KeyPoint& p3 = longer[i+1];
106+
107+
if (keyPointsEquals(p1, p2) || keyPointsEquals(p1, p3))
108+
++validCount;
109+
}
88110
}
89111

90112
return validCount;
@@ -154,7 +176,8 @@ TEST_P(SURF, Detector)
154176
std::vector<cv::KeyPoint> keypoints_gold;
155177
surf->detect(image, keypoints_gold, cv::noArray());
156178

157-
ASSERT_EQ(keypoints_gold.size(), keypoints.size());
179+
int lengthDiff = abs((int)keypoints_gold.size()) - ((int)keypoints.size());
180+
EXPECT_LE(lengthDiff, 1);
158181
int matchedCount = getMatchedPointsCount(keypoints_gold, keypoints);
159182
double matchedRatio = static_cast<double>(matchedCount) / keypoints_gold.size();
160183

0 commit comments

Comments
 (0)