1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
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.
8 //
9 //
10 //                           License Agreement
11 //                For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15 // Third party copyrights are property of their respective owners.
16 //
17 // Redistribution and use in source and binary forms, with or without modification,
18 // are permitted provided that the following conditions are met:
19 //
20 //   * Redistribution's of source code must retain the above copyright notice,
21 //     this list of conditions and the following disclaimer.
22 //
23 //   * Redistribution's in binary form must reproduce the above copyright notice,
24 //     this list of conditions and the following disclaimer in the documentation
25 //     and/or other materials provided with the distribution.
26 //
27 //   * The name of the copyright holders may not be used to endorse or promote products
28 //     derived from this software without specific prior written permission.
29 //
30 // This software is provided by the copyright holders and contributors "as is" and
31 // any express or implied warranties, including, but not limited to, the implied
32 // warranties of merchantability and fitness for a particular purpose are disclaimed.
33 // In no event shall the Intel Corporation or contributors be liable for any direct,
34 // indirect, incidental, special, exemplary, or consequential damages
35 // (including, but not limited to, procurement of substitute goods or services;
36 // loss of use, data, or profits; or business interruption) however caused
37 // and on any theory of liability, whether in contract, strict liability,
38 // or tort (including negligence or otherwise) arising in any way out of
39 // the use of this software, even if advised of the possibility of such damage.
40 //
41 //M*/
42 
43 #include "test_precomp.hpp"
44 
45 #ifdef HAVE_CUDA
46 
47 using namespace cvtest;
48 
49 ////////////////////////////////////////////////////////
50 // pyrDown
51 
PARAM_TEST_CASE(PyrDown,cv::cuda::DeviceInfo,cv::Size,MatType,UseRoi)52 PARAM_TEST_CASE(PyrDown, cv::cuda::DeviceInfo, cv::Size, MatType, UseRoi)
53 {
54     cv::cuda::DeviceInfo devInfo;
55     cv::Size size;
56     int type;
57     bool useRoi;
58 
59     virtual void SetUp()
60     {
61         devInfo = GET_PARAM(0);
62         size = GET_PARAM(1);
63         type = GET_PARAM(2);
64         useRoi = GET_PARAM(3);
65 
66         cv::cuda::setDevice(devInfo.deviceID());
67     }
68 };
69 
CUDA_TEST_P(PyrDown,Accuracy)70 CUDA_TEST_P(PyrDown, Accuracy)
71 {
72     cv::Mat src = randomMat(size, type);
73 
74     cv::cuda::GpuMat dst = createMat(cv::Size((size.width + 1) / 2, (size.height + 1) / 2), type, useRoi);
75     cv::cuda::pyrDown(loadMat(src, useRoi), dst);
76 
77     cv::Mat dst_gold;
78     cv::pyrDown(src, dst_gold);
79 
80     EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-4 : 1.0);
81 }
82 
83 INSTANTIATE_TEST_CASE_P(CUDA_Warping, PyrDown, testing::Combine(
84     ALL_DEVICES,
85     DIFFERENT_SIZES,
86     testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),
87     WHOLE_SUBMAT));
88 
89 ////////////////////////////////////////////////////////
90 // pyrUp
91 
PARAM_TEST_CASE(PyrUp,cv::cuda::DeviceInfo,cv::Size,MatType,UseRoi)92 PARAM_TEST_CASE(PyrUp, cv::cuda::DeviceInfo, cv::Size, MatType, UseRoi)
93 {
94     cv::cuda::DeviceInfo devInfo;
95     cv::Size size;
96     int type;
97     bool useRoi;
98 
99     virtual void SetUp()
100     {
101         devInfo = GET_PARAM(0);
102         size = GET_PARAM(1);
103         type = GET_PARAM(2);
104         useRoi = GET_PARAM(3);
105 
106         cv::cuda::setDevice(devInfo.deviceID());
107     }
108 };
109 
CUDA_TEST_P(PyrUp,Accuracy)110 CUDA_TEST_P(PyrUp, Accuracy)
111 {
112     cv::Mat src = randomMat(size, type);
113 
114     cv::cuda::GpuMat dst = createMat(cv::Size(size.width * 2, size.height * 2), type, useRoi);
115     cv::cuda::pyrUp(loadMat(src, useRoi), dst);
116 
117     cv::Mat dst_gold;
118     cv::pyrUp(src, dst_gold);
119 
120     EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-4 : 1.0);
121 }
122 
123 INSTANTIATE_TEST_CASE_P(CUDA_Warping, PyrUp, testing::Combine(
124     ALL_DEVICES,
125     DIFFERENT_SIZES,
126     testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),
127     WHOLE_SUBMAT));
128 
129 #endif // HAVE_CUDA
130