Path: blob/master/modules/features2d/test/ocl/test_feature2d.cpp
16358 views
// This file is part of OpenCV project.1// It is subject to the license terms in the LICENSE file found in the top-level directory2// of this distribution and at http://opencv.org/license.html34#include "../test_precomp.hpp"5#include "cvconfig.h"6#include "opencv2/ts/ocl_test.hpp"78#ifdef HAVE_OPENCL910namespace opencv_test {11namespace ocl {1213#define TEST_IMAGES testing::Values(\14"detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\15"../stitching/a3.png", \16"../stitching/s2.jpg")1718PARAM_TEST_CASE(Feature2DFixture, Ptr<Feature2D>, std::string)19{20std::string filename;21Mat image, descriptors;22vector<KeyPoint> keypoints;23UMat uimage, udescriptors;24vector<KeyPoint> ukeypoints;25Ptr<Feature2D> feature;2627virtual void SetUp()28{29feature = GET_PARAM(0);30filename = GET_PARAM(1);3132image = readImage(filename);3334ASSERT_FALSE(image.empty());3536image.copyTo(uimage);3738OCL_OFF(feature->detect(image, keypoints));39OCL_ON(feature->detect(uimage, ukeypoints));40// note: we use keypoints from CPU for GPU too, to test descriptors separately41OCL_OFF(feature->compute(image, keypoints, descriptors));42OCL_ON(feature->compute(uimage, keypoints, udescriptors));43}44};4546OCL_TEST_P(Feature2DFixture, KeypointsSame)47{48EXPECT_EQ(keypoints.size(), ukeypoints.size());4950for (size_t i = 0; i < keypoints.size(); ++i)51{52EXPECT_GE(KeyPoint::overlap(keypoints[i], ukeypoints[i]), 0.95);53EXPECT_NEAR(keypoints[i].angle, ukeypoints[i].angle, 0.001);54}55}5657OCL_TEST_P(Feature2DFixture, DescriptorsSame)58{59EXPECT_MAT_NEAR(descriptors, udescriptors, 0.001);60}6162OCL_INSTANTIATE_TEST_CASE_P(AKAZE, Feature2DFixture,63testing::Combine(testing::Values(AKAZE::create()), TEST_IMAGES));6465OCL_INSTANTIATE_TEST_CASE_P(AKAZE_DESCRIPTOR_KAZE, Feature2DFixture,66testing::Combine(testing::Values(AKAZE::create(AKAZE::DESCRIPTOR_KAZE)), TEST_IMAGES));6768}//ocl69}//cvtest7071#endif //HAVE_OPENCL727374