Path: blob/master/modules/features2d/perf/opencl/perf_brute_force_matcher.cpp
16358 views
/*M///////////////////////////////////////////////////////////////////////////////////////1//2// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.3//4// By downloading, copying, installing or using the software you agree to this license.5// If you do not agree to this license, do not download, install,6// copy or use the software.7//8//9// License Agreement10// For Open Source Computer Vision Library11//12// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.13// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.14// Third party copyrights are property of their respective owners.15//16// @Authors17// Fangfang Bai, [email protected]18// Jin Ma, [email protected]19//20// Redistribution and use in source and binary forms, with or without modification,21// are permitted provided that the following conditions are met:22//23// * Redistribution's of source code must retain the above copyright notice,24// this list of conditions and the following disclaimer.25//26// * Redistribution's in binary form must reproduce the above copyright notice,27// this list of conditions and the following disclaimer in the documentation28// and/or other materials provided with the distribution.29//30// * The name of the copyright holders may not be used to endorse or promote products31// derived from this software without specific prior written permission.32//33// This software is provided by the copyright holders and contributors as is and34// any express or implied warranties, including, but not limited to, the implied35// warranties of merchantability and fitness for a particular purpose are disclaimed.36// In no event shall the Intel Corporation or contributors be liable for any direct,37// indirect, incidental, special, exemplary, or consequential damages38// (including, but not limited to, procurement of substitute goods or services;39// loss of use, data, or profits; or business interruption) however caused40// and on any theory of liability, whether in contract, strict liability,41// or tort (including negligence or otherwise) arising in any way out of42// the use of this software, even if advised of the possibility of such damage.43//44//M*/45#include "../perf_precomp.hpp"46#include "opencv2/ts/ocl_perf.hpp"4748#ifdef HAVE_OPENCL4950namespace opencv_test {51namespace ocl {5253//////////////////// BruteForceMatch /////////////////5455typedef Size_MatType BruteForceMatcherFixture;5657OCL_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) ) )58{59const Size_MatType_t params = GetParam();60const Size srcSize = get<0>(params);61const int type = get<1>(params);6263checkDeviceMaxMemoryAllocSize(srcSize, type);6465vector<DMatch> matches;66UMat uquery(srcSize, type), utrain(srcSize, type);6768declare.in(uquery, utrain, WARMUP_RNG);6970BFMatcher matcher(NORM_L2);7172OCL_TEST_CYCLE()73matcher.match(uquery, utrain, matches);7475SANITY_CHECK_MATCHES(matches, 1e-3);76}7778OCL_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) ) )79{80const Size_MatType_t params = GetParam();81const Size srcSize = get<0>(params);82const int type = get<1>(params);8384checkDeviceMaxMemoryAllocSize(srcSize, type);8586vector< vector<DMatch> > matches;87UMat uquery(srcSize, type), utrain(srcSize, type);8889declare.in(uquery, utrain, WARMUP_RNG);9091BFMatcher matcher(NORM_L2);9293OCL_TEST_CYCLE()94matcher.knnMatch(uquery, utrain, matches, 2);9596vector<DMatch> & matches0 = matches[0], & matches1 = matches[1];97SANITY_CHECK_MATCHES(matches0, 1e-3);98SANITY_CHECK_MATCHES(matches1, 1e-3);99100}101102OCL_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) ) )103{104const Size_MatType_t params = GetParam();105const Size srcSize = get<0>(params);106const int type = get<1>(params);107108checkDeviceMaxMemoryAllocSize(srcSize, type);109110vector< vector<DMatch> > matches;111UMat uquery(srcSize, type), utrain(srcSize, type);112113declare.in(uquery, utrain, WARMUP_RNG);114115BFMatcher matcher(NORM_L2);116117OCL_TEST_CYCLE()118matcher.radiusMatch(uquery, utrain, matches, 2.0f);119120vector<DMatch> & matches0 = matches[0], & matches1 = matches[1];121SANITY_CHECK_MATCHES(matches0, 1e-3);122SANITY_CHECK_MATCHES(matches1, 1e-3);123}124125} // ocl126} // cvtest127128#endif // HAVE_OPENCL129130131