1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install,
7 // copy or use the software.
11 // For Open Source Computer Vision Library
13 // Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
14 // Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
15 // Third party copyrights are property of their respective owners.
18 // Peng Xiao, pengxiao@multicorewareinc.com
19 // Redistribution and use in source and binary forms, with or without modification,
20 // are permitted provided that the following conditions are met:
22 // * Redistribution's of source code must retain the above copyright notice,
23 // this list of conditions and the following disclaimer.
25 // * Redistribution's in binary form must reproduce the above copyright notice,
26 // this list of conditions and the following disclaimer in the documentation
27 // and/or other oclMaterials provided with the distribution.
29 // * The name of the copyright holders may not be used to endorse or promote products
30 // derived from this software without specific prior written permission.
32 // This software is provided by the copyright holders and contributors as is and
33 // any express or implied warranties, including, but not limited to, the implied
34 // warranties of merchantability and fitness for a particular purpose are disclaimed.
35 // In no event shall the Intel Corporation or contributors be liable for any direct,
36 // indirect, incidental, special, exemplary, or consequential damages
37 // (including, but not limited to, procurement of substitute goods or services;
38 // loss of use, data, or profits; or business interruption) however caused
39 // and on any theory of liability, whether in contract, strict liability,
40 // or tort (including negligence or otherwise) arising in any way out of
41 // the use of this software, even if advised of the possibility of such damage.
46 #include "test_precomp.hpp"
49 ////////////////////////////////////////////////////////////////////////////////
51 #define ALL_TEMPLATE_METHODS testing::Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_CCORR), TemplateMethod(cv::TM_CCOEFF), TemplateMethod(cv::TM_SQDIFF_NORMED), TemplateMethod(cv::TM_CCORR_NORMED), TemplateMethod(cv::TM_CCOEFF_NORMED))
53 IMPLEMENT_PARAM_CLASS(TemplateSize, cv::Size);
55 #define MTEMP_SIZES testing::Values(cv::Size(128, 256), cv::Size(1024, 768))
57 PARAM_TEST_CASE(MatchTemplate8U, cv::Size, TemplateSize, Channels, TemplateMethod)
67 templ_size = GET_PARAM(1);
69 method = GET_PARAM(3);
73 OCL_TEST_P(MatchTemplate8U, Accuracy)
75 cv::Mat image = randomMat(size, CV_MAKETYPE(CV_8U, cn), 0, 255);
76 cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_8U, cn), 0, 255);
78 cv::ocl::oclMat dst, ocl_image(image), ocl_templ(templ);
79 cv::ocl::matchTemplate(ocl_image, ocl_templ, dst, method);
82 cv::matchTemplate(image, templ, dst_gold, method);
85 dst.download(mat_dst);
87 EXPECT_MAT_NEAR(dst_gold, mat_dst, templ_size.area() * 1e-1);
90 PARAM_TEST_CASE(MatchTemplate32F, cv::Size, TemplateSize, Channels, TemplateMethod)
100 templ_size = GET_PARAM(1);
102 method = GET_PARAM(3);
106 OCL_TEST_P(MatchTemplate32F, Accuracy)
108 cv::Mat image = randomMat(size, CV_MAKETYPE(CV_32F, cn), 0, 255);
109 cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_32F, cn), 0, 255);
111 cv::ocl::oclMat dst, ocl_image(image), ocl_templ(templ);
112 cv::ocl::matchTemplate(ocl_image, ocl_templ, dst, method);
115 cv::matchTemplate(image, templ, dst_gold, method);
118 dst.download(mat_dst);
120 EXPECT_MAT_NEAR(dst_gold, mat_dst, templ_size.area() * 1e-1);
123 INSTANTIATE_TEST_CASE_P(OCL_ImgProc, MatchTemplate8U,
126 testing::Values(TemplateSize(cv::Size(5, 5)), TemplateSize(cv::Size(16, 16)), TemplateSize(cv::Size(30, 30))),
127 testing::Values(Channels(1), Channels(3), Channels(4)),
132 INSTANTIATE_TEST_CASE_P(OCL_ImgProc, MatchTemplate32F, testing::Combine(
134 testing::Values(TemplateSize(cv::Size(5, 5)), TemplateSize(cv::Size(16, 16)), TemplateSize(cv::Size(30, 30))),
135 testing::Values(Channels(1), Channels(3), Channels(4)),
136 testing::Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_CCORR))));