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, Institute Of Software Chinese Academy Of Science, all rights reserved.
14 // Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
15 // Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
16 // Third party copyrights are property of their respective owners.
18 // Redistribution and use in source and binary forms, with or without modification,
19 // are permitted provided that the following conditions are met:
21 // * Redistribution's of source code must retain the above copyright notice,
22 // this list of conditions and the following disclaimer.
24 // * Redistribution's in binary form must reproduce the above copyright notice,
25 // this list of conditions and the following disclaimer in the documentation
26 // and/or other materials provided with the distribution.
28 // * The name of the copyright holders may not be used to endorse or promote products
29 // derived from this software without specific prior written permission.
31 // This software is provided by the copyright holders and contributors "as is" and
32 // any express or implied warranties, including, but not limited to, the implied
33 // warranties of merchantability and fitness for a particular purpose are disclaimed.
34 // In no event shall the Intel Corporation or contributors be liable for any direct,
35 // indirect, incidental, special, exemplary, or consequential damages
36 // (including, but not limited to, procurement of substitute goods or services;
37 // loss of use, data, or profits; or business interruption) however caused
38 // and on any theory of liability, whether in contract, strict liability,
39 // or tort (including negligence or otherwise) arising in any way out of
40 // the use of this software, even if advised of the possibility of such damage.
44 #include "test_precomp.hpp"
45 #include "opencv2/ts/ocl_test.hpp"
52 ////////////////////////////////////////// boxFilter ///////////////////////////////////////////////////////
54 PARAM_TEST_CASE(BoxFilterBase, MatDepth, Channels, BorderType, bool, bool)
56 static const int kernelMinSize = 2;
57 static const int kernelMaxSize = 10;
59 int depth, cn, borderType;
62 bool normalize, useRoi;
64 TEST_DECLARE_INPUT_PARAMETER(src);
65 TEST_DECLARE_OUTPUT_PARAMETER(dst);
71 borderType = GET_PARAM(2); // only not isolated border tested, because CPU module doesn't support isolated border case.
72 normalize = GET_PARAM(3);
73 useRoi = GET_PARAM(4);
78 int type = CV_MAKE_TYPE(depth, cn);
79 ksize = randomSize(kernelMinSize, kernelMaxSize);
81 Size roiSize = randomSize(ksize.width, MAX_VALUE, ksize.height, MAX_VALUE);
82 Border srcBorder = randomBorder(0, useRoi ? MAX_VALUE : 0);
83 randomSubMat(src, src_roi, roiSize, srcBorder, type, -MAX_VALUE, MAX_VALUE);
85 Border dstBorder = randomBorder(0, useRoi ? MAX_VALUE : 0);
86 randomSubMat(dst, dst_roi, roiSize, dstBorder, type, -MAX_VALUE, MAX_VALUE);
88 anchor.x = randomInt(-1, ksize.width);
89 anchor.y = randomInt(-1, ksize.height);
91 UMAT_UPLOAD_INPUT_PARAMETER(src);
92 UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
95 void Near(double threshold = 0.0)
97 OCL_EXPECT_MATS_NEAR(dst, threshold);
101 typedef BoxFilterBase BoxFilter;
103 OCL_TEST_P(BoxFilter, Mat)
105 for (int j = 0; j < test_loop_times; j++)
109 OCL_OFF(cv::boxFilter(src_roi, dst_roi, -1, ksize, anchor, normalize, borderType));
110 OCL_ON(cv::boxFilter(usrc_roi, udst_roi, -1, ksize, anchor, normalize, borderType));
112 Near(depth <= CV_32S ? 1 : 3e-3);
116 typedef BoxFilterBase SqrBoxFilter;
118 OCL_TEST_P(SqrBoxFilter, Mat)
120 for (int j = 0; j < test_loop_times; j++)
124 int ddepth = depth == CV_8U ? CV_32S : CV_64F;
126 OCL_OFF(cv::sqrBoxFilter(src_roi, dst_roi, ddepth, ksize, anchor, normalize, borderType));
127 OCL_ON(cv::sqrBoxFilter(usrc_roi, udst_roi, ddepth, ksize, anchor, normalize, borderType));
129 Near(depth <= CV_32S ? 1 : 7e-2);
133 OCL_INSTANTIATE_TEST_CASE_P(ImageProc, BoxFilter,
135 Values(CV_8U, CV_16U, CV_16S, CV_32S, CV_32F),
137 Values((BorderType)BORDER_CONSTANT,
138 (BorderType)BORDER_REPLICATE,
139 (BorderType)BORDER_REFLECT,
140 (BorderType)BORDER_REFLECT_101),
146 OCL_INSTANTIATE_TEST_CASE_P(ImageProc, SqrBoxFilter,
148 Values(CV_8U, CV_16U, CV_16S, CV_32F, CV_64F),
150 Values((BorderType)BORDER_CONSTANT,
151 (BorderType)BORDER_REPLICATE,
152 (BorderType)BORDER_REFLECT,
153 (BorderType)BORDER_REFLECT_101),
160 } } // namespace cvtest::ocl
162 #endif // HAVE_OPENCL