1 ///////////////////////////////////////////////////////////////////////////////////////
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) 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.
17 //
18 // @Authors
19 // Niko Li, newlife20080214@gmail.com
20 // Jia Haipeng, jiahaipeng95@gmail.com
21 // Shengen Yan, yanshengen@gmail.com
22 // Jiang Liyuan,jlyuan001.good@163.com
23 // Rock Li, Rock.Li@amd.com
24 // Zailong Wu, bullet@yeah.net
25 // Yao Wang, bitwangyaoyao@gmail.com
26 //
27 // Redistribution and use in source and binary forms, with or without modification,
28 // are permitted provided that the following conditions are met:
29 //
30 // * Redistribution's of source code must retain the above copyright notice,
31 // this list of conditions and the following disclaimer.
32 //
33 // * Redistribution's in binary form must reproduce the above copyright notice,
34 // this list of conditions and the following disclaimer in the documentation
35 // and/or other materials provided with the distribution.
36 //
37 // * The name of the copyright holders may not be used to endorse or promote products
38 // derived from this software without specific prior written permission.
39 //
40 // This software is provided by the copyright holders and contributors "as is" and
41 // any express or implied warranties, including, but not limited to, the implied
42 // warranties of merchantability and fitness for a particular purpose are disclaimed.
43 // In no event shall the Intel Corporation or contributors be liable for any direct,
44 // indirect, incidental, special, exemplary, or consequential damages
45 // (including, but not limited to, procurement of substitute goods or services;
46 // loss of use, data, or profits; or business interruption) however caused
47 // and on any theory of liability, whether in contract, strict liability,
48 // or tort (including negligence or otherwise) arising in any way out of
49 // the use of this software, even if advised of the possibility of such damage.
50 //
51 //M*/
52
53 #include "../test_precomp.hpp"
54 #include "opencv2/ts/ocl_test.hpp"
55
56 #ifdef HAVE_OPENCL
57
58 namespace cvtest {
59 namespace ocl {
60
61 ///////////////////// HOG /////////////////////////////
PARAM_TEST_CASE(HOG,Size,MatType)62 PARAM_TEST_CASE(HOG, Size, MatType)
63 {
64 Size winSize;
65 int type;
66 Mat img;
67 UMat uimg;
68 virtual void SetUp()
69 {
70 winSize = GET_PARAM(0);
71 type = GET_PARAM(1);
72 img = readImage("cascadeandhog/images/image_00000000_0.png", IMREAD_GRAYSCALE);
73 ASSERT_FALSE(img.empty());
74 img.copyTo(uimg);
75 }
76 };
77
OCL_TEST_P(HOG,GetDescriptors)78 OCL_TEST_P(HOG, GetDescriptors)
79 {
80 HOGDescriptor hog;
81 hog.gammaCorrection = true;
82
83 hog.setSVMDetector(hog.getDefaultPeopleDetector());
84
85 std::vector<float> cpu_descriptors;
86 std::vector<float> gpu_descriptors;
87
88 OCL_OFF(hog.compute(img, cpu_descriptors, hog.winSize));
89 OCL_ON(hog.compute(uimg, gpu_descriptors, hog.winSize));
90
91 Mat cpu_desc(cpu_descriptors), gpu_desc(gpu_descriptors);
92
93 EXPECT_MAT_SIMILAR(cpu_desc, gpu_desc, 1e-1);
94 }
95
OCL_TEST_P(HOG,Detect)96 OCL_TEST_P(HOG, Detect)
97 {
98 HOGDescriptor hog;
99 hog.winSize = winSize;
100 hog.gammaCorrection = true;
101
102 if (winSize.width == 48 && winSize.height == 96)
103 hog.setSVMDetector(hog.getDaimlerPeopleDetector());
104 else
105 hog.setSVMDetector(hog.getDefaultPeopleDetector());
106
107 std::vector<Rect> cpu_found;
108 std::vector<Rect> gpu_found;
109
110 OCL_OFF(hog.detectMultiScale(img, cpu_found, 0, Size(8, 8), Size(0, 0), 1.05, 6));
111 OCL_ON(hog.detectMultiScale(uimg, gpu_found, 0, Size(8, 8), Size(0, 0), 1.05, 6));
112
113 EXPECT_LT(checkRectSimilarity(img.size(), cpu_found, gpu_found), 0.05);
114 }
115
116 INSTANTIATE_TEST_CASE_P(OCL_ObjDetect, HOG, testing::Combine(
117 testing::Values(Size(64, 128), Size(48, 96)),
118 testing::Values( MatType(CV_8UC1) ) ) );
119
120 }}
121 #endif
122