Merge pull request #3426 from tomoaki0705:handleNonBitExact

pull/3427/head^2
Alexander Alekhin 2 years ago
commit b01f2f90a9
  1. 14
      modules/xfeatures2d/test/test_surf.cuda.cpp
  2. 37
      modules/xfeatures2d/test/test_surf.ocl.cpp

@ -99,7 +99,8 @@ CUDA_TEST_P(CUDA_SURF, Detector)
std::vector<cv::KeyPoint> keypoints_gold; std::vector<cv::KeyPoint> keypoints_gold;
surf_gold->detect(image, keypoints_gold); surf_gold->detect(image, keypoints_gold);
ASSERT_EQ(keypoints_gold.size(), keypoints.size()); int lengthDiff = abs((int)keypoints_gold.size()) - ((int)keypoints.size());
EXPECT_LE(lengthDiff, 1);
int matchedCount = getMatchedPointsCount(keypoints_gold, keypoints); int matchedCount = getMatchedPointsCount(keypoints_gold, keypoints);
double matchedRatio = static_cast<double>(matchedCount) / keypoints_gold.size(); double matchedRatio = static_cast<double>(matchedCount) / keypoints_gold.size();
@ -130,7 +131,8 @@ CUDA_TEST_P(CUDA_SURF, Detector_Masked)
std::vector<cv::KeyPoint> keypoints_gold; std::vector<cv::KeyPoint> keypoints_gold;
surf_gold->detect(image, keypoints_gold, mask); surf_gold->detect(image, keypoints_gold, mask);
ASSERT_EQ(keypoints_gold.size(), keypoints.size()); int lengthDiff = abs((int)keypoints_gold.size()) - ((int)keypoints.size());
EXPECT_LE(lengthDiff, 1);
int matchedCount = getMatchedPointsCount(keypoints_gold, keypoints); int matchedCount = getMatchedPointsCount(keypoints_gold, keypoints);
double matchedRatio = static_cast<double>(matchedCount) / keypoints_gold.size(); double matchedRatio = static_cast<double>(matchedCount) / keypoints_gold.size();
@ -171,19 +173,11 @@ CUDA_TEST_P(CUDA_SURF, Descriptor)
EXPECT_GT(matchedRatio, 0.6); EXPECT_GT(matchedRatio, 0.6);
} }
#if defined (__x86_64__) || defined (_M_X64)
testing::internal::ValueArray3<SURF_HessianThreshold, SURF_HessianThreshold, SURF_HessianThreshold> thresholdValues = testing::internal::ValueArray3<SURF_HessianThreshold, SURF_HessianThreshold, SURF_HessianThreshold> thresholdValues =
testing::Values( testing::Values(
SURF_HessianThreshold(100.0), SURF_HessianThreshold(100.0),
SURF_HessianThreshold(500.0), SURF_HessianThreshold(500.0),
SURF_HessianThreshold(1000.0)); SURF_HessianThreshold(1000.0));
#else
// hessian computation is not bit-exact and lower threshold causes different count of detection
testing::internal::ValueArray2<SURF_HessianThreshold, SURF_HessianThreshold> thresholdValues =
testing::Values(
SURF_HessianThreshold(830.0),
SURF_HessianThreshold(1000.0));
#endif
INSTANTIATE_TEST_CASE_P(CUDA_Features2D, CUDA_SURF, testing::Combine( INSTANTIATE_TEST_CASE_P(CUDA_Features2D, CUDA_SURF, testing::Combine(
thresholdValues, thresholdValues,

@ -78,13 +78,35 @@ static int getMatchedPointsCount(std::vector<cv::KeyPoint>& gold, std::vector<cv
int validCount = 0; int validCount = 0;
for (size_t i = 0; i < gold.size(); ++i) if (actual.size() == gold.size())
{ {
const cv::KeyPoint& p1 = gold[i]; for (size_t i = 0; i < gold.size(); ++i)
const cv::KeyPoint& p2 = actual[i]; {
const cv::KeyPoint& p1 = gold[i];
if (keyPointsEquals(p1, p2)) const cv::KeyPoint& p2 = actual[i];
++validCount;
if (keyPointsEquals(p1, p2))
++validCount;
}
}
else
{
std::vector<cv::KeyPoint>& shorter = gold;
std::vector<cv::KeyPoint>& longer = actual;
if (actual.size() < gold.size())
{
shorter = actual;
longer = gold;
}
for (size_t i = 0; i < shorter.size(); ++i)
{
const cv::KeyPoint& p1 = shorter[i];
const cv::KeyPoint& p2 = longer[i];
const cv::KeyPoint& p3 = longer[i+1];
if (keyPointsEquals(p1, p2) || keyPointsEquals(p1, p3))
++validCount;
}
} }
return validCount; return validCount;
@ -154,7 +176,8 @@ TEST_P(SURF, Detector)
std::vector<cv::KeyPoint> keypoints_gold; std::vector<cv::KeyPoint> keypoints_gold;
surf->detect(image, keypoints_gold, cv::noArray()); surf->detect(image, keypoints_gold, cv::noArray());
ASSERT_EQ(keypoints_gold.size(), keypoints.size()); int lengthDiff = abs((int)keypoints_gold.size()) - ((int)keypoints.size());
EXPECT_LE(lengthDiff, 1);
int matchedCount = getMatchedPointsCount(keypoints_gold, keypoints); int matchedCount = getMatchedPointsCount(keypoints_gold, keypoints);
double matchedRatio = static_cast<double>(matchedCount) / keypoints_gold.size(); double matchedRatio = static_cast<double>(matchedCount) / keypoints_gold.size();

Loading…
Cancel
Save