1 #include "perf_precomp.hpp"
\r
3 PERF_TEST_P(DevInfo_Size_MatType_Interpolation_BorderMode, remap, testing::Combine(testing::ValuesIn(devices()),
\r
4 testing::Values(GPU_TYPICAL_MAT_SIZES),
\r
5 testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_32FC1),
\r
6 testing::Values((int)INTER_NEAREST, (int)INTER_LINEAR, (int)INTER_CUBIC),
\r
7 testing::Values((int)BORDER_REFLECT101, (int)BORDER_REPLICATE, (int)BORDER_CONSTANT)))
\r
9 DeviceInfo devInfo = std::tr1::get<0>(GetParam());
\r
10 Size size = std::tr1::get<1>(GetParam());
\r
11 int type = std::tr1::get<2>(GetParam());
\r
12 int interpolation = std::tr1::get<3>(GetParam());
\r
13 int borderMode = std::tr1::get<4>(GetParam());
\r
15 setDevice(devInfo.deviceID());
\r
17 Mat src_host(size, type);
\r
19 declare.in(src_host, WARMUP_RNG);
\r
21 GpuMat src(src_host);
\r
22 GpuMat dst(size, type);
\r
24 Mat xmap_host(size, CV_32FC1);
\r
25 Mat ymap_host(size, CV_32FC1);
\r
26 randu(xmap_host, -300, size.width + 300);
\r
27 randu(ymap_host, -300, size.height + 300);
\r
29 GpuMat xmap(xmap_host);
\r
30 GpuMat ymap(ymap_host);
\r
32 declare.time(3.0).iterations(100);
\r
36 remap(src, dst, xmap, ymap, interpolation, borderMode);
\r
41 SANITY_CHECK(dst_host);
\r
44 PERF_TEST_P(DevInfo, meanShiftFiltering, testing::ValuesIn(devices()))
\r
46 DeviceInfo devInfo = GetParam();
\r
48 setDevice(devInfo.deviceID());
\r
50 Mat img = readImage("meanshift/cones.png");
\r
51 ASSERT_FALSE(img.empty());
\r
54 cvtColor(img, rgba, CV_BGR2BGRA);
\r
57 GpuMat dst(src.size(), CV_8UC4);
\r
59 declare.time(5.0).iterations(100);
\r
63 meanShiftFiltering(src, dst, 50, 50);
\r
68 SANITY_CHECK(dst_host);
\r
71 PERF_TEST_P(DevInfo, meanShiftProc, testing::ValuesIn(devices()))
\r
73 DeviceInfo devInfo = GetParam();
\r
75 setDevice(devInfo.deviceID());
\r
77 Mat img = readImage("meanshift/cones.png");
\r
78 ASSERT_FALSE(img.empty());
\r
81 cvtColor(img, rgba, CV_BGR2BGRA);
\r
84 GpuMat dstr(src.size(), CV_8UC4);
\r
85 GpuMat dstsp(src.size(), CV_16SC2);
\r
87 declare.time(5.0).iterations(100);
\r
91 meanShiftProc(src, dstr, dstsp, 50, 50);
\r
94 Mat dstr_host = dstr;
\r
95 Mat dstsp_host = dstsp;
\r
97 SANITY_CHECK(dstr_host);
\r
98 SANITY_CHECK(dstsp_host);
\r
101 PERF_TEST_P(DevInfo, meanShiftSegmentation, testing::ValuesIn(devices()))
\r
103 DeviceInfo devInfo = GetParam();
\r
105 setDevice(devInfo.deviceID());
\r
107 Mat img = readImage("meanshift/cones.png");
\r
108 ASSERT_FALSE(img.empty());
\r
111 cvtColor(img, rgba, CV_BGR2BGRA);
\r
114 Mat dst(src.size(), CV_8UC4);
\r
116 declare.time(5.0).iterations(100);
\r
118 SIMPLE_TEST_CYCLE()
\r
120 meanShiftSegmentation(src, dst, 10, 10, 20);
\r
126 PERF_TEST_P(DevInfo_Size_MatType, reprojectImageTo3D, testing::Combine(testing::ValuesIn(devices()),
\r
127 testing::Values(GPU_TYPICAL_MAT_SIZES),
\r
128 testing::Values(CV_8UC1, CV_16SC1)))
\r
130 DeviceInfo devInfo = std::tr1::get<0>(GetParam());
\r
131 Size size = std::tr1::get<1>(GetParam());
\r
132 int type = std::tr1::get<2>(GetParam());
\r
134 setDevice(devInfo.deviceID());
\r
136 Mat src_host(size, type);
\r
138 declare.in(src_host, WARMUP_RNG);
\r
140 GpuMat src(src_host);
\r
141 GpuMat dst(size, CV_32FC4);
\r
143 declare.time(0.5).iterations(100);
\r
145 SIMPLE_TEST_CYCLE()
\r
147 reprojectImageTo3D(src, dst, Mat::ones(4, 4, CV_32FC1));
\r
152 SANITY_CHECK(dst_host);
\r
155 PERF_TEST_P(DevInfo_Size_MatType_CvtColorInfo, cvtColor, testing::Combine(testing::ValuesIn(devices()),
\r
156 testing::Values(GPU_TYPICAL_MAT_SIZES),
\r
157 testing::Values(CV_8UC1, CV_16UC1, CV_32FC1),
\r
158 testing::Values(CvtColorInfo(4, 4, CV_RGBA2BGRA), CvtColorInfo(4, 1, CV_BGRA2GRAY), CvtColorInfo(1, 4, CV_GRAY2BGRA),
\r
159 CvtColorInfo(4, 4, CV_BGR2XYZ), CvtColorInfo(4, 4, CV_BGR2YCrCb), CvtColorInfo(4, 4, CV_BGR2HSV))))
\r
161 DeviceInfo devInfo = std::tr1::get<0>(GetParam());
\r
162 Size size = std::tr1::get<1>(GetParam());
\r
163 int type = std::tr1::get<2>(GetParam());
\r
164 CvtColorInfo info = std::tr1::get<3>(GetParam());
\r
166 setDevice(devInfo.deviceID());
\r
168 Mat src_host(size, CV_MAKETYPE(type, info.scn));
\r
170 declare.in(src_host, WARMUP_RNG);
\r
172 GpuMat src(src_host);
\r
173 GpuMat dst(size, CV_MAKETYPE(type, info.dcn));
\r
175 declare.time(0.5).iterations(100);
\r
177 SIMPLE_TEST_CYCLE()
\r
179 cvtColor(src, dst, info.code, info.dcn);
\r
184 SANITY_CHECK(dst_host);
\r
187 PERF_TEST_P(DevInfo_Size_MatType, threshold, testing::Combine(testing::ValuesIn(devices()),
\r
188 testing::Values(GPU_TYPICAL_MAT_SIZES),
\r
189 testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)))
\r
191 DeviceInfo devInfo = std::tr1::get<0>(GetParam());
\r
192 Size size = std::tr1::get<1>(GetParam());
\r
193 int type = std::tr1::get<2>(GetParam());
\r
195 setDevice(devInfo.deviceID());
\r
197 Mat src_host(size, type);
\r
199 declare.in(src_host, WARMUP_RNG);
\r
201 GpuMat src(src_host);
\r
202 GpuMat dst(size, type);
\r
204 declare.time(0.5).iterations(100);
\r
206 SIMPLE_TEST_CYCLE()
\r
208 threshold(src, dst, 100.0, 255.0, THRESH_BINARY);
\r
213 SANITY_CHECK(dst_host);
\r
216 PERF_TEST_P(DevInfo_Size_MatType_Interpolation_SizeCoeff, resize, testing::Combine(testing::ValuesIn(devices()),
\r
217 testing::Values(GPU_TYPICAL_MAT_SIZES),
\r
218 testing::Values(CV_8UC1, CV_8UC4),
\r
219 testing::Values((int)INTER_NEAREST, (int)INTER_LINEAR),
\r
220 testing::Values(0.5, 2.0)))
\r
222 DeviceInfo devInfo = std::tr1::get<0>(GetParam());
\r
223 Size size = std::tr1::get<1>(GetParam());
\r
224 int type = std::tr1::get<2>(GetParam());
\r
225 int interpolation = std::tr1::get<3>(GetParam());
\r
226 double f = std::tr1::get<4>(GetParam());
\r
228 setDevice(devInfo.deviceID());
\r
230 Mat src_host(size, type);
\r
232 declare.in(src_host, WARMUP_RNG);
\r
234 GpuMat src(src_host);
\r
237 declare.time(0.5).iterations(100);
\r
239 SIMPLE_TEST_CYCLE()
\r
241 resize(src, dst, Size(), f, f, interpolation);
\r
246 SANITY_CHECK(dst_host);
\r
249 PERF_TEST_P(DevInfo_Size_MatType_Interpolation, warpAffine, testing::Combine(testing::ValuesIn(devices()),
\r
250 testing::Values(GPU_TYPICAL_MAT_SIZES),
\r
251 testing::Values(CV_8UC1, CV_8UC4, CV_32FC1),
\r
252 testing::Values((int)INTER_NEAREST, (int)INTER_LINEAR, (int)INTER_CUBIC)))
\r
254 DeviceInfo devInfo = std::tr1::get<0>(GetParam());
\r
255 Size size = std::tr1::get<1>(GetParam());
\r
256 int type = std::tr1::get<2>(GetParam());
\r
257 int interpolation = std::tr1::get<3>(GetParam());
\r
259 setDevice(devInfo.deviceID());
\r
261 Mat src_host(size, type);
\r
263 declare.in(src_host, WARMUP_RNG);
\r
265 GpuMat src(src_host);
\r
266 GpuMat dst(size, type);
\r
268 static double reflect[2][3] = { {-1, 0, 0},
\r
270 reflect[0][2] = size.width;
\r
271 reflect[1][2] = size.height;
\r
272 Mat M(2, 3, CV_64F, (void*)reflect);
\r
274 declare.time(0.5).iterations(100);
\r
276 SIMPLE_TEST_CYCLE()
\r
278 warpAffine(src, dst, M, size, interpolation);
\r
283 SANITY_CHECK(dst_host);
\r
286 PERF_TEST_P(DevInfo_Size_MatType_Interpolation, warpPerspective, testing::Combine(testing::ValuesIn(devices()),
\r
287 testing::Values(GPU_TYPICAL_MAT_SIZES),
\r
288 testing::Values(CV_8UC1, CV_8UC4, CV_32FC1),
\r
289 testing::Values((int)INTER_NEAREST, (int)INTER_LINEAR, (int)INTER_CUBIC)))
\r
291 DeviceInfo devInfo = std::tr1::get<0>(GetParam());
\r
292 Size size = std::tr1::get<1>(GetParam());
\r
293 int type = std::tr1::get<2>(GetParam());
\r
294 int interpolation = std::tr1::get<3>(GetParam());
\r
296 setDevice(devInfo.deviceID());
\r
298 Mat src_host(size, type);
\r
300 declare.in(src_host, WARMUP_RNG);
\r
302 GpuMat src(src_host);
\r
303 GpuMat dst(size, type);
\r
305 static double reflect[3][3] = { {-1, 0, 0},
\r
308 reflect[0][2] = size.width;
\r
309 reflect[1][2] = size.height;
\r
310 Mat M(3, 3, CV_64F, (void*)reflect);
\r
312 declare.time(0.5).iterations(100);
\r
314 SIMPLE_TEST_CYCLE()
\r
316 warpPerspective(src, dst, M, size, interpolation);
\r
321 SANITY_CHECK(dst_host);
\r
324 PERF_TEST_P(DevInfo_Size_MatType_Interpolation, rotate, testing::Combine(testing::ValuesIn(devices()),
\r
325 testing::Values(GPU_TYPICAL_MAT_SIZES),
\r
326 testing::Values(CV_8UC1, CV_8UC4),
\r
327 testing::Values((int)INTER_NEAREST, (int)INTER_LINEAR, (int)INTER_CUBIC)))
\r
329 DeviceInfo devInfo = std::tr1::get<0>(GetParam());
\r
330 Size size = std::tr1::get<1>(GetParam());
\r
331 int type = std::tr1::get<2>(GetParam());
\r
332 int interpolation = std::tr1::get<3>(GetParam());
\r
334 setDevice(devInfo.deviceID());
\r
336 Mat src_host(size, type);
\r
338 declare.in(src_host, WARMUP_RNG);
\r
340 GpuMat src(src_host);
\r
341 GpuMat dst(size, type);
\r
343 declare.time(0.5).iterations(100);
\r
345 SIMPLE_TEST_CYCLE()
\r
347 rotate(src, dst, size, 30.0, 0, 0, interpolation);
\r
352 SANITY_CHECK(dst_host);
\r
355 PERF_TEST_P(DevInfo_Size_MatType, copyMakeBorder, testing::Combine(testing::ValuesIn(devices()),
\r
356 testing::Values(GPU_TYPICAL_MAT_SIZES),
\r
357 testing::Values(CV_8UC1, CV_8UC4, CV_32SC1)))
\r
359 DeviceInfo devInfo = std::tr1::get<0>(GetParam());
\r
360 Size size = std::tr1::get<1>(GetParam());
\r
361 int type = std::tr1::get<2>(GetParam());
\r
363 setDevice(devInfo.deviceID());
\r
365 Mat src_host(size, type);
\r
367 declare.in(src_host, WARMUP_RNG);
\r
369 GpuMat src(src_host);
\r
372 declare.time(0.5).iterations(100);
\r
374 SIMPLE_TEST_CYCLE()
\r
376 copyMakeBorder(src, dst, 5, 5, 5, 5);
\r
381 SANITY_CHECK(dst_host);
\r
384 PERF_TEST_P(DevInfo_Size, integral, testing::Combine(testing::ValuesIn(devices()),
\r
385 testing::Values(GPU_TYPICAL_MAT_SIZES)))
\r
387 DeviceInfo devInfo = std::tr1::get<0>(GetParam());
\r
388 Size size = std::tr1::get<1>(GetParam());
\r
390 setDevice(devInfo.deviceID());
\r
392 Mat src_host(size, CV_8UC1);
\r
394 declare.in(src_host, WARMUP_RNG);
\r
396 GpuMat src(src_host);
\r
400 declare.time(0.5).iterations(100);
\r
402 SIMPLE_TEST_CYCLE()
\r
404 integralBuffered(src, dst, buf);
\r
409 SANITY_CHECK(dst_host);
\r
412 PERF_TEST_P(DevInfo_Size, sqrIntegral, testing::Combine(testing::ValuesIn(devices()),
\r
413 testing::Values(GPU_TYPICAL_MAT_SIZES)))
\r
415 DeviceInfo devInfo = std::tr1::get<0>(GetParam());
\r
416 Size size = std::tr1::get<1>(GetParam());
\r
418 setDevice(devInfo.deviceID());
\r
420 Mat src_host(size, CV_8UC1);
\r
422 declare.in(src_host, WARMUP_RNG);
\r
424 GpuMat src(src_host);
\r
427 declare.time(0.5).iterations(100);
\r
429 SIMPLE_TEST_CYCLE()
\r
431 sqrIntegral(src, dst);
\r
436 SANITY_CHECK(dst_host);
\r
439 PERF_TEST_P(DevInfo_Size, columnSum, testing::Combine(testing::ValuesIn(devices()),
\r
440 testing::Values(GPU_TYPICAL_MAT_SIZES)))
\r
442 DeviceInfo devInfo = std::tr1::get<0>(GetParam());
\r
443 Size size = std::tr1::get<1>(GetParam());
\r
445 setDevice(devInfo.deviceID());
\r
447 Mat src_host(size, CV_32FC1);
\r
449 declare.in(src_host, WARMUP_RNG);
\r
451 GpuMat src(src_host);
\r
454 declare.time(0.5).iterations(100);
\r
456 SIMPLE_TEST_CYCLE()
\r
458 columnSum(src, dst);
\r
463 SANITY_CHECK(dst_host);
\r
466 PERF_TEST_P(DevInfo_MatType, cornerHarris, testing::Combine(testing::ValuesIn(devices()),
\r
467 testing::Values(CV_8UC1, CV_32FC1)))
\r
469 DeviceInfo devInfo = std::tr1::get<0>(GetParam());
\r
470 int type = std::tr1::get<1>(GetParam());
\r
472 setDevice(devInfo.deviceID());
\r
474 Mat img = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
\r
475 ASSERT_FALSE(img.empty());
\r
477 img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0);
\r
488 declare.time(0.5).iterations(100);
\r
490 SIMPLE_TEST_CYCLE()
\r
492 cornerHarris(src, dst, Dx, Dy, blockSize, ksize, k);
\r
499 SANITY_CHECK(dst_host);
\r
500 SANITY_CHECK(Dx_host);
\r
501 SANITY_CHECK(Dy_host);
\r
504 PERF_TEST_P(DevInfo_MatType, cornerMinEigenVal, testing::Combine(testing::ValuesIn(devices()),
\r
505 testing::Values(CV_8UC1, CV_32FC1)))
\r
507 DeviceInfo devInfo = std::tr1::get<0>(GetParam());
\r
508 int type = std::tr1::get<1>(GetParam());
\r
510 setDevice(devInfo.deviceID());
\r
512 Mat img = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
\r
513 ASSERT_FALSE(img.empty());
\r
515 img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0);
\r
525 declare.time(0.5).iterations(100);
\r
527 SIMPLE_TEST_CYCLE()
\r
529 cornerMinEigenVal(src, dst, Dx, Dy, blockSize, ksize);
\r
536 SANITY_CHECK(dst_host);
\r
537 SANITY_CHECK(Dx_host);
\r
538 SANITY_CHECK(Dy_host);
\r
541 PERF_TEST_P(DevInfo_Size_MatType, mulSpectrums, testing::Combine(testing::ValuesIn(devices()),
\r
542 testing::Values(GPU_TYPICAL_MAT_SIZES),
\r
543 testing::Values(CV_8UC1, CV_32FC1)))
\r
545 DeviceInfo devInfo = std::tr1::get<0>(GetParam());
\r
546 Size size = std::tr1::get<1>(GetParam());
\r
547 int type = std::tr1::get<2>(GetParam());
\r
549 setDevice(devInfo.deviceID());
\r
551 Mat a_host(size, CV_32FC2);
\r
552 Mat b_host(size, CV_32FC2);
\r
554 declare.in(a_host, b_host, WARMUP_RNG);
\r
560 declare.time(0.5).iterations(100);
\r
562 SIMPLE_TEST_CYCLE()
\r
564 mulSpectrums(a, b, dst, 0);
\r
569 SANITY_CHECK(dst_host);
\r
572 PERF_TEST_P(DevInfo_Size, dft, testing::Combine(testing::ValuesIn(devices()),
\r
573 testing::Values(GPU_TYPICAL_MAT_SIZES)))
\r
575 DeviceInfo devInfo = std::tr1::get<0>(GetParam());
\r
576 Size size = std::tr1::get<1>(GetParam());
\r
578 setDevice(devInfo.deviceID());
\r
580 Mat src_host(size, CV_32FC2);
\r
582 declare.in(src_host, WARMUP_RNG);
\r
584 GpuMat src(src_host);
\r
587 declare.time(2.0).iterations(100);
\r
589 SIMPLE_TEST_CYCLE()
\r
591 dft(src, dst, size);
\r
596 SANITY_CHECK(dst_host);
\r
599 PERF_TEST_P(DevInfo_Size, convolve, testing::Combine(testing::ValuesIn(devices()),
\r
600 testing::Values(GPU_TYPICAL_MAT_SIZES)))
\r
602 DeviceInfo devInfo = std::tr1::get<0>(GetParam());
\r
603 Size size = std::tr1::get<1>(GetParam());
\r
605 setDevice(devInfo.deviceID());
\r
607 Mat image_host(size, CV_32FC1);
\r
608 Mat templ_host(size, CV_32FC1);
\r
610 declare.in(image_host, templ_host, WARMUP_RNG);
\r
612 GpuMat image(image_host);
\r
613 GpuMat templ(templ_host);
\r
617 declare.time(2.0).iterations(100);
\r
619 SIMPLE_TEST_CYCLE()
\r
621 convolve(image, templ, dst, false, buf);
\r
626 SANITY_CHECK(dst_host);
\r
629 PERF_TEST_P(DevInfo_Size_MatType, pyrDown, testing::Combine(testing::ValuesIn(devices()),
\r
630 testing::Values(GPU_TYPICAL_MAT_SIZES),
\r
631 testing::Values(CV_8UC1, CV_8UC4, CV_16SC3, CV_32FC1)))
\r
633 DeviceInfo devInfo = std::tr1::get<0>(GetParam());
\r
634 Size size = std::tr1::get<1>(GetParam());
\r
635 int type = std::tr1::get<2>(GetParam());
\r
637 setDevice(devInfo.deviceID());
\r
639 Mat src_host(size, type);
\r
641 declare.in(src_host, WARMUP_RNG);
\r
643 GpuMat src(src_host);
\r
646 declare.time(0.5).iterations(100);
\r
648 SIMPLE_TEST_CYCLE()
\r
655 SANITY_CHECK(dst_host);
\r
658 PERF_TEST_P(DevInfo_Size_MatType, pyrUp, testing::Combine(testing::ValuesIn(devices()),
\r
659 testing::Values(GPU_TYPICAL_MAT_SIZES),
\r
660 testing::Values(CV_8UC1, CV_8UC4, CV_16SC3, CV_32FC1)))
\r
662 DeviceInfo devInfo = std::tr1::get<0>(GetParam());
\r
663 Size size = std::tr1::get<1>(GetParam());
\r
664 int type = std::tr1::get<2>(GetParam());
\r
666 setDevice(devInfo.deviceID());
\r
668 Mat src_host(size, type);
\r
670 declare.in(src_host, WARMUP_RNG);
\r
672 GpuMat src(src_host);
\r
675 declare.time(0.5).iterations(100);
\r
677 SIMPLE_TEST_CYCLE()
\r
684 SANITY_CHECK(dst_host);
\r
687 PERF_TEST_P(DevInfo_Size_MatType, blendLinear, testing::Combine(testing::ValuesIn(devices()),
\r
688 testing::Values(GPU_TYPICAL_MAT_SIZES),
\r
689 testing::Values(CV_8UC1, CV_32FC1)))
\r
691 DeviceInfo devInfo = std::tr1::get<0>(GetParam());
\r
692 Size size = std::tr1::get<1>(GetParam());
\r
693 int type = std::tr1::get<2>(GetParam());
\r
695 setDevice(devInfo.deviceID());
\r
697 Mat img1_host(size, type);
\r
698 Mat img2_host(size, type);
\r
700 declare.in(img1_host, img2_host, WARMUP_RNG);
\r
702 GpuMat img1(img1_host);
\r
703 GpuMat img2(img2_host);
\r
704 GpuMat weights1(size, CV_32FC1, Scalar::all(0.5));
\r
705 GpuMat weights2(size, CV_32FC1, Scalar::all(0.5));
\r
708 declare.time(0.5).iterations(100);
\r
710 SIMPLE_TEST_CYCLE()
\r
712 blendLinear(img1, img2, weights1, weights2, dst);
\r
717 SANITY_CHECK(dst_host);
\r
720 PERF_TEST_P(DevInfo, Canny, testing::ValuesIn(devices()))
\r
722 DeviceInfo devInfo = GetParam();
\r
724 setDevice(devInfo.deviceID());
\r
726 Mat image_host = readImage("perf/aloe.jpg", CV_LOAD_IMAGE_GRAYSCALE);
\r
727 ASSERT_FALSE(image_host.empty());
\r
729 GpuMat image(image_host);
\r
733 declare.time(0.5).iterations(100);
\r
735 SIMPLE_TEST_CYCLE()
\r
737 Canny(image, buf, dst, 50.0, 100.0);
\r
742 SANITY_CHECK(dst_host);
\r