added perf tests for new gpu::cvtColor functions
[profile/ivi/opencv.git] / modules / gpu / perf_cpu / perf_utility.cpp
1 #include "perf_cpu_precomp.hpp"\r
2 \r
3 using namespace std;\r
4 using namespace cv;\r
5 using namespace cv::gpu;\r
6 \r
7 void fill(Mat& m, double a, double b)\r
8 {\r
9     RNG rng(123456789);\r
10     rng.fill(m, RNG::UNIFORM, a, b);\r
11 }\r
12 \r
13 void PrintTo(const CvtColorInfo& info, ostream* os)\r
14 {\r
15     static const char* str[] =\r
16     {\r
17         "BGR2BGRA",\r
18         "BGRA2BGR",\r
19         "BGR2RGBA",\r
20         "RGBA2BGR",\r
21         "BGR2RGB",\r
22         "BGRA2RGBA",\r
23 \r
24         "BGR2GRAY",\r
25         "RGB2GRAY",\r
26         "GRAY2BGR",\r
27         "GRAY2BGRA",\r
28         "BGRA2GRAY",\r
29         "RGBA2GRAY",\r
30 \r
31         "BGR2BGR565",\r
32         "RGB2BGR565",\r
33         "BGR5652BGR",\r
34         "BGR5652RGB",\r
35         "BGRA2BGR565",\r
36         "RGBA2BGR565",\r
37         "BGR5652BGRA",\r
38         "BGR5652RGBA",\r
39 \r
40         "GRAY2BGR565",\r
41         "BGR5652GRAY",\r
42 \r
43         "BGR2BGR555",\r
44         "RGB2BGR555",\r
45         "BGR5552BGR",\r
46         "BGR5552RGB",\r
47         "BGRA2BGR555",\r
48         "RGBA2BGR555",\r
49         "BGR5552BGRA",\r
50         "BGR5552RGBA",\r
51 \r
52         "GRAY2BGR555",\r
53         "BGR5552GRAY",\r
54 \r
55         "BGR2XYZ",\r
56         "RGB2XYZ",\r
57         "XYZ2BGR",\r
58         "XYZ2RGB",\r
59 \r
60         "BGR2YCrCb",\r
61         "RGB2YCrCb",\r
62         "YCrCb2BGR",\r
63         "YCrCb2RGB",\r
64 \r
65         "BGR2HSV",\r
66         "RGB2HSV",\r
67 \r
68         "",\r
69         "",\r
70 \r
71         "BGR2Lab",\r
72         "RGB2Lab",\r
73 \r
74         "BayerBG2BGR",\r
75         "BayerGB2BGR",\r
76         "BayerRG2BGR",\r
77         "BayerGR2BGR",\r
78 \r
79         "BGR2Luv",\r
80         "RGB2Luv",\r
81 \r
82         "BGR2HLS",\r
83         "RGB2HLS",\r
84 \r
85         "HSV2BGR",\r
86         "HSV2RGB",\r
87 \r
88         "Lab2BGR",\r
89         "Lab2RGB",\r
90         "Luv2BGR",\r
91         "Luv2RGB",\r
92 \r
93         "HLS2BGR",\r
94         "HLS2RGB",\r
95 \r
96         "BayerBG2BGR_VNG",\r
97         "BayerGB2BGR_VNG",\r
98         "BayerRG2BGR_VNG",\r
99         "BayerGR2BGR_VNG",\r
100 \r
101         "BGR2HSV_FULL",\r
102         "RGB2HSV_FULL",\r
103         "BGR2HLS_FULL",\r
104         "RGB2HLS_FULL",\r
105 \r
106         "HSV2BGR_FULL",\r
107         "HSV2RGB_FULL",\r
108         "HLS2BGR_FULL",\r
109         "HLS2RGB_FULL",\r
110 \r
111         "LBGR2Lab",\r
112         "LRGB2Lab",\r
113         "LBGR2Luv",\r
114         "LRGB2Luv",\r
115 \r
116         "Lab2LBGR",\r
117         "Lab2LRGB",\r
118         "Luv2LBGR",\r
119         "Luv2LRGB",\r
120 \r
121         "BGR2YUV",\r
122         "RGB2YUV",\r
123         "YUV2BGR",\r
124         "YUV2RGB",\r
125 \r
126         "BayerBG2GRAY",\r
127         "BayerGB2GRAY",\r
128         "BayerRG2GRAY",\r
129         "BayerGR2GRAY",\r
130 \r
131         //YUV 4:2:0 formats family\r
132         "YUV2RGB_NV12",\r
133         "YUV2BGR_NV12",\r
134         "YUV2RGB_NV21",\r
135         "YUV2BGR_NV21",\r
136 \r
137         "YUV2RGBA_NV12",\r
138         "YUV2BGRA_NV12",\r
139         "YUV2RGBA_NV21",\r
140         "YUV2BGRA_NV21",\r
141 \r
142         "YUV2RGB_YV12",\r
143         "YUV2BGR_YV12",\r
144         "YUV2RGB_IYUV",\r
145         "YUV2BGR_IYUV",\r
146 \r
147         "YUV2RGBA_YV12",\r
148         "YUV2BGRA_YV12",\r
149         "YUV2RGBA_IYUV",\r
150         "YUV2BGRA_IYUV",\r
151 \r
152         "YUV2GRAY_420",\r
153 \r
154         //YUV 4:2:2 formats family\r
155         "YUV2RGB_UYVY",\r
156         "YUV2BGR_UYVY",\r
157         "YUV2RGB_VYUY",\r
158         "YUV2BGR_VYUY",\r
159 \r
160         "YUV2RGBA_UYVY",\r
161         "YUV2BGRA_UYVY",\r
162         "YUV2RGBA_VYUY",\r
163         "YUV2BGRA_VYUY",\r
164 \r
165         "YUV2RGB_YUY2",\r
166         "YUV2BGR_YUY2",\r
167         "YUV2RGB_YVYU",\r
168         "YUV2BGR_YVYU",\r
169 \r
170         "YUV2RGBA_YUY2",\r
171         "YUV2BGRA_YUY2",\r
172         "YUV2RGBA_YVYU",\r
173         "YUV2BGRA_YVYU",\r
174 \r
175         "YUV2GRAY_UYVY",\r
176         "YUV2GRAY_YUY2",\r
177 \r
178         // alpha premultiplication\r
179         "RGBA2mRGBA",\r
180         "mRGBA2RGBA",\r
181 \r
182         "COLORCVT_MAX"\r
183     };\r
184 \r
185     *os << str[info.code];\r
186 }\r
187 \r
188 void cv::gpu::PrintTo(const DeviceInfo& info, ostream* os)\r
189 {\r
190     *os << info.name();\r
191 }\r
192 \r
193 Mat readImage(const string& fileName, int flags)\r
194 {\r
195     return imread(perf::TestBase::getDataPath(fileName), flags);\r
196 }\r
197 \r
198 const vector<DeviceInfo>& devices()\r
199 {\r
200     static vector<DeviceInfo> devs;\r
201     static bool first = true;\r
202 \r
203     if (first)\r
204     {\r
205         int deviceCount = getCudaEnabledDeviceCount();\r
206 \r
207         devs.reserve(deviceCount);\r
208 \r
209         for (int i = 0; i < deviceCount; ++i)\r
210         {\r
211             DeviceInfo info(i);\r
212             if (info.isCompatible())\r
213                 devs.push_back(info);\r
214         }\r
215 \r
216         first = false;\r
217     }\r
218 \r
219     return devs;\r
220 }\r