chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html
|
||||
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
namespace opencv_test {
|
||||
namespace ocl {
|
||||
|
||||
typedef Size_MatType AKAZEFixture;
|
||||
|
||||
OCL_PERF_TEST_P(AKAZEFixture, detectAndCompute, ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), OCL_PERF_ENUM((MatType)CV_8UC1)))
|
||||
{
|
||||
const Size_MatType_t params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat img(srcSize, type), mask;
|
||||
declare.in(img, WARMUP_RNG);
|
||||
|
||||
Ptr<AKAZE> akaze = AKAZE::create(AKAZE::DESCRIPTOR_MLDB_UPRIGHT, 0, 3, 0.001f, 1, 1, KAZE::DIFF_PM_G2);
|
||||
vector<KeyPoint> points;
|
||||
UMat descriptors;
|
||||
|
||||
OCL_TEST_CYCLE() akaze->detectAndCompute(img, mask, points, descriptors, false);
|
||||
|
||||
EXPECT_GT(points.size(), 20u);
|
||||
EXPECT_EQ((size_t)descriptors.rows, points.size());
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
typedef Size_MatType AKAZEOclMldbUprightFixture;
|
||||
|
||||
OCL_PERF_TEST_P(AKAZEOclMldbUprightFixture, detectAndComputeMLDB,
|
||||
::testing::Combine(
|
||||
::testing::Values(
|
||||
cv::Size(320, 240), cv::Size(640, 480), cv::Size(960, 540),
|
||||
cv::Size(1280, 720), cv::Size(1920, 1080), cv::Size(2560, 1440), cv::Size(3840, 2160)
|
||||
),
|
||||
OCL_PERF_ENUM((MatType)CV_8UC1)
|
||||
))
|
||||
{
|
||||
const Size_MatType_t params = GetParam();
|
||||
const cv::Size srcSize = get<0>(params);
|
||||
|
||||
UMat img(srcSize, CV_8U);
|
||||
declare.in(img, WARMUP_RNG);
|
||||
|
||||
Ptr<Feature2D> det = AKAZE::create(AKAZE::DESCRIPTOR_MLDB_UPRIGHT, 0, 3, 0.001f, 4, 4, KAZE::DIFF_PM_G2);
|
||||
vector<KeyPoint> kps;
|
||||
UMat descriptors;
|
||||
|
||||
OCL_TEST_CYCLE() det->detectAndCompute(img, noArray(), kps, descriptors, false);
|
||||
|
||||
EXPECT_GT(kps.size(), 0u);
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
typedef tuple<std::string, int> AKAZEOclRealImagesParams;
|
||||
typedef TestBaseWithParam<AKAZEOclRealImagesParams> AKAZEOclRealImagesFixture;
|
||||
|
||||
OCL_PERF_TEST_P(AKAZEOclRealImagesFixture, detectAndComputeMLDBRealImages,
|
||||
::testing::Combine(
|
||||
::testing::Values(
|
||||
std::string("stitching/boat1.jpg"),
|
||||
std::string("stitching/boat2.jpg"),
|
||||
std::string("stitching/boat3.jpg"),
|
||||
std::string("stitching/boat4.jpg"),
|
||||
std::string("stitching/boat5.jpg"),
|
||||
std::string("stitching/boat6.jpg")
|
||||
),
|
||||
::testing::Values(0)
|
||||
))
|
||||
{
|
||||
const std::string imgName = get<0>(GetParam());
|
||||
|
||||
Mat img_mat = imread(getDataPath(imgName), IMREAD_GRAYSCALE);
|
||||
if (img_mat.empty())
|
||||
throw cvtest::SkipTestException("Image not found: " + imgName);
|
||||
|
||||
UMat img;
|
||||
img_mat.copyTo(img);
|
||||
declare.in(img);
|
||||
|
||||
Ptr<Feature2D> det = AKAZE::create(AKAZE::DESCRIPTOR_MLDB_UPRIGHT, 0, 3, 0.001f, 4, 4, KAZE::DIFF_PM_G2);
|
||||
vector<KeyPoint> kps;
|
||||
UMat descriptors;
|
||||
|
||||
OCL_TEST_CYCLE() det->detectAndCompute(img, noArray(), kps, descriptors, false);
|
||||
|
||||
EXPECT_GT(kps.size(), 0u);
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
typedef Size_MatType AKAZEOclKazeUprightFixture;
|
||||
|
||||
OCL_PERF_TEST_P(AKAZEOclKazeUprightFixture, detectAndComputeKAZEUpright,
|
||||
::testing::Combine(
|
||||
::testing::Values(cv::Size(320, 240), cv::Size(640, 480), cv::Size(1280, 720)),
|
||||
OCL_PERF_ENUM((MatType)CV_8UC1)
|
||||
))
|
||||
{
|
||||
const Size_MatType_t params = GetParam();
|
||||
const cv::Size srcSize = get<0>(params);
|
||||
|
||||
UMat img(srcSize, CV_8U);
|
||||
declare.in(img, WARMUP_RNG);
|
||||
|
||||
Ptr<Feature2D> det = AKAZE::create(AKAZE::DESCRIPTOR_KAZE_UPRIGHT, 0, 3, 0.001f, 4, 4, KAZE::DIFF_PM_G2);
|
||||
vector<KeyPoint> kps;
|
||||
UMat descriptors;
|
||||
|
||||
OCL_TEST_CYCLE() det->detectAndCompute(img, noArray(), kps, descriptors, false);
|
||||
|
||||
EXPECT_GT(kps.size(), 0u);
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // ocl
|
||||
} // opencv_test
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
@@ -0,0 +1,150 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
||||
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// @Authors
|
||||
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||
// Jin Ma, jin@multicorewareinc.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors as is and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
namespace opencv_test {
|
||||
namespace ocl {
|
||||
|
||||
//////////////////// BruteForceMatch /////////////////
|
||||
|
||||
typedef Size_MatType BruteForceMatcherFixture;
|
||||
|
||||
OCL_PERF_TEST_P(BruteForceMatcherFixture, Match, ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), OCL_PERF_ENUM((MatType)CV_32FC1) ) )
|
||||
{
|
||||
const Size_MatType_t params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
vector<DMatch> matches;
|
||||
UMat uquery(srcSize, type), utrain(srcSize, type);
|
||||
|
||||
declare.in(uquery, utrain, WARMUP_RNG);
|
||||
|
||||
BFMatcher matcher(NORM_L2);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
matcher.match(uquery, utrain, matches);
|
||||
|
||||
SANITY_CHECK_MATCHES(matches, 1e-3);
|
||||
}
|
||||
|
||||
OCL_PERF_TEST_P(BruteForceMatcherFixture, KnnMatch, ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), OCL_PERF_ENUM((MatType)CV_32FC1) ) )
|
||||
{
|
||||
const Size_MatType_t params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
vector< vector<DMatch> > matches;
|
||||
UMat uquery(srcSize, type), utrain(srcSize, type);
|
||||
|
||||
declare.in(uquery, utrain, WARMUP_RNG);
|
||||
|
||||
BFMatcher matcher(NORM_L2);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
matcher.knnMatch(uquery, utrain, matches, 2);
|
||||
|
||||
vector<DMatch> & matches0 = matches[0], & matches1 = matches[1];
|
||||
SANITY_CHECK_MATCHES(matches0, 1e-3);
|
||||
SANITY_CHECK_MATCHES(matches1, 1e-3);
|
||||
|
||||
}
|
||||
|
||||
OCL_PERF_TEST_P(BruteForceMatcherFixture, RadiusMatch, ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), OCL_PERF_ENUM((MatType)CV_32FC1) ) )
|
||||
{
|
||||
const Size_MatType_t params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
vector< vector<DMatch> > matches;
|
||||
UMat uquery(srcSize, type), utrain(srcSize, type);
|
||||
|
||||
declare.in(uquery, utrain, WARMUP_RNG);
|
||||
|
||||
BFMatcher matcher(NORM_L2);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
matcher.radiusMatch(uquery, utrain, matches, 2.0f);
|
||||
|
||||
vector<DMatch> & matches0 = matches[0], & matches1 = matches[1];
|
||||
SANITY_CHECK_MATCHES(matches0, 1e-3);
|
||||
SANITY_CHECK_MATCHES(matches1, 1e-3);
|
||||
}
|
||||
|
||||
OCL_PERF_TEST_P(BruteForceMatcherFixture, MatchCrossCheck, ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), OCL_PERF_ENUM((MatType)CV_32FC1) ) )
|
||||
{
|
||||
const Size_MatType_t params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
vector<DMatch> matches;
|
||||
UMat uquery(srcSize, type), utrain(srcSize, type);
|
||||
|
||||
declare.in(uquery, utrain, WARMUP_RNG);
|
||||
|
||||
BFMatcher matcher(NORM_L2, true /*crossCheck*/);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
matcher.match(uquery, utrain, matches);
|
||||
|
||||
SANITY_CHECK_MATCHES(matches, 1e-3);
|
||||
}
|
||||
|
||||
} // ocl
|
||||
} // cvtest
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
@@ -0,0 +1,81 @@
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
#include "../perf_feature2d.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
namespace opencv_test {
|
||||
namespace ocl {
|
||||
|
||||
OCL_PERF_TEST_P(feature2d, detect, testing::Combine(Feature2DType::all(), TEST_IMAGES))
|
||||
{
|
||||
Ptr<Feature2D> detector = getFeature2D(get<0>(GetParam()));
|
||||
std::string filename = getDataPath(get<1>(GetParam()));
|
||||
Mat mimg = imread(filename, IMREAD_GRAYSCALE);
|
||||
|
||||
ASSERT_FALSE(mimg.empty());
|
||||
ASSERT_TRUE(detector);
|
||||
|
||||
UMat img, mask;
|
||||
mimg.copyTo(img);
|
||||
declare.in(img);
|
||||
vector<KeyPoint> points;
|
||||
|
||||
OCL_TEST_CYCLE() detector->detect(img, points, mask);
|
||||
|
||||
EXPECT_GT(points.size(), 20u);
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
OCL_PERF_TEST_P(feature2d, extract, testing::Combine(testing::Values(DETECTORS_EXTRACTORS), TEST_IMAGES))
|
||||
{
|
||||
Ptr<Feature2D> detector = AKAZE::create();
|
||||
Ptr<Feature2D> extractor = getFeature2D(get<0>(GetParam()));
|
||||
std::string filename = getDataPath(get<1>(GetParam()));
|
||||
Mat mimg = imread(filename, IMREAD_GRAYSCALE);
|
||||
|
||||
ASSERT_FALSE(mimg.empty());
|
||||
ASSERT_TRUE(extractor);
|
||||
|
||||
UMat img, mask;
|
||||
mimg.copyTo(img);
|
||||
declare.in(img);
|
||||
vector<KeyPoint> points;
|
||||
detector->detect(img, points, mask);
|
||||
|
||||
EXPECT_GT(points.size(), 20u);
|
||||
|
||||
UMat descriptors;
|
||||
|
||||
OCL_TEST_CYCLE() extractor->compute(img, points, descriptors);
|
||||
|
||||
EXPECT_EQ((size_t)descriptors.rows, points.size());
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
OCL_PERF_TEST_P(feature2d, detectAndExtract, testing::Combine(testing::Values(DETECTORS_EXTRACTORS), TEST_IMAGES))
|
||||
{
|
||||
Ptr<Feature2D> detector = getFeature2D(get<0>(GetParam()));
|
||||
std::string filename = getDataPath(get<1>(GetParam()));
|
||||
Mat mimg = imread(filename, IMREAD_GRAYSCALE);
|
||||
|
||||
ASSERT_FALSE(mimg.empty());
|
||||
ASSERT_TRUE(detector);
|
||||
|
||||
UMat img, mask;
|
||||
mimg.copyTo(img);
|
||||
declare.in(img);
|
||||
vector<KeyPoint> points;
|
||||
UMat descriptors;
|
||||
|
||||
OCL_TEST_CYCLE() detector->detectAndCompute(img, mask, points, descriptors, false);
|
||||
|
||||
EXPECT_GT(points.size(), 20u);
|
||||
EXPECT_EQ((size_t)descriptors.rows, points.size());
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // ocl
|
||||
} // cvtest
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
@@ -0,0 +1,167 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
CV_ENUM(NormType, NORM_L1, NORM_L2, NORM_L2SQR, NORM_HAMMING, NORM_HAMMING2)
|
||||
|
||||
typedef tuple<NormType, MatType, bool> Norm_Destination_CrossCheck_t;
|
||||
typedef perf::TestBaseWithParam<Norm_Destination_CrossCheck_t> Norm_Destination_CrossCheck;
|
||||
|
||||
typedef tuple<NormType, bool> Norm_CrossCheck_t;
|
||||
typedef perf::TestBaseWithParam<Norm_CrossCheck_t> Norm_CrossCheck;
|
||||
|
||||
typedef tuple<MatType, bool> Source_CrossCheck_t;
|
||||
typedef perf::TestBaseWithParam<Source_CrossCheck_t> Source_CrossCheck;
|
||||
|
||||
void generateData( Mat& query, Mat& train, const int sourceType );
|
||||
|
||||
PERF_TEST_P(Norm_Destination_CrossCheck, batchDistance_8U,
|
||||
testing::Combine(testing::Values((int)NORM_L1, (int)NORM_L2SQR),
|
||||
testing::Values(CV_32S, CV_32F),
|
||||
testing::Bool()
|
||||
)
|
||||
)
|
||||
{
|
||||
NormType normType = get<0>(GetParam());
|
||||
int destinationType = get<1>(GetParam());
|
||||
bool isCrossCheck = get<2>(GetParam());
|
||||
int knn = isCrossCheck ? 1 : 0;
|
||||
|
||||
Mat queryDescriptors;
|
||||
Mat trainDescriptors;
|
||||
Mat dist;
|
||||
Mat ndix;
|
||||
|
||||
generateData(queryDescriptors, trainDescriptors, CV_8U);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
batchDistance(queryDescriptors, trainDescriptors, dist, destinationType, (isCrossCheck) ? ndix : noArray(),
|
||||
normType, knn, Mat(), 0, isCrossCheck);
|
||||
}
|
||||
|
||||
SANITY_CHECK(dist);
|
||||
if (isCrossCheck) SANITY_CHECK(ndix);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Norm_CrossCheck, batchDistance_Dest_32S,
|
||||
testing::Combine(testing::Values((int)NORM_HAMMING, (int)NORM_HAMMING2),
|
||||
testing::Bool()
|
||||
)
|
||||
)
|
||||
{
|
||||
NormType normType = get<0>(GetParam());
|
||||
bool isCrossCheck = get<1>(GetParam());
|
||||
int knn = isCrossCheck ? 1 : 0;
|
||||
|
||||
Mat queryDescriptors;
|
||||
Mat trainDescriptors;
|
||||
Mat dist;
|
||||
Mat ndix;
|
||||
|
||||
generateData(queryDescriptors, trainDescriptors, CV_8U);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
batchDistance(queryDescriptors, trainDescriptors, dist, CV_32S, (isCrossCheck) ? ndix : noArray(),
|
||||
normType, knn, Mat(), 0, isCrossCheck);
|
||||
}
|
||||
|
||||
SANITY_CHECK(dist);
|
||||
if (isCrossCheck) SANITY_CHECK(ndix);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Source_CrossCheck, batchDistance_L2,
|
||||
testing::Combine(testing::Values(CV_8U, CV_32F),
|
||||
testing::Bool()
|
||||
)
|
||||
)
|
||||
{
|
||||
int sourceType = get<0>(GetParam());
|
||||
bool isCrossCheck = get<1>(GetParam());
|
||||
int knn = isCrossCheck ? 1 : 0;
|
||||
|
||||
Mat queryDescriptors;
|
||||
Mat trainDescriptors;
|
||||
Mat dist;
|
||||
Mat ndix;
|
||||
|
||||
generateData(queryDescriptors, trainDescriptors, sourceType);
|
||||
|
||||
declare.time(50);
|
||||
TEST_CYCLE()
|
||||
{
|
||||
batchDistance(queryDescriptors, trainDescriptors, dist, CV_32F, (isCrossCheck) ? ndix : noArray(),
|
||||
NORM_L2, knn, Mat(), 0, isCrossCheck);
|
||||
}
|
||||
|
||||
SANITY_CHECK(dist);
|
||||
if (isCrossCheck) SANITY_CHECK(ndix);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Norm_CrossCheck, batchDistance_32F,
|
||||
testing::Combine(testing::Values((int)NORM_L1, (int)NORM_L2SQR),
|
||||
testing::Bool()
|
||||
)
|
||||
)
|
||||
{
|
||||
NormType normType = get<0>(GetParam());
|
||||
bool isCrossCheck = get<1>(GetParam());
|
||||
int knn = isCrossCheck ? 1 : 0;
|
||||
|
||||
Mat queryDescriptors;
|
||||
Mat trainDescriptors;
|
||||
Mat dist;
|
||||
Mat ndix;
|
||||
|
||||
generateData(queryDescriptors, trainDescriptors, CV_32F);
|
||||
declare.time(100);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
batchDistance(queryDescriptors, trainDescriptors, dist, CV_32F, (isCrossCheck) ? ndix : noArray(),
|
||||
normType, knn, Mat(), 0, isCrossCheck);
|
||||
}
|
||||
|
||||
SANITY_CHECK(dist, 1e-4);
|
||||
if (isCrossCheck) SANITY_CHECK(ndix);
|
||||
}
|
||||
|
||||
void generateData( Mat& query, Mat& train, const int sourceType )
|
||||
{
|
||||
const int dim = 500;
|
||||
const int queryDescCount = 300; // must be even number because we split train data in some cases in two
|
||||
const int countFactor = 4; // do not change it
|
||||
RNG& rng = theRNG();
|
||||
|
||||
// Generate query descriptors randomly.
|
||||
// Descriptor vector elements are integer values.
|
||||
Mat buf( queryDescCount, dim, CV_32SC1 );
|
||||
rng.fill( buf, RNG::UNIFORM, Scalar::all(0), Scalar(3) );
|
||||
buf.convertTo( query, sourceType );
|
||||
|
||||
// Generate train descriptors as follows:
|
||||
// copy each query descriptor to train set countFactor times
|
||||
// and perturb some one element of the copied descriptors in
|
||||
// in ascending order. General boundaries of the perturbation
|
||||
// are (0.f, 1.f).
|
||||
train.create( query.rows*countFactor, query.cols, sourceType );
|
||||
float step = (sourceType == CV_8U ? 256.f : 1.f) / countFactor;
|
||||
for( int qIdx = 0; qIdx < query.rows; qIdx++ )
|
||||
{
|
||||
Mat queryDescriptor = query.row(qIdx);
|
||||
for( int c = 0; c < countFactor; c++ )
|
||||
{
|
||||
int tIdx = qIdx * countFactor + c;
|
||||
Mat trainDescriptor = train.row(tIdx);
|
||||
queryDescriptor.copyTo( trainDescriptor );
|
||||
int elem = rng(dim);
|
||||
float diff = rng.uniform( step*c, step*(c+1) );
|
||||
trainDescriptor.col(elem) += diff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,43 @@
|
||||
#include "perf_precomp.hpp"
|
||||
#include "perf_feature2d.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
typedef tuple<int, int, bool, string> Fast_Params_t;
|
||||
typedef perf::TestBaseWithParam<Fast_Params_t> Fast_Params;
|
||||
|
||||
PERF_TEST_P(Fast_Params, detect,
|
||||
testing::Combine(
|
||||
testing::Values(20,30,100), // threshold
|
||||
testing::Values(
|
||||
// (int)FastFeatureDetector::TYPE_5_8,
|
||||
// (int)FastFeatureDetector::TYPE_7_12,
|
||||
(int)FastFeatureDetector::TYPE_9_16 // detector_type
|
||||
),
|
||||
testing::Bool(), // nonmaxSuppression
|
||||
testing::Values("cv/inpaint/orig.png",
|
||||
"cv/cameracalibration/chess9.png")
|
||||
))
|
||||
{
|
||||
int threshold_p = get<0>(GetParam());
|
||||
int type_p = get<1>(GetParam());
|
||||
bool nonmaxSuppression_p = get<2>(GetParam());
|
||||
string filename = getDataPath(get<3>(GetParam()));
|
||||
|
||||
Mat img = imread(filename, IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty()) << "Failed to load image: " << filename;
|
||||
|
||||
vector<KeyPoint> keypoints;
|
||||
|
||||
declare.in(img);
|
||||
TEST_CYCLE()
|
||||
{
|
||||
FAST(img, keypoints, threshold_p, nonmaxSuppression_p, (FastFeatureDetector::DetectorType)type_p);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace opencv_test
|
||||
@@ -0,0 +1,72 @@
|
||||
#include "perf_feature2d.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
PERF_TEST_P(feature2d, detect, testing::Combine(Feature2DType::all(), TEST_IMAGES))
|
||||
{
|
||||
Ptr<Feature2D> detector = getFeature2D(get<0>(GetParam()));
|
||||
std::string filename = getDataPath(get<1>(GetParam()));
|
||||
Mat img = imread(filename, IMREAD_GRAYSCALE);
|
||||
|
||||
ASSERT_FALSE(img.empty());
|
||||
ASSERT_TRUE(detector);
|
||||
|
||||
declare.in(img);
|
||||
Mat mask;
|
||||
vector<KeyPoint> points;
|
||||
|
||||
TEST_CYCLE() detector->detect(img, points, mask);
|
||||
|
||||
EXPECT_GT(points.size(), 20u);
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P(feature2d, extract, testing::Combine(testing::Values(DETECTORS_EXTRACTORS), TEST_IMAGES))
|
||||
{
|
||||
Ptr<Feature2D> detector = AKAZE::create();
|
||||
Ptr<Feature2D> extractor = getFeature2D(get<0>(GetParam()));
|
||||
std::string filename = getDataPath(get<1>(GetParam()));
|
||||
Mat img = imread(filename, IMREAD_GRAYSCALE);
|
||||
|
||||
ASSERT_FALSE(img.empty());
|
||||
ASSERT_TRUE(extractor);
|
||||
|
||||
declare.in(img);
|
||||
Mat mask;
|
||||
vector<KeyPoint> points;
|
||||
detector->detect(img, points, mask);
|
||||
|
||||
EXPECT_GT(points.size(), 20u);
|
||||
|
||||
Mat descriptors;
|
||||
|
||||
TEST_CYCLE() extractor->compute(img, points, descriptors);
|
||||
|
||||
EXPECT_EQ((size_t)descriptors.rows, points.size());
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P(feature2d, detectAndExtract, testing::Combine(testing::Values(DETECTORS_EXTRACTORS), TEST_IMAGES))
|
||||
{
|
||||
Ptr<Feature2D> detector = getFeature2D(get<0>(GetParam()));
|
||||
std::string filename = getDataPath(get<1>(GetParam()));
|
||||
Mat img = imread(filename, IMREAD_GRAYSCALE);
|
||||
|
||||
ASSERT_FALSE(img.empty());
|
||||
ASSERT_TRUE(detector);
|
||||
|
||||
declare.in(img);
|
||||
Mat mask;
|
||||
vector<KeyPoint> points;
|
||||
Mat descriptors;
|
||||
|
||||
TEST_CYCLE() detector->detectAndCompute(img, mask, points, descriptors, false);
|
||||
|
||||
EXPECT_GT(points.size(), 20u);
|
||||
EXPECT_EQ((size_t)descriptors.rows, points.size());
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,90 @@
|
||||
#ifndef __OPENCV_PERF_FEATURE2D_HPP__
|
||||
#define __OPENCV_PERF_FEATURE2D_HPP__
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
|
||||
/* configuration for tests of detectors/descriptors. shared between ocl and cpu tests. */
|
||||
|
||||
// detectors/descriptors configurations to test
|
||||
#define DETECTORS_ONLY \
|
||||
FAST_DEFAULT, FAST_20_TRUE_TYPE5_8, FAST_20_TRUE_TYPE7_12, FAST_20_TRUE_TYPE9_16, \
|
||||
FAST_20_FALSE_TYPE5_8, FAST_20_FALSE_TYPE7_12, FAST_20_FALSE_TYPE9_16, \
|
||||
\
|
||||
AGAST_DEFAULT, AGAST_5_8, AGAST_7_12d, AGAST_7_12s, AGAST_OAST_9_16, \
|
||||
\
|
||||
MSER_DEFAULT
|
||||
|
||||
#define DETECTORS_EXTRACTORS \
|
||||
ORB_DEFAULT, ORB_1500_13_1, \
|
||||
AKAZE_DEFAULT, AKAZE_DESCRIPTOR_KAZE, \
|
||||
BRISK_DEFAULT, \
|
||||
KAZE_DEFAULT, \
|
||||
SIFT_DEFAULT
|
||||
|
||||
#define CV_ENUM_EXPAND(name, ...) CV_ENUM(name, __VA_ARGS__)
|
||||
|
||||
enum Feature2DVals { DETECTORS_ONLY, DETECTORS_EXTRACTORS };
|
||||
CV_ENUM_EXPAND(Feature2DType, DETECTORS_ONLY, DETECTORS_EXTRACTORS)
|
||||
|
||||
typedef tuple<Feature2DType, string> Feature2DType_String_t;
|
||||
typedef perf::TestBaseWithParam<Feature2DType_String_t> feature2d;
|
||||
|
||||
#define TEST_IMAGES testing::Values(\
|
||||
"cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
|
||||
"stitching/a3.png", \
|
||||
"stitching/s2.jpg")
|
||||
|
||||
static inline Ptr<Feature2D> getFeature2D(Feature2DType type)
|
||||
{
|
||||
switch(type) {
|
||||
case ORB_DEFAULT:
|
||||
return ORB::create();
|
||||
case ORB_1500_13_1:
|
||||
return ORB::create(1500, 1.3f, 1);
|
||||
case FAST_DEFAULT:
|
||||
return FastFeatureDetector::create();
|
||||
case FAST_20_TRUE_TYPE5_8:
|
||||
return FastFeatureDetector::create(20, true, FastFeatureDetector::TYPE_5_8);
|
||||
case FAST_20_TRUE_TYPE7_12:
|
||||
return FastFeatureDetector::create(20, true, FastFeatureDetector::TYPE_7_12);
|
||||
case FAST_20_TRUE_TYPE9_16:
|
||||
return FastFeatureDetector::create(20, true, FastFeatureDetector::TYPE_9_16);
|
||||
case FAST_20_FALSE_TYPE5_8:
|
||||
return FastFeatureDetector::create(20, false, FastFeatureDetector::TYPE_5_8);
|
||||
case FAST_20_FALSE_TYPE7_12:
|
||||
return FastFeatureDetector::create(20, false, FastFeatureDetector::TYPE_7_12);
|
||||
case FAST_20_FALSE_TYPE9_16:
|
||||
return FastFeatureDetector::create(20, false, FastFeatureDetector::TYPE_9_16);
|
||||
case AGAST_DEFAULT:
|
||||
return AgastFeatureDetector::create();
|
||||
case AGAST_5_8:
|
||||
return AgastFeatureDetector::create(70, true, AgastFeatureDetector::AGAST_5_8);
|
||||
case AGAST_7_12d:
|
||||
return AgastFeatureDetector::create(70, true, AgastFeatureDetector::AGAST_7_12d);
|
||||
case AGAST_7_12s:
|
||||
return AgastFeatureDetector::create(70, true, AgastFeatureDetector::AGAST_7_12s);
|
||||
case AGAST_OAST_9_16:
|
||||
return AgastFeatureDetector::create(70, true, AgastFeatureDetector::OAST_9_16);
|
||||
case AKAZE_DEFAULT:
|
||||
return AKAZE::create();
|
||||
case AKAZE_DESCRIPTOR_KAZE:
|
||||
return AKAZE::create(AKAZE::DESCRIPTOR_KAZE);
|
||||
case BRISK_DEFAULT:
|
||||
return BRISK::create();
|
||||
case KAZE_DEFAULT:
|
||||
return KAZE::create();
|
||||
case MSER_DEFAULT:
|
||||
return MSER::create();
|
||||
case SIFT_DEFAULT:
|
||||
return SIFT::create();
|
||||
default:
|
||||
return Ptr<Feature2D>();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // __OPENCV_PERF_FEATURE2D_HPP__
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
#if defined(HAVE_HPX)
|
||||
#include <hpx/hpx_main.hpp>
|
||||
#endif
|
||||
|
||||
CV_PERF_TEST_MAIN(features2d)
|
||||
@@ -0,0 +1,91 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2026, Advanced Micro Devices, Inc., all rights reserved.
|
||||
|
||||
// Brute-force descriptor matching perf tests. These exercise the core distance
|
||||
// kernels (hal::normL2Sqr_ / normL1_ / normHamming via cv::batchDistance) that
|
||||
// back BFMatcher, which is how float descriptors (SIFT 128-d, SURF 64-d) and
|
||||
// binary descriptors (ORB 32-byte) are matched.
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
// (descriptor dimension, query/train descriptor count)
|
||||
typedef tuple<int, int> Dim_Count_t;
|
||||
typedef TestBaseWithParam<Dim_Count_t> DescriptorMatcherFixture;
|
||||
|
||||
// Float descriptors matched with L2 (SIFT=128, SURF=64) — uses hal::normL2Sqr_.
|
||||
PERF_TEST_P(DescriptorMatcherFixture, bfmatch_knn_L2_float,
|
||||
testing::Combine(
|
||||
testing::Values(64, 128), // SURF, SIFT descriptor sizes
|
||||
testing::Values(512, 1000)
|
||||
))
|
||||
{
|
||||
const int dim = get<0>(GetParam());
|
||||
const int count = get<1>(GetParam());
|
||||
|
||||
Mat query(count, dim, CV_32F);
|
||||
Mat train(count, dim, CV_32F);
|
||||
declare.in(query, train, WARMUP_RNG);
|
||||
declare.time(60);
|
||||
|
||||
BFMatcher matcher(NORM_L2, false);
|
||||
std::vector<std::vector<DMatch> > matches;
|
||||
|
||||
TEST_CYCLE() matcher.knnMatch(query, train, matches, 2);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
// Float descriptors matched with L1 — uses hal::normL1_.
|
||||
PERF_TEST_P(DescriptorMatcherFixture, bfmatch_knn_L1_float,
|
||||
testing::Combine(
|
||||
testing::Values(64, 128),
|
||||
testing::Values(512, 1000)
|
||||
))
|
||||
{
|
||||
const int dim = get<0>(GetParam());
|
||||
const int count = get<1>(GetParam());
|
||||
|
||||
Mat query(count, dim, CV_32F);
|
||||
Mat train(count, dim, CV_32F);
|
||||
declare.in(query, train, WARMUP_RNG);
|
||||
declare.time(60);
|
||||
|
||||
BFMatcher matcher(NORM_L1, false);
|
||||
std::vector<std::vector<DMatch> > matches;
|
||||
|
||||
TEST_CYCLE() matcher.knnMatch(query, train, matches, 2);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
// Binary descriptors matched with Hamming (ORB/BRISK=32 bytes) — uses hal::normHamming.
|
||||
PERF_TEST_P(DescriptorMatcherFixture, bfmatch_knn_Hamming_binary,
|
||||
testing::Combine(
|
||||
testing::Values(32, 64), // ORB (32), BRISK/FREAK (64) byte sizes
|
||||
testing::Values(512, 1000)
|
||||
))
|
||||
{
|
||||
const int bytes = get<0>(GetParam());
|
||||
const int count = get<1>(GetParam());
|
||||
|
||||
Mat query(count, bytes, CV_8U);
|
||||
Mat train(count, bytes, CV_8U);
|
||||
declare.in(query, train, WARMUP_RNG);
|
||||
declare.time(60);
|
||||
|
||||
BFMatcher matcher(NORM_HAMMING, false);
|
||||
std::vector<std::vector<DMatch> > matches;
|
||||
|
||||
TEST_CYCLE() matcher.knnMatch(query, train, matches, 2);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef __OPENCV_PERF_PRECOMP_HPP__
|
||||
#define __OPENCV_PERF_PRECOMP_HPP__
|
||||
|
||||
#include "opencv2/ts.hpp"
|
||||
#include "opencv2/features2d.hpp"
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user