2017-08-17 00:46:11 +08:00
|
|
|
// 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 "../test_precomp.hpp"
|
|
|
|
#include "cvconfig.h"
|
|
|
|
#include "opencv2/ts/ocl_test.hpp"
|
2024-04-17 19:19:05 +08:00
|
|
|
#include <functional>
|
2017-08-17 00:46:11 +08:00
|
|
|
|
|
|
|
#ifdef HAVE_OPENCL
|
|
|
|
|
2017-11-05 21:48:40 +08:00
|
|
|
namespace opencv_test {
|
2017-08-17 00:46:11 +08:00
|
|
|
namespace ocl {
|
|
|
|
|
|
|
|
#define TEST_IMAGES testing::Values(\
|
|
|
|
"detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
|
|
|
|
"../stitching/a3.png", \
|
|
|
|
"../stitching/s2.jpg")
|
|
|
|
|
2024-04-17 19:19:05 +08:00
|
|
|
PARAM_TEST_CASE(Feature2DFixture, std::function<Ptr<Feature2D>()>, std::string)
|
2017-08-17 00:46:11 +08:00
|
|
|
{
|
|
|
|
std::string filename;
|
|
|
|
Mat image, descriptors;
|
|
|
|
vector<KeyPoint> keypoints;
|
|
|
|
UMat uimage, udescriptors;
|
|
|
|
vector<KeyPoint> ukeypoints;
|
|
|
|
Ptr<Feature2D> feature;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2024-04-17 19:19:05 +08:00
|
|
|
feature = GET_PARAM(0)();
|
2017-08-17 00:46:11 +08:00
|
|
|
filename = GET_PARAM(1);
|
|
|
|
|
|
|
|
image = readImage(filename);
|
|
|
|
|
|
|
|
ASSERT_FALSE(image.empty());
|
|
|
|
|
|
|
|
image.copyTo(uimage);
|
|
|
|
|
|
|
|
OCL_OFF(feature->detect(image, keypoints));
|
|
|
|
OCL_ON(feature->detect(uimage, ukeypoints));
|
|
|
|
// note: we use keypoints from CPU for GPU too, to test descriptors separately
|
|
|
|
OCL_OFF(feature->compute(image, keypoints, descriptors));
|
|
|
|
OCL_ON(feature->compute(uimage, keypoints, udescriptors));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
OCL_TEST_P(Feature2DFixture, KeypointsSame)
|
|
|
|
{
|
|
|
|
EXPECT_EQ(keypoints.size(), ukeypoints.size());
|
|
|
|
|
|
|
|
for (size_t i = 0; i < keypoints.size(); ++i)
|
|
|
|
{
|
|
|
|
EXPECT_GE(KeyPoint::overlap(keypoints[i], ukeypoints[i]), 0.95);
|
2020-05-14 04:44:14 +08:00
|
|
|
EXPECT_NEAR(keypoints[i].angle, ukeypoints[i].angle, 0.05);
|
2017-08-17 00:46:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OCL_TEST_P(Feature2DFixture, DescriptorsSame)
|
|
|
|
{
|
|
|
|
EXPECT_MAT_NEAR(descriptors, udescriptors, 0.001);
|
|
|
|
}
|
|
|
|
|
|
|
|
OCL_INSTANTIATE_TEST_CASE_P(AKAZE, Feature2DFixture,
|
2024-04-17 19:19:05 +08:00
|
|
|
testing::Combine(testing::Values([]() { return AKAZE::create(); }), TEST_IMAGES));
|
2017-08-17 00:46:11 +08:00
|
|
|
|
|
|
|
OCL_INSTANTIATE_TEST_CASE_P(AKAZE_DESCRIPTOR_KAZE, Feature2DFixture,
|
2024-04-17 19:19:05 +08:00
|
|
|
testing::Combine(testing::Values([]() { return AKAZE::create(AKAZE::DESCRIPTOR_KAZE); }), TEST_IMAGES));
|
2017-08-17 00:46:11 +08:00
|
|
|
|
|
|
|
}//ocl
|
|
|
|
}//cvtest
|
|
|
|
|
|
|
|
#endif //HAVE_OPENCL
|