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) 2010-2013, Advanced Micro Devices, Inc., all rights reserved. 14 // Third party copyrights are property of their respective owners. 15 // 16 // Redistribution and use in source and binary forms, with or without modification, 17 // are permitted provided that the following conditions are met: 18 // 19 // * Redistribution's of source code must retain the above copyright notice, 20 // this list of conditions and the following disclaimer. 21 // 22 // * Redistribution's in binary form must reproduce the above copyright notice, 23 // this list of conditions and the following disclaimer in the documentation 24 // and/or other materials provided with the distribution. 25 // 26 // * The name of the copyright holders may not be used to endorse or promote products 27 // derived from this software without specific prior written permission. 28 // 29 // This software is provided by the copyright holders and contributors "as is" and 30 // any express or implied warranties, including, but not limited to, the implied 31 // warranties of merchantability and fitness for a particular purpose are disclaimed. 32 // In no event shall the OpenCV Foundation or contributors be liable for any direct, 33 // indirect, incidental, special, exemplary, or consequential damages 34 // (including, but not limited to, procurement of substitute goods or services; 35 // loss of use, data, or profits; or business interruption) however caused 36 // and on any theory of liability, whether in contract, strict liability, 37 // or tort (including negligence or otherwise) arising in any way out of 38 // the use of this software, even if advised of the possibility of such damage. 39 // 40 //M*/ 41 42 #include "../test_precomp.hpp" 43 #include "opencv2/ts/ocl_test.hpp" 44 45 #include <cmath> 46 47 #ifdef HAVE_OPENCL 48 49 namespace cvtest { 50 namespace ocl { 51 52 //////////////////////////////// LUT ///////////////////////////////////////////////// 53 54 PARAM_TEST_CASE(Lut, MatDepth, MatDepth, Channels, bool, bool) 55 { 56 int src_depth, lut_depth; 57 int cn; 58 bool use_roi, same_cn; 59 60 TEST_DECLARE_INPUT_PARAMETER(src); 61 TEST_DECLARE_INPUT_PARAMETER(lut); 62 TEST_DECLARE_OUTPUT_PARAMETER(dst); 63 64 virtual void SetUp() 65 { 66 src_depth = GET_PARAM(0); 67 lut_depth = GET_PARAM(1); 68 cn = GET_PARAM(2); 69 same_cn = GET_PARAM(3); 70 use_roi = GET_PARAM(4); 71 } 72 73 void generateTestData() 74 { 75 const int src_type = CV_MAKE_TYPE(src_depth, cn); 76 const int lut_type = CV_MAKE_TYPE(lut_depth, same_cn ? cn : 1); 77 const int dst_type = CV_MAKE_TYPE(lut_depth, cn); 78 79 Size roiSize = randomSize(1, MAX_VALUE); 80 Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); 81 randomSubMat(src, src_roi, roiSize, srcBorder, src_type, 0, 256); 82 83 Size lutRoiSize = Size(256, 1); 84 Border lutBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); 85 randomSubMat(lut, lut_roi, lutRoiSize, lutBorder, lut_type, 5, 16); 86 87 Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); 88 randomSubMat(dst, dst_roi, roiSize, dstBorder, dst_type, 5, 16); 89 90 UMAT_UPLOAD_INPUT_PARAMETER(src); 91 UMAT_UPLOAD_INPUT_PARAMETER(lut); 92 UMAT_UPLOAD_OUTPUT_PARAMETER(dst); 93 } 94 95 void Near(double threshold = 0.) 96 { 97 OCL_EXPECT_MATS_NEAR(dst, threshold); 98 } 99 }; 100 101 OCL_TEST_P(Lut, Mat) 102 { 103 for (int j = 0; j < test_loop_times; j++) 104 { 105 generateTestData(); 106 107 OCL_OFF(cv::LUT(src_roi, lut_roi, dst_roi)); 108 OCL_ON(cv::LUT(usrc_roi, ulut_roi, udst_roi)); 109 110 Near(); 111 } 112 } 113 114 ///////////////////////// ArithmTestBase /////////////////////////// 115 116 PARAM_TEST_CASE(ArithmTestBase, MatDepth, Channels, bool) 117 { 118 int depth; 119 int cn; 120 bool use_roi; 121 cv::Scalar val; 122 cv::Scalar val_in_range; 123 124 TEST_DECLARE_INPUT_PARAMETER(src1); 125 TEST_DECLARE_INPUT_PARAMETER(src2); 126 TEST_DECLARE_INPUT_PARAMETER(mask); 127 TEST_DECLARE_OUTPUT_PARAMETER(dst1); 128 TEST_DECLARE_OUTPUT_PARAMETER(dst2); 129 130 virtual void SetUp() 131 { 132 depth = GET_PARAM(0); 133 cn = GET_PARAM(1); 134 use_roi = GET_PARAM(2); 135 } 136 137 virtual void generateTestData(bool with_val_in_range = false) 138 { 139 const int type = CV_MAKE_TYPE(depth, cn); 140 141 double minV = getMinVal(type); 142 double maxV = getMaxVal(type); 143 144 Size roiSize = randomSize(1, MAX_VALUE); 145 Border src1Border = randomBorder(0, use_roi ? MAX_VALUE : 0); 146 randomSubMat(src1, src1_roi, roiSize, src1Border, type, 2, 11); // FIXIT: Test with minV, maxV 147 148 Border src2Border = randomBorder(0, use_roi ? MAX_VALUE : 0); 149 randomSubMat(src2, src2_roi, roiSize, src2Border, type, std::max(-1540., minV), std::min(1740., maxV)); 150 151 Border dst1Border = randomBorder(0, use_roi ? MAX_VALUE : 0); 152 randomSubMat(dst1, dst1_roi, roiSize, dst1Border, type, 5, 16); 153 154 Border dst2Border = randomBorder(0, use_roi ? MAX_VALUE : 0); 155 randomSubMat(dst2, dst2_roi, roiSize, dst2Border, type, 5, 16); 156 157 Border maskBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); 158 randomSubMat(mask, mask_roi, roiSize, maskBorder, CV_8UC1, 0, 2); 159 cv::threshold(mask, mask, 0.5, 255., CV_8UC1); 160 *mask.ptr(0) = 255; // prevent test case with mask filled 0 only 161 162 val = cv::Scalar(rng.uniform(-100.0, 100.0), rng.uniform(-100.0, 100.0), 163 rng.uniform(-100.0, 100.0), rng.uniform(-100.0, 100.0)); 164 165 if (with_val_in_range) 166 { 167 val_in_range = cv::Scalar(rng.uniform(minV, maxV), rng.uniform(minV, maxV), 168 rng.uniform(minV, maxV), rng.uniform(minV, maxV)); 169 } 170 171 UMAT_UPLOAD_INPUT_PARAMETER(src1); 172 UMAT_UPLOAD_INPUT_PARAMETER(src2); 173 UMAT_UPLOAD_INPUT_PARAMETER(mask); 174 UMAT_UPLOAD_OUTPUT_PARAMETER(dst1); 175 UMAT_UPLOAD_OUTPUT_PARAMETER(dst2); 176 } 177 178 void Near(double threshold = 0., bool relative = false) 179 { 180 if (!relative) 181 OCL_EXPECT_MATS_NEAR(dst1, threshold); 182 else 183 OCL_EXPECT_MATS_NEAR_RELATIVE(dst1, threshold); 184 } 185 186 void Near1(double threshold = 0.) 187 { 188 OCL_EXPECT_MATS_NEAR(dst2, threshold); 189 } 190 }; 191 192 //////////////////////////////// Add ///////////////////////////////////////////////// 193 194 typedef ArithmTestBase Add; 195 196 OCL_TEST_P(Add, Mat) 197 { 198 for (int j = 0; j < test_loop_times; j++) 199 { 200 generateTestData(); 201 202 OCL_OFF(cv::add(src1_roi, src2_roi, dst1_roi)); 203 OCL_ON(cv::add(usrc1_roi, usrc2_roi, udst1_roi)); 204 Near(0); 205 } 206 } 207 208 OCL_TEST_P(Add, Mat_Mask) 209 { 210 for (int j = 0; j < test_loop_times; j++) 211 { 212 generateTestData(); 213 214 OCL_OFF(cv::add(src1_roi, src2_roi, dst1_roi, mask_roi)); 215 OCL_ON(cv::add(usrc1_roi, usrc2_roi, udst1_roi, umask_roi)); 216 Near(0); 217 } 218 } 219 220 OCL_TEST_P(Add, Scalar) 221 { 222 for (int j = 0; j < test_loop_times; j++) 223 { 224 generateTestData(); 225 226 OCL_OFF(cv::add(src1_roi, val, dst1_roi)); 227 OCL_ON(cv::add(val, usrc1_roi, udst1_roi)); 228 Near(1e-5); 229 } 230 } 231 232 OCL_TEST_P(Add, Scalar_Mask) 233 { 234 for (int j = 0; j < test_loop_times; j++) 235 { 236 generateTestData(); 237 238 OCL_OFF(cv::add(src1_roi, val, dst1_roi, mask_roi)); 239 OCL_ON(cv::add(usrc1_roi, val, udst1_roi, umask_roi)); 240 Near(1e-5); 241 } 242 } 243 244 //////////////////////////////////////// Subtract ////////////////////////////////////////////// 245 246 typedef ArithmTestBase Subtract; 247 248 OCL_TEST_P(Subtract, Mat) 249 { 250 for (int j = 0; j < test_loop_times; j++) 251 { 252 generateTestData(); 253 254 OCL_OFF(cv::subtract(src1_roi, src2_roi, dst1_roi)); 255 OCL_ON(cv::subtract(usrc1_roi, usrc2_roi, udst1_roi)); 256 Near(0); 257 } 258 } 259 260 OCL_TEST_P(Subtract, Mat_Mask) 261 { 262 for (int j = 0; j < test_loop_times; j++) 263 { 264 generateTestData(); 265 266 OCL_OFF(cv::subtract(src1_roi, src2_roi, dst1_roi, mask_roi)); 267 OCL_ON(cv::subtract(usrc1_roi, usrc2_roi, udst1_roi, umask_roi)); 268 Near(0); 269 } 270 } 271 272 OCL_TEST_P(Subtract, Scalar) 273 { 274 for (int j = 0; j < test_loop_times; j++) 275 { 276 generateTestData(); 277 278 OCL_OFF(cv::subtract(val, src1_roi, dst1_roi)); 279 OCL_ON(cv::subtract(val, usrc1_roi, udst1_roi)); 280 Near(1e-5); 281 } 282 } 283 284 OCL_TEST_P(Subtract, Scalar_Mask) 285 { 286 for (int j = 0; j < test_loop_times; j++) 287 { 288 generateTestData(); 289 290 OCL_OFF(cv::subtract(src1_roi, val, dst1_roi, mask_roi)); 291 OCL_ON(cv::subtract(usrc1_roi, val, udst1_roi, umask_roi)); 292 Near(1e-5); 293 } 294 } 295 296 //////////////////////////////// Mul ///////////////////////////////////////////////// 297 298 typedef ArithmTestBase Mul; 299 300 OCL_TEST_P(Mul, Mat) 301 { 302 for (int j = 0; j < test_loop_times; j++) 303 { 304 generateTestData(); 305 306 OCL_OFF(cv::multiply(src1_roi, src2_roi, dst1_roi)); 307 OCL_ON(cv::multiply(usrc1_roi, usrc2_roi, udst1_roi)); 308 Near(0); 309 } 310 } 311 312 OCL_TEST_P(Mul, Scalar) 313 { 314 for (int j = 0; j < test_loop_times; j++) 315 { 316 generateTestData(); 317 318 OCL_OFF(cv::multiply(src1_roi, val, dst1_roi)); 319 OCL_ON(cv::multiply(val, usrc1_roi, udst1_roi)); 320 321 Near(udst1_roi.depth() >= CV_32F ? 1e-3 : 1); 322 } 323 } 324 325 OCL_TEST_P(Mul, Mat_Scale) 326 { 327 for (int j = 0; j < test_loop_times; j++) 328 { 329 generateTestData(); 330 331 OCL_OFF(cv::multiply(src1_roi, src2_roi, dst1_roi, val[0])); 332 OCL_ON(cv::multiply(usrc1_roi, usrc2_roi, udst1_roi, val[0])); 333 334 #ifdef ANDROID 335 Near(udst1_roi.depth() >= CV_32F ? 2e-1 : 1); 336 #else 337 Near(udst1_roi.depth() >= CV_32F ? 1e-3 : 1); 338 #endif 339 } 340 } 341 342 OCL_TEST_P(Mul, Mat_Scalar_Scale) 343 { 344 for (int j = 0; j < test_loop_times; j++) 345 { 346 generateTestData(); 347 348 OCL_OFF(cv::multiply(src1_roi, val, dst1_roi, val[0])); 349 OCL_ON(cv::multiply(usrc1_roi, val, udst1_roi, val[0])); 350 351 if (udst1_roi.depth() >= CV_32F) 352 Near(1e-6, true); 353 else 354 Near(1); 355 } 356 } 357 358 359 //////////////////////////////// Div ///////////////////////////////////////////////// 360 361 typedef ArithmTestBase Div; 362 363 OCL_TEST_P(Div, Mat) 364 { 365 for (int j = 0; j < test_loop_times; j++) 366 { 367 generateTestData(); 368 369 OCL_OFF(cv::divide(src1_roi, src2_roi, dst1_roi)); 370 OCL_ON(cv::divide(usrc1_roi, usrc2_roi, udst1_roi)); 371 Near(1); 372 } 373 } 374 375 OCL_TEST_P(Div, Scalar) 376 { 377 for (int j = 0; j < test_loop_times; j++) 378 { 379 generateTestData(); 380 381 OCL_OFF(cv::divide(val, src1_roi, dst1_roi)); 382 OCL_ON(cv::divide(val, usrc1_roi, udst1_roi)); 383 384 Near(udst1_roi.depth() >= CV_32F ? 1e-3 : 1); 385 } 386 } 387 388 OCL_TEST_P(Div, Scalar2) 389 { 390 for (int j = 0; j < test_loop_times; j++) 391 { 392 generateTestData(); 393 394 OCL_OFF(cv::divide(src1_roi, val, dst1_roi)); 395 OCL_ON(cv::divide(usrc1_roi, val, udst1_roi)); 396 397 Near(udst1_roi.depth() >= CV_32F ? 1e-3 : 1); 398 } 399 } 400 401 OCL_TEST_P(Div, Mat_Scale) 402 { 403 for (int j = 0; j < test_loop_times; j++) 404 { 405 generateTestData(); 406 407 OCL_OFF(cv::divide(src1_roi, src2_roi, dst1_roi, val[0])); 408 OCL_ON(cv::divide(usrc1_roi, usrc2_roi, udst1_roi, val[0])); 409 410 Near(udst1_roi.depth() >= CV_32F ? 4e-3 : 1); 411 } 412 } 413 414 OCL_TEST_P(Div, Mat_Scalar_Scale) 415 { 416 for (int j = 0; j < test_loop_times; j++) 417 { 418 generateTestData(); 419 420 OCL_OFF(cv::divide(src1_roi, val, dst1_roi, val[0])); 421 OCL_ON(cv::divide(usrc1_roi, val, udst1_roi, val[0])); 422 423 Near(udst1_roi.depth() >= CV_32F ? 4e-3 : 1); 424 } 425 } 426 427 OCL_TEST_P(Div, Recip) 428 { 429 for (int j = 0; j < test_loop_times; j++) 430 { 431 generateTestData(); 432 433 OCL_OFF(cv::divide(val[0], src1_roi, dst1_roi)); 434 OCL_ON(cv::divide(val[0], usrc1_roi, udst1_roi)); 435 436 Near(udst1_roi.depth() >= CV_32F ? 1e-3 : 1); 437 } 438 } 439 440 //////////////////////////////// Min/Max ///////////////////////////////////////////////// 441 442 typedef ArithmTestBase Min; 443 444 OCL_TEST_P(Min, Mat) 445 { 446 for (int j = 0; j < test_loop_times; j++) 447 { 448 generateTestData(); 449 450 OCL_OFF(cv::max(src1_roi, src2_roi, dst1_roi)); 451 OCL_ON(cv::max(usrc1_roi, usrc2_roi, udst1_roi)); 452 Near(0); 453 } 454 } 455 456 typedef ArithmTestBase Max; 457 458 OCL_TEST_P(Max, Mat) 459 { 460 for (int j = 0; j < test_loop_times; j++) 461 { 462 generateTestData(); 463 464 OCL_OFF(cv::min(src1_roi, src2_roi, dst1_roi)); 465 OCL_ON(cv::min(usrc1_roi, usrc2_roi, udst1_roi)); 466 Near(0); 467 } 468 } 469 470 //////////////////////////////// Absdiff ///////////////////////////////////////////////// 471 472 typedef ArithmTestBase Absdiff; 473 474 OCL_TEST_P(Absdiff, Mat) 475 { 476 for (int j = 0; j < test_loop_times; j++) 477 { 478 generateTestData(); 479 480 OCL_OFF(cv::absdiff(src1_roi, src2_roi, dst1_roi)); 481 OCL_ON(cv::absdiff(usrc1_roi, usrc2_roi, udst1_roi)); 482 Near(0); 483 } 484 } 485 486 OCL_TEST_P(Absdiff, Scalar) 487 { 488 for (int j = 0; j < test_loop_times; j++) 489 { 490 generateTestData(); 491 492 OCL_OFF(cv::absdiff(src1_roi, val, dst1_roi)); 493 OCL_ON(cv::absdiff(usrc1_roi, val, udst1_roi)); 494 Near(1e-5); 495 } 496 } 497 498 //////////////////////////////// CartToPolar ///////////////////////////////////////////////// 499 500 typedef ArithmTestBase CartToPolar; 501 502 OCL_TEST_P(CartToPolar, angleInDegree) 503 { 504 for (int j = 0; j < test_loop_times; j++) 505 { 506 generateTestData(); 507 508 OCL_OFF(cv::cartToPolar(src1_roi, src2_roi, dst1_roi, dst2_roi, true)); 509 OCL_ON(cv::cartToPolar(usrc1_roi, usrc2_roi, udst1_roi, udst2_roi, true)); 510 Near(0.5); 511 Near1(0.5); 512 } 513 } 514 515 OCL_TEST_P(CartToPolar, angleInRadians) 516 { 517 for (int j = 0; j < test_loop_times; j++) 518 { 519 generateTestData(); 520 521 OCL_OFF(cv::cartToPolar(src1_roi, src2_roi, dst1_roi, dst2_roi)); 522 OCL_ON(cv::cartToPolar(usrc1_roi, usrc2_roi, udst1_roi, udst2_roi)); 523 Near(0.5); 524 Near1(0.5); 525 } 526 } 527 528 //////////////////////////////// PolarToCart ///////////////////////////////////////////////// 529 530 typedef ArithmTestBase PolarToCart; 531 532 OCL_TEST_P(PolarToCart, angleInDegree) 533 { 534 for (int j = 0; j < test_loop_times; j++) 535 { 536 generateTestData(); 537 538 OCL_OFF(cv::polarToCart(src1_roi, src2_roi, dst1_roi, dst2_roi, true)); 539 OCL_ON(cv::polarToCart(usrc1_roi, usrc2_roi, udst1_roi, udst2_roi, true)); 540 541 Near(0.5); 542 Near1(0.5); 543 } 544 } 545 546 OCL_TEST_P(PolarToCart, angleInRadians) 547 { 548 for (int j = 0; j < test_loop_times; j++) 549 { 550 generateTestData(); 551 552 OCL_OFF(cv::polarToCart(src1_roi, src2_roi, dst1_roi, dst2_roi)); 553 OCL_ON(cv::polarToCart(usrc1_roi, usrc2_roi, udst1_roi, udst2_roi)); 554 555 Near(0.5); 556 Near1(0.5); 557 } 558 } 559 560 //////////////////////////////// Transpose ///////////////////////////////////////////////// 561 562 typedef ArithmTestBase Transpose; 563 564 OCL_TEST_P(Transpose, Mat) 565 { 566 for (int j = 0; j < test_loop_times; j++) 567 { 568 generateTestData(); 569 570 Size roiSize = src1_roi.size(); 571 Border dst1Border = randomBorder(0, use_roi ? MAX_VALUE : 0); 572 randomSubMat(dst1, dst1_roi, Size(roiSize.height, roiSize.width), dst1Border, src1.type(), 5, 16); 573 574 UMAT_UPLOAD_INPUT_PARAMETER(dst1); 575 576 OCL_OFF(cv::transpose(src1_roi, dst1_roi)); 577 OCL_ON(cv::transpose(usrc1_roi, udst1_roi)); 578 579 Near(1e-5); 580 } 581 } 582 583 OCL_TEST_P(Transpose, SquareInplace) 584 { 585 const int type = CV_MAKE_TYPE(depth, cn); 586 587 for (int j = 0; j < test_loop_times; j++) 588 { 589 Size roiSize = randomSize(1, MAX_VALUE); 590 roiSize.height = roiSize.width; // make it square 591 592 Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); 593 randomSubMat(src1, src1_roi, roiSize, srcBorder, type, 5, 16); 594 595 UMAT_UPLOAD_OUTPUT_PARAMETER(src1); 596 597 OCL_OFF(cv::transpose(src1_roi, src1_roi)); 598 OCL_ON(cv::transpose(usrc1_roi, usrc1_roi)); 599 600 OCL_EXPECT_MATS_NEAR(src1, 0); 601 } 602 } 603 604 //////////////////////////////// Bitwise_and ///////////////////////////////////////////////// 605 606 typedef ArithmTestBase Bitwise_and; 607 608 OCL_TEST_P(Bitwise_and, Mat) 609 { 610 for (int j = 0; j < test_loop_times; j++) 611 { 612 generateTestData(); 613 614 OCL_OFF(cv::bitwise_and(src1_roi, src2_roi, dst1_roi)); 615 OCL_ON(cv::bitwise_and(usrc1_roi, usrc2_roi, udst1_roi)); 616 Near(0); 617 } 618 } 619 620 OCL_TEST_P(Bitwise_and, Mat_Mask) 621 { 622 for (int j = 0; j < test_loop_times; j++) 623 { 624 generateTestData(); 625 626 OCL_OFF(cv::bitwise_and(src1_roi, src2_roi, dst1_roi, mask_roi)); 627 OCL_ON(cv::bitwise_and(usrc1_roi, usrc2_roi, udst1_roi, umask_roi)); 628 Near(0); 629 } 630 } 631 632 OCL_TEST_P(Bitwise_and, Scalar) 633 { 634 for (int j = 0; j < test_loop_times; j++) 635 { 636 generateTestData(); 637 638 OCL_OFF(cv::bitwise_and(src1_roi, val, dst1_roi)); 639 OCL_ON(cv::bitwise_and(usrc1_roi, val, udst1_roi)); 640 Near(1e-5); 641 } 642 } 643 644 OCL_TEST_P(Bitwise_and, Scalar_Mask) 645 { 646 for (int j = 0; j < test_loop_times; j++) 647 { 648 generateTestData(); 649 650 OCL_OFF(cv::bitwise_and(src1_roi, val, dst1_roi, mask_roi)); 651 OCL_ON(cv::bitwise_and(usrc1_roi, val, udst1_roi, umask_roi)); 652 Near(1e-5); 653 } 654 } 655 656 //////////////////////////////// Bitwise_or ///////////////////////////////////////////////// 657 658 typedef ArithmTestBase Bitwise_or; 659 660 OCL_TEST_P(Bitwise_or, Mat) 661 { 662 for (int j = 0; j < test_loop_times; j++) 663 { 664 generateTestData(); 665 666 OCL_OFF(cv::bitwise_or(src1_roi, src2_roi, dst1_roi)); 667 OCL_ON(cv::bitwise_or(usrc1_roi, usrc2_roi, udst1_roi)); 668 Near(0); 669 } 670 } 671 672 OCL_TEST_P(Bitwise_or, Mat_Mask) 673 { 674 for (int j = 0; j < test_loop_times; j++) 675 { 676 generateTestData(); 677 678 OCL_OFF(cv::bitwise_or(src1_roi, src2_roi, dst1_roi, mask_roi)); 679 OCL_ON(cv::bitwise_or(usrc1_roi, usrc2_roi, udst1_roi, umask_roi)); 680 Near(0); 681 } 682 } 683 684 OCL_TEST_P(Bitwise_or, Scalar) 685 { 686 for (int j = 0; j < test_loop_times; j++) 687 { 688 generateTestData(); 689 690 OCL_OFF(cv::bitwise_or(src1_roi, val, dst1_roi)); 691 OCL_ON(cv::bitwise_or(usrc1_roi, val, udst1_roi)); 692 Near(1e-5); 693 } 694 } 695 696 OCL_TEST_P(Bitwise_or, Scalar_Mask) 697 { 698 for (int j = 0; j < test_loop_times; j++) 699 { 700 generateTestData(); 701 702 OCL_OFF(cv::bitwise_or(src1_roi, val, dst1_roi, mask_roi)); 703 OCL_ON(cv::bitwise_or(val, usrc1_roi, udst1_roi, umask_roi)); 704 Near(1e-5); 705 } 706 } 707 708 //////////////////////////////// Bitwise_xor ///////////////////////////////////////////////// 709 710 typedef ArithmTestBase Bitwise_xor; 711 712 OCL_TEST_P(Bitwise_xor, Mat) 713 { 714 for (int j = 0; j < test_loop_times; j++) 715 { 716 generateTestData(); 717 718 OCL_OFF(cv::bitwise_xor(src1_roi, src2_roi, dst1_roi)); 719 OCL_ON(cv::bitwise_xor(usrc1_roi, usrc2_roi, udst1_roi)); 720 Near(0); 721 } 722 } 723 724 OCL_TEST_P(Bitwise_xor, Mat_Mask) 725 { 726 for (int j = 0; j < test_loop_times; j++) 727 { 728 generateTestData(); 729 730 OCL_OFF(cv::bitwise_xor(src1_roi, src2_roi, dst1_roi, mask_roi)); 731 OCL_ON(cv::bitwise_xor(usrc1_roi, usrc2_roi, udst1_roi, umask_roi)); 732 Near(0); 733 } 734 } 735 736 OCL_TEST_P(Bitwise_xor, Scalar) 737 { 738 for (int j = 0; j < test_loop_times; j++) 739 { 740 generateTestData(); 741 742 OCL_OFF(cv::bitwise_xor(src1_roi, val, dst1_roi)); 743 OCL_ON(cv::bitwise_xor(usrc1_roi, val, udst1_roi)); 744 Near(1e-5); 745 } 746 } 747 748 OCL_TEST_P(Bitwise_xor, Scalar_Mask) 749 { 750 for (int j = 0; j < test_loop_times; j++) 751 { 752 generateTestData(); 753 754 OCL_OFF(cv::bitwise_xor(src1_roi, val, dst1_roi, mask_roi)); 755 OCL_ON(cv::bitwise_xor(usrc1_roi, val, udst1_roi, umask_roi)); 756 Near(1e-5); 757 } 758 } 759 760 //////////////////////////////// Bitwise_not ///////////////////////////////////////////////// 761 762 typedef ArithmTestBase Bitwise_not; 763 764 OCL_TEST_P(Bitwise_not, Mat) 765 { 766 for (int j = 0; j < test_loop_times; j++) 767 { 768 generateTestData(); 769 770 OCL_OFF(cv::bitwise_not(src1_roi, dst1_roi)); 771 OCL_ON(cv::bitwise_not(usrc1_roi, udst1_roi)); 772 Near(0); 773 } 774 } 775 776 //////////////////////////////// Compare ///////////////////////////////////////////////// 777 778 typedef ArithmTestBase Compare; 779 780 static const int cmp_codes[] = { CMP_EQ, CMP_GT, CMP_GE, CMP_LT, CMP_LE, CMP_NE }; 781 static const char * cmp_strs[] = { "CMP_EQ", "CMP_GT", "CMP_GE", "CMP_LT", "CMP_LE", "CMP_NE" }; 782 static const int cmp_num = sizeof(cmp_codes) / sizeof(int); 783 784 OCL_TEST_P(Compare, Mat) 785 { 786 for (int i = 0; i < cmp_num; ++i) 787 { 788 SCOPED_TRACE(cmp_strs[i]); 789 for (int j = 0; j < test_loop_times; j++) 790 { 791 generateTestData(); 792 793 OCL_OFF(cv::compare(src1_roi, src2_roi, dst1_roi, cmp_codes[i])); 794 OCL_ON(cv::compare(usrc1_roi, usrc2_roi, udst1_roi, cmp_codes[i])); 795 796 Near(0); 797 } 798 } 799 } 800 801 OCL_TEST_P(Compare, Scalar) 802 { 803 for (int i = 0; i < cmp_num; ++i) 804 { 805 SCOPED_TRACE(cmp_strs[i]); 806 for (int j = 0; j < test_loop_times; j++) 807 { 808 generateTestData(true); 809 810 OCL_OFF(cv::compare(src1_roi, val_in_range, dst1_roi, cmp_codes[i])); 811 OCL_ON(cv::compare(usrc1_roi, val_in_range, udst1_roi, cmp_codes[i])); 812 813 Near(0); 814 } 815 } 816 } 817 818 OCL_TEST_P(Compare, Scalar2) 819 { 820 for (int i = 0; i < cmp_num; ++i) 821 { 822 SCOPED_TRACE(cmp_strs[i]); 823 for (int j = 0; j < test_loop_times; j++) 824 { 825 generateTestData(true); 826 827 OCL_OFF(cv::compare(val_in_range, src1_roi, dst1_roi, cmp_codes[i])); 828 OCL_ON(cv::compare(val_in_range, usrc1_roi, udst1_roi, cmp_codes[i])); 829 830 Near(0); 831 } 832 } 833 } 834 835 //////////////////////////////// Pow ///////////////////////////////////////////////// 836 837 typedef ArithmTestBase Pow; 838 839 OCL_TEST_P(Pow, Mat) 840 { 841 static const double pows[] = { -4, -1, -2.5, 0, 1, 2, 3.7, 4 }; 842 843 for (int j = 0; j < 1/*test_loop_times*/; j++) 844 for (int k = 0, size = sizeof(pows) / sizeof(double); k < size; ++k) 845 { 846 SCOPED_TRACE(pows[k]); 847 848 generateTestData(); 849 850 OCL_OFF(cv::pow(src1_roi, pows[k], dst1_roi)); 851 OCL_ON(cv::pow(usrc1_roi, pows[k], udst1_roi)); 852 853 OCL_EXPECT_MATS_NEAR_RELATIVE(dst1, 1e-5); 854 } 855 } 856 857 //////////////////////////////// AddWeighted ///////////////////////////////////////////////// 858 859 typedef ArithmTestBase AddWeighted; 860 861 OCL_TEST_P(AddWeighted, Mat) 862 { 863 for (int j = 0; j < test_loop_times; j++) 864 { 865 generateTestData(); 866 867 const double alpha = 2.0, beta = 1.0, gama = 3.0; 868 869 OCL_OFF(cv::addWeighted(src1_roi, alpha, src2_roi, beta, gama, dst1_roi)); 870 OCL_ON(cv::addWeighted(usrc1_roi, alpha, usrc2_roi, beta, gama, udst1_roi)); 871 872 Near(3e-4); 873 } 874 } 875 876 //////////////////////////////// setIdentity ///////////////////////////////////////////////// 877 878 typedef ArithmTestBase SetIdentity; 879 880 OCL_TEST_P(SetIdentity, Mat) 881 { 882 for (int j = 0; j < test_loop_times; j++) 883 { 884 generateTestData(); 885 886 OCL_OFF(cv::setIdentity(dst1_roi, val)); 887 OCL_ON(cv::setIdentity(udst1_roi, val)); 888 889 Near(0); 890 } 891 } 892 893 //// Repeat 894 895 struct RepeatTestCase : 896 public ArithmTestBase 897 { 898 int nx, ny; 899 900 virtual void generateTestData() 901 { 902 const int type = CV_MAKE_TYPE(depth, cn); 903 904 nx = randomInt(1, 4); 905 ny = randomInt(1, 4); 906 907 Size srcRoiSize = randomSize(1, MAX_VALUE); 908 Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); 909 randomSubMat(src1, src1_roi, srcRoiSize, srcBorder, type, 2, 11); 910 911 Size dstRoiSize(srcRoiSize.width * nx, srcRoiSize.height * ny); 912 Border dst1Border = randomBorder(0, use_roi ? MAX_VALUE : 0); 913 randomSubMat(dst1, dst1_roi, dstRoiSize, dst1Border, type, 5, 16); 914 915 UMAT_UPLOAD_INPUT_PARAMETER(src1); 916 UMAT_UPLOAD_OUTPUT_PARAMETER(dst1); 917 } 918 }; 919 920 typedef RepeatTestCase Repeat; 921 922 OCL_TEST_P(Repeat, Mat) 923 { 924 for (int i = 0; i < test_loop_times; ++i) 925 { 926 generateTestData(); 927 928 OCL_OFF(cv::repeat(src1_roi, ny, nx, dst1_roi)); 929 OCL_ON(cv::repeat(usrc1_roi, ny, nx, udst1_roi)); 930 931 Near(); 932 } 933 } 934 935 //////////////////////////////// CountNonZero ///////////////////////////////////////////////// 936 937 typedef ArithmTestBase CountNonZero; 938 939 OCL_TEST_P(CountNonZero, MAT) 940 { 941 for (int j = 0; j < test_loop_times; j++) 942 { 943 generateTestData(); 944 945 int cpures, gpures; 946 OCL_OFF(cpures = cv::countNonZero(src1_roi)); 947 OCL_ON(gpures = cv::countNonZero(usrc1_roi)); 948 949 EXPECT_EQ(cpures, gpures); 950 } 951 } 952 953 //////////////////////////////// Sum ///////////////////////////////////////////////// 954 955 typedef ArithmTestBase Sum; 956 957 OCL_TEST_P(Sum, MAT) 958 { 959 for (int j = 0; j < test_loop_times; j++) 960 { 961 generateTestData(); 962 963 Scalar cpures, gpures; 964 OCL_OFF(cpures = cv::sum(src1_roi)); 965 OCL_ON(gpures = cv::sum(usrc1_roi)); 966 967 for (int i = 0; i < cn; ++i) 968 EXPECT_NEAR(cpures[i], gpures[i], 0.1); 969 } 970 } 971 972 //////////////////////////////// meanStdDev ///////////////////////////////////////////////// 973 974 typedef ArithmTestBase MeanStdDev; 975 976 OCL_TEST_P(MeanStdDev, Mat) 977 { 978 for (int j = 0; j < test_loop_times; j++) 979 { 980 generateTestData(); 981 982 Scalar cpu_mean, cpu_stddev; 983 Scalar gpu_mean, gpu_stddev; 984 985 OCL_OFF(cv::meanStdDev(src1_roi, cpu_mean, cpu_stddev)); 986 OCL_ON(cv::meanStdDev(usrc1_roi, gpu_mean, gpu_stddev)); 987 988 for (int i = 0; i < cn; ++i) 989 { 990 EXPECT_NEAR(cpu_mean[i], gpu_mean[i], 0.1); 991 EXPECT_NEAR(cpu_stddev[i], gpu_stddev[i], 0.1); 992 } 993 } 994 } 995 996 OCL_TEST_P(MeanStdDev, Mat_Mask) 997 { 998 for (int j = 0; j < test_loop_times; j++) 999 { 1000 generateTestData(); 1001 1002 Scalar cpu_mean, cpu_stddev; 1003 Scalar gpu_mean, gpu_stddev; 1004 1005 OCL_OFF(cv::meanStdDev(src1_roi, cpu_mean, cpu_stddev, mask_roi)); 1006 OCL_ON(cv::meanStdDev(usrc1_roi, gpu_mean, gpu_stddev, umask_roi)); 1007 1008 for (int i = 0; i < cn; ++i) 1009 { 1010 EXPECT_NEAR(cpu_mean[i], gpu_mean[i], 0.1); 1011 EXPECT_NEAR(cpu_stddev[i], gpu_stddev[i], 0.1); 1012 } 1013 } 1014 } 1015 1016 OCL_TEST(MeanStdDev_, ZeroMask) 1017 { 1018 Size size(5, 5); 1019 UMat um(size, CV_32SC1), umask(size, CV_8UC1, Scalar::all(0)); 1020 Mat m(size, CV_32SC1), mask(size, CV_8UC1, Scalar::all(0)); 1021 1022 Scalar cpu_mean, cpu_stddev; 1023 Scalar gpu_mean, gpu_stddev; 1024 1025 OCL_OFF(cv::meanStdDev(m, cpu_mean, cpu_stddev, mask)); 1026 OCL_ON(cv::meanStdDev(um, gpu_mean, gpu_stddev, umask)); 1027 1028 for (int i = 0; i < 4; ++i) 1029 { 1030 EXPECT_NEAR(cpu_mean[i], gpu_mean[i], 0.1); 1031 EXPECT_NEAR(cpu_stddev[i], gpu_stddev[i], 0.1); 1032 } 1033 } 1034 1035 //////////////////////////////////////// Log ///////////////////////////////////////// 1036 1037 typedef ArithmTestBase Log; 1038 1039 OCL_TEST_P(Log, Mat) 1040 { 1041 for (int j = 0; j < test_loop_times; j++) 1042 { 1043 generateTestData(); 1044 1045 OCL_OFF(cv::log(src1_roi, dst1_roi)); 1046 OCL_ON(cv::log(usrc1_roi, udst1_roi)); 1047 Near(1); 1048 } 1049 } 1050 1051 //////////////////////////////////////// Exp ///////////////////////////////////////// 1052 1053 typedef ArithmTestBase Exp; 1054 1055 OCL_TEST_P(Exp, Mat) 1056 { 1057 for (int j = 0; j < test_loop_times; j++) 1058 { 1059 generateTestData(); 1060 1061 OCL_OFF(cv::exp(src1_roi, dst1_roi)); 1062 OCL_ON(cv::exp(usrc1_roi, udst1_roi)); 1063 Near(2); 1064 } 1065 } 1066 1067 //////////////////////////////////////// Phase ///////////////////////////////////////// 1068 1069 typedef ArithmTestBase Phase; 1070 1071 OCL_TEST_P(Phase, angleInDegree) 1072 { 1073 for (int j = 0; j < test_loop_times; j++) 1074 { 1075 generateTestData(); 1076 1077 OCL_OFF(cv::phase(src1_roi, src2_roi, dst1_roi, true)); 1078 OCL_ON(cv::phase(usrc1_roi, usrc2_roi, udst1_roi, true)); 1079 Near(1e-2); 1080 } 1081 } 1082 1083 OCL_TEST_P(Phase, angleInRadians) 1084 { 1085 for (int j = 0; j < test_loop_times; j++) 1086 { 1087 generateTestData(); 1088 1089 OCL_OFF(cv::phase(src1_roi, src2_roi, dst1_roi)); 1090 OCL_ON(cv::phase(usrc1_roi, usrc2_roi, udst1_roi)); 1091 Near(1e-2); 1092 } 1093 } 1094 1095 //////////////////////////////////////// Magnitude ///////////////////////////////////////// 1096 1097 typedef ArithmTestBase Magnitude; 1098 1099 OCL_TEST_P(Magnitude, Mat) 1100 { 1101 for (int j = 0; j < test_loop_times; j++) 1102 { 1103 generateTestData(); 1104 1105 OCL_OFF(cv::magnitude(src1_roi, src2_roi, dst1_roi)); 1106 OCL_ON(cv::magnitude(usrc1_roi, usrc2_roi, udst1_roi)); 1107 Near(depth == CV_64F ? 1e-5 : 1e-2); 1108 } 1109 } 1110 1111 //////////////////////////////// Flip ///////////////////////////////////////////////// 1112 1113 typedef ArithmTestBase Flip; 1114 1115 OCL_TEST_P(Flip, X) 1116 { 1117 for (int j = 0; j < test_loop_times; j++) 1118 { 1119 generateTestData(); 1120 1121 OCL_OFF(cv::flip(src1_roi, dst1_roi, 0)); 1122 OCL_ON(cv::flip(usrc1_roi, udst1_roi, 0)); 1123 Near(0); 1124 } 1125 } 1126 1127 OCL_TEST_P(Flip, Y) 1128 { 1129 for (int j = 0; j < test_loop_times; j++) 1130 { 1131 generateTestData(); 1132 1133 OCL_OFF(cv::flip(src1_roi, dst1_roi, 1)); 1134 OCL_ON(cv::flip(usrc1_roi, udst1_roi, 1)); 1135 Near(0); 1136 } 1137 } 1138 1139 OCL_TEST_P(Flip, BOTH) 1140 { 1141 for (int j = 0; j < test_loop_times; j++) 1142 { 1143 generateTestData(); 1144 1145 OCL_OFF(cv::flip(src1_roi, dst1_roi, -1)); 1146 OCL_ON(cv::flip(usrc1_roi, udst1_roi, -1)); 1147 Near(0); 1148 } 1149 } 1150 //////////////////////////////////////// minMaxIdx ///////////////////////////////////////// 1151 1152 typedef ArithmTestBase MinMaxIdx; 1153 1154 OCL_TEST_P(MinMaxIdx, Mat) 1155 { 1156 for (int j = 0; j < test_loop_times; j++) 1157 { 1158 generateTestData(); 1159 1160 int p1[2], p2[2], up1[2], up2[2]; 1161 double minv, maxv, uminv, umaxv; 1162 1163 if (cn > 1) 1164 { 1165 OCL_OFF(cv::minMaxIdx(src2_roi, &minv, &maxv) ); 1166 OCL_ON(cv::minMaxIdx(usrc2_roi, &uminv, &umaxv)); 1167 1168 EXPECT_DOUBLE_EQ(minv, uminv); 1169 EXPECT_DOUBLE_EQ(maxv, umaxv); 1170 } 1171 else 1172 { 1173 OCL_OFF(cv::minMaxIdx(src2_roi, &minv, &maxv, p1, p2, noArray())); 1174 OCL_ON(cv::minMaxIdx(usrc2_roi, &uminv, &umaxv, up1, up2, noArray())); 1175 1176 EXPECT_DOUBLE_EQ(minv, uminv); 1177 EXPECT_DOUBLE_EQ(maxv, umaxv); 1178 1179 for (int i = 0; i < 2; i++) 1180 { 1181 EXPECT_EQ(p1[i], up1[i]); 1182 EXPECT_EQ(p2[i], up2[i]); 1183 } 1184 } 1185 } 1186 } 1187 1188 typedef ArithmTestBase MinMaxIdx_Mask; 1189 1190 OCL_TEST_P(MinMaxIdx_Mask, Mat) 1191 { 1192 for (int j = 0; j < test_loop_times; j++) 1193 { 1194 generateTestData(); 1195 1196 int p1[2], p2[2], up1[2], up2[2]; 1197 double minv, maxv, uminv, umaxv; 1198 1199 OCL_OFF(cv::minMaxIdx(src2_roi, &minv, &maxv, p1, p2, mask_roi)); 1200 OCL_ON(cv::minMaxIdx(usrc2_roi, &uminv, &umaxv, up1, up2, umask_roi)); 1201 1202 EXPECT_DOUBLE_EQ(minv, uminv); 1203 EXPECT_DOUBLE_EQ(maxv, umaxv); 1204 for( int i = 0; i < 2; i++) 1205 { 1206 EXPECT_EQ(p1[i], up1[i]); 1207 EXPECT_EQ(p2[i], up2[i]); 1208 } 1209 1210 } 1211 } 1212 1213 //////////////////////////////// Norm ///////////////////////////////////////////////// 1214 1215 static bool relativeError(double actual, double expected, double eps) 1216 { 1217 return std::abs(actual - expected) < eps*(1 + std::abs(actual)); 1218 } 1219 1220 typedef ArithmTestBase Norm; 1221 1222 OCL_TEST_P(Norm, NORM_INF_1arg) 1223 { 1224 for (int j = 0; j < test_loop_times; j++) 1225 { 1226 generateTestData(); 1227 1228 OCL_OFF(const double cpuRes = cv::norm(src1_roi, NORM_INF)); 1229 OCL_ON(const double gpuRes = cv::norm(usrc1_roi, NORM_INF)); 1230 1231 EXPECT_NEAR(cpuRes, gpuRes, 0.1); 1232 } 1233 } 1234 1235 OCL_TEST_P(Norm, NORM_INF_1arg_mask) 1236 { 1237 for (int j = 0; j < test_loop_times; j++) 1238 { 1239 generateTestData(); 1240 1241 OCL_OFF(const double cpuRes = cv::norm(src1_roi, NORM_INF, mask_roi)); 1242 OCL_ON(const double gpuRes = cv::norm(usrc1_roi, NORM_INF, umask_roi)); 1243 1244 EXPECT_NEAR(cpuRes, gpuRes, 0.2); 1245 } 1246 } 1247 1248 OCL_TEST_P(Norm, NORM_L1_1arg) 1249 { 1250 for (int j = 0; j < test_loop_times; j++) 1251 { 1252 generateTestData(); 1253 1254 OCL_OFF(const double cpuRes = cv::norm(src1_roi, NORM_L1)); 1255 OCL_ON(const double gpuRes = cv::norm(usrc1_roi, NORM_L1)); 1256 1257 EXPECT_PRED3(relativeError, cpuRes, gpuRes, 1e-6); 1258 } 1259 } 1260 1261 OCL_TEST_P(Norm, NORM_L1_1arg_mask) 1262 { 1263 for (int j = 0; j < test_loop_times; j++) 1264 { 1265 generateTestData(); 1266 1267 OCL_OFF(const double cpuRes = cv::norm(src1_roi, NORM_L1, mask_roi)); 1268 OCL_ON(const double gpuRes = cv::norm(usrc1_roi, NORM_L1, umask_roi)); 1269 1270 EXPECT_PRED3(relativeError, cpuRes, gpuRes, 1e-6); 1271 } 1272 } 1273 1274 OCL_TEST_P(Norm, NORM_L2_1arg) 1275 { 1276 for (int j = 0; j < test_loop_times; j++) 1277 { 1278 generateTestData(); 1279 1280 OCL_OFF(const double cpuRes = cv::norm(src1_roi, NORM_L2)); 1281 OCL_ON(const double gpuRes = cv::norm(usrc1_roi, NORM_L2)); 1282 1283 EXPECT_PRED3(relativeError, cpuRes, gpuRes, 1e-6); 1284 } 1285 } 1286 1287 OCL_TEST_P(Norm, NORM_L2_1arg_mask) 1288 { 1289 for (int j = 0; j < test_loop_times; j++) 1290 { 1291 generateTestData(); 1292 1293 OCL_OFF(const double cpuRes = cv::norm(src1_roi, NORM_L2, mask_roi)); 1294 OCL_ON(const double gpuRes = cv::norm(usrc1_roi, NORM_L2, umask_roi)); 1295 1296 EXPECT_PRED3(relativeError, cpuRes, gpuRes, 1e-6); 1297 } 1298 } 1299 1300 OCL_TEST_P(Norm, NORM_INF_2args) 1301 { 1302 for (int relative = 0; relative < 2; ++relative) 1303 for (int j = 0; j < test_loop_times; j++) 1304 { 1305 generateTestData(); 1306 1307 SCOPED_TRACE(relative ? "NORM_RELATIVE" : ""); 1308 1309 int type = NORM_INF; 1310 if (relative == 1) 1311 type |= NORM_RELATIVE; 1312 1313 OCL_OFF(const double cpuRes = cv::norm(src1_roi, src2_roi, type)); 1314 OCL_ON(const double gpuRes = cv::norm(usrc1_roi, usrc2_roi, type)); 1315 1316 EXPECT_PRED3(relativeError, cpuRes, gpuRes, 1e-6); 1317 } 1318 } 1319 1320 OCL_TEST_P(Norm, NORM_INF_2args_mask) 1321 { 1322 for (int relative = 0; relative < 2; ++relative) 1323 for (int j = 0; j < test_loop_times; j++) 1324 { 1325 generateTestData(); 1326 1327 SCOPED_TRACE(relative ? "NORM_RELATIVE" : ""); 1328 1329 int type = NORM_INF; 1330 if (relative == 1) 1331 type |= NORM_RELATIVE; 1332 1333 OCL_OFF(const double cpuRes = cv::norm(src1_roi, src2_roi, type, mask_roi)); 1334 OCL_ON(const double gpuRes = cv::norm(usrc1_roi, usrc2_roi, type, umask_roi)); 1335 1336 EXPECT_PRED3(relativeError, cpuRes, gpuRes, 1e-6); 1337 } 1338 } 1339 1340 OCL_TEST_P(Norm, NORM_L1_2args) 1341 { 1342 for (int relative = 0; relative < 2; ++relative) 1343 for (int j = 0; j < test_loop_times; j++) 1344 { 1345 generateTestData(); 1346 1347 SCOPED_TRACE(relative ? "NORM_RELATIVE" : ""); 1348 1349 int type = NORM_L1; 1350 if (relative == 1) 1351 type |= NORM_RELATIVE; 1352 1353 OCL_OFF(const double cpuRes = cv::norm(src1_roi, src2_roi, type)); 1354 OCL_ON(const double gpuRes = cv::norm(usrc1_roi, usrc2_roi, type)); 1355 1356 EXPECT_PRED3(relativeError, cpuRes, gpuRes, 1e-6); 1357 } 1358 } 1359 1360 OCL_TEST_P(Norm, NORM_L1_2args_mask) 1361 { 1362 for (int relative = 0; relative < 2; ++relative) 1363 for (int j = 0; j < test_loop_times; j++) 1364 { 1365 generateTestData(); 1366 1367 SCOPED_TRACE(relative ? "NORM_RELATIVE" : ""); 1368 1369 int type = NORM_L1; 1370 if (relative == 1) 1371 type |= NORM_RELATIVE; 1372 1373 OCL_OFF(const double cpuRes = cv::norm(src1_roi, src2_roi, type, mask_roi)); 1374 OCL_ON(const double gpuRes = cv::norm(usrc1_roi, usrc2_roi, type, umask_roi)); 1375 1376 EXPECT_PRED3(relativeError, cpuRes, gpuRes, 1e-6); 1377 } 1378 } 1379 1380 OCL_TEST_P(Norm, NORM_L2_2args) 1381 { 1382 for (int relative = 0; relative < 2; ++relative) 1383 for (int j = 0; j < test_loop_times; j++) 1384 { 1385 generateTestData(); 1386 1387 SCOPED_TRACE(relative ? "NORM_RELATIVE" : ""); 1388 1389 int type = NORM_L2; 1390 if (relative == 1) 1391 type |= NORM_RELATIVE; 1392 1393 OCL_OFF(const double cpuRes = cv::norm(src1_roi, src2_roi, type)); 1394 OCL_ON(const double gpuRes = cv::norm(usrc1_roi, usrc2_roi, type)); 1395 1396 EXPECT_PRED3(relativeError, cpuRes, gpuRes, 1e-6); 1397 } 1398 } 1399 1400 OCL_TEST_P(Norm, NORM_L2_2args_mask) 1401 { 1402 for (int relative = 0; relative < 2; ++relative) 1403 for (int j = 0; j < test_loop_times; j++) 1404 { 1405 generateTestData(); 1406 1407 SCOPED_TRACE(relative ? "NORM_RELATIVE" : ""); 1408 1409 int type = NORM_L2; 1410 if (relative == 1) 1411 type |= NORM_RELATIVE; 1412 1413 OCL_OFF(const double cpuRes = cv::norm(src1_roi, src2_roi, type, mask_roi)); 1414 OCL_ON(const double gpuRes = cv::norm(usrc1_roi, usrc2_roi, type, umask_roi)); 1415 1416 EXPECT_PRED3(relativeError, cpuRes, gpuRes, 1e-6); 1417 } 1418 } 1419 1420 //////////////////////////////// UMat::dot //////////////////////////////////////////////// 1421 1422 typedef ArithmTestBase UMatDot; 1423 1424 OCL_TEST_P(UMatDot, Mat) 1425 { 1426 for (int j = 0; j < test_loop_times; j++) 1427 { 1428 generateTestData(); 1429 1430 OCL_OFF(const double cpuRes = src1_roi.dot(src2_roi)); 1431 OCL_ON(const double gpuRes = usrc1_roi.dot(usrc2_roi)); 1432 1433 EXPECT_PRED3(relativeError, cpuRes, gpuRes, 1e-5); 1434 } 1435 } 1436 1437 //////////////////////////////// Sqrt //////////////////////////////////////////////// 1438 1439 typedef ArithmTestBase Sqrt; 1440 1441 OCL_TEST_P(Sqrt, Mat) 1442 { 1443 for (int j = 0; j < test_loop_times; j++) 1444 { 1445 generateTestData(); 1446 1447 OCL_OFF(cv::sqrt(src1_roi, dst1_roi)); 1448 OCL_ON(cv::sqrt(usrc1_roi, udst1_roi)); 1449 1450 Near(1); 1451 } 1452 } 1453 1454 //////////////////////////////// Normalize //////////////////////////////////////////////// 1455 1456 typedef ArithmTestBase Normalize; 1457 1458 OCL_TEST_P(Normalize, Mat) 1459 { 1460 static int modes[] = { CV_MINMAX, CV_L2, CV_L1, CV_C }; 1461 1462 for (int j = 0; j < test_loop_times; j++) 1463 { 1464 generateTestData(); 1465 1466 for (int i = 0, size = sizeof(modes) / sizeof(modes[0]); i < size; ++i) 1467 { 1468 OCL_OFF(cv::normalize(src1_roi, dst1_roi, 10, 110, modes[i], src1_roi.type(), mask_roi)); 1469 OCL_ON(cv::normalize(usrc1_roi, udst1_roi, 10, 110, modes[i], src1_roi.type(), umask_roi)); 1470 1471 Near(1); 1472 } 1473 } 1474 } 1475 1476 //////////////////////////////////////// InRange /////////////////////////////////////////////// 1477 1478 PARAM_TEST_CASE(InRange, MatDepth, Channels, bool /*Scalar or not*/, bool /*Roi*/) 1479 { 1480 int depth; 1481 int cn; 1482 bool scalars, use_roi; 1483 cv::Scalar val1, val2; 1484 1485 TEST_DECLARE_INPUT_PARAMETER(src1); 1486 TEST_DECLARE_INPUT_PARAMETER(src2); 1487 TEST_DECLARE_INPUT_PARAMETER(src3); 1488 TEST_DECLARE_OUTPUT_PARAMETER(dst); 1489 1490 virtual void SetUp() 1491 { 1492 depth = GET_PARAM(0); 1493 cn = GET_PARAM(1); 1494 scalars = GET_PARAM(2); 1495 use_roi = GET_PARAM(3); 1496 } 1497 1498 virtual void generateTestData() 1499 { 1500 const int type = CV_MAKE_TYPE(depth, cn); 1501 1502 Size roiSize = randomSize(1, MAX_VALUE); 1503 Border src1Border = randomBorder(0, use_roi ? MAX_VALUE : 0); 1504 randomSubMat(src1, src1_roi, roiSize, src1Border, type, -40, 40); 1505 1506 Border src2Border = randomBorder(0, use_roi ? MAX_VALUE : 0); 1507 randomSubMat(src2, src2_roi, roiSize, src2Border, type, -40, 40); 1508 1509 Border src3Border = randomBorder(0, use_roi ? MAX_VALUE : 0); 1510 randomSubMat(src3, src3_roi, roiSize, src3Border, type, -40, 40); 1511 1512 Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); 1513 randomSubMat(dst, dst_roi, roiSize, dstBorder, CV_8UC1, 5, 16); 1514 1515 val1 = cv::Scalar(rng.uniform(-100.0, 100.0), rng.uniform(-100.0, 100.0), 1516 rng.uniform(-100.0, 100.0), rng.uniform(-100.0, 100.0)); 1517 val2 = cv::Scalar(rng.uniform(-100.0, 100.0), rng.uniform(-100.0, 100.0), 1518 rng.uniform(-100.0, 100.0), rng.uniform(-100.0, 100.0)); 1519 1520 UMAT_UPLOAD_INPUT_PARAMETER(src1); 1521 UMAT_UPLOAD_INPUT_PARAMETER(src2); 1522 UMAT_UPLOAD_INPUT_PARAMETER(src3); 1523 UMAT_UPLOAD_OUTPUT_PARAMETER(dst); 1524 } 1525 1526 void Near() 1527 { 1528 OCL_EXPECT_MATS_NEAR(dst, 0); 1529 } 1530 }; 1531 1532 OCL_TEST_P(InRange, Mat) 1533 { 1534 for (int j = 0; j < test_loop_times; j++) 1535 { 1536 generateTestData(); 1537 1538 OCL_OFF(cv::inRange(src1_roi, src2_roi, src3_roi, dst_roi)); 1539 OCL_ON(cv::inRange(usrc1_roi, usrc2_roi, usrc3_roi, udst_roi)); 1540 1541 Near(); 1542 } 1543 } 1544 1545 OCL_TEST_P(InRange, Scalar) 1546 { 1547 for (int j = 0; j < test_loop_times; j++) 1548 { 1549 generateTestData(); 1550 1551 OCL_OFF(cv::inRange(src1_roi, val1, val2, dst_roi)); 1552 OCL_ON(cv::inRange(usrc1_roi, val1, val2, udst_roi)); 1553 1554 Near(); 1555 } 1556 } 1557 1558 //////////////////////////////// ConvertScaleAbs //////////////////////////////////////////////// 1559 1560 PARAM_TEST_CASE(ConvertScaleAbs, MatDepth, Channels, bool) 1561 { 1562 int depth; 1563 int cn; 1564 bool use_roi; 1565 cv::Scalar val; 1566 1567 TEST_DECLARE_INPUT_PARAMETER(src); 1568 TEST_DECLARE_OUTPUT_PARAMETER(dst); 1569 1570 virtual void SetUp() 1571 { 1572 depth = GET_PARAM(0); 1573 cn = GET_PARAM(1); 1574 use_roi = GET_PARAM(2); 1575 } 1576 1577 virtual void generateTestData() 1578 { 1579 const int stype = CV_MAKE_TYPE(depth, cn); 1580 const int dtype = CV_MAKE_TYPE(CV_8U, cn); 1581 1582 Size roiSize = randomSize(1, MAX_VALUE); 1583 Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); 1584 randomSubMat(src, src_roi, roiSize, srcBorder, stype, -11, 11); // FIXIT: Test with minV, maxV 1585 1586 Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); 1587 randomSubMat(dst, dst_roi, roiSize, dstBorder, dtype, 5, 16); 1588 1589 val = cv::Scalar(rng.uniform(-100.0, 100.0), rng.uniform(-100.0, 100.0), 1590 rng.uniform(-100.0, 100.0), rng.uniform(-100.0, 100.0)); 1591 1592 UMAT_UPLOAD_INPUT_PARAMETER(src); 1593 UMAT_UPLOAD_OUTPUT_PARAMETER(dst); 1594 } 1595 1596 void Near(double threshold = 0.) 1597 { 1598 OCL_EXPECT_MATS_NEAR(dst, threshold); 1599 } 1600 1601 }; 1602 1603 1604 OCL_TEST_P(ConvertScaleAbs, Mat) 1605 { 1606 for (int j = 0; j < test_loop_times; j++) 1607 { 1608 generateTestData(); 1609 1610 OCL_OFF(cv::convertScaleAbs(src_roi, dst_roi, val[0], val[1])); 1611 OCL_ON(cv::convertScaleAbs(usrc_roi, udst_roi, val[0], val[1])); 1612 1613 Near(1); 1614 } 1615 } 1616 1617 //////////////////////////////// ScaleAdd //////////////////////////////////////////////// 1618 1619 typedef ArithmTestBase ScaleAdd; 1620 1621 OCL_TEST_P(ScaleAdd, Mat) 1622 { 1623 for (int j = 0; j < test_loop_times; j++) 1624 { 1625 generateTestData(); 1626 1627 OCL_OFF(cv::scaleAdd(src1_roi, val[0], src2_roi, dst1_roi)); 1628 OCL_ON(cv::scaleAdd(usrc1_roi, val[0], usrc2_roi, udst1_roi)); 1629 1630 Near(depth <= CV_32S ? 1 : 1e-3); 1631 } 1632 } 1633 1634 //////////////////////////////// PatchNans //////////////////////////////////////////////// 1635 1636 PARAM_TEST_CASE(PatchNaNs, Channels, bool) 1637 { 1638 int cn; 1639 bool use_roi; 1640 double value; 1641 1642 TEST_DECLARE_INPUT_PARAMETER(src); 1643 1644 virtual void SetUp() 1645 { 1646 cn = GET_PARAM(0); 1647 use_roi = GET_PARAM(1); 1648 } 1649 1650 virtual void generateTestData() 1651 { 1652 const int type = CV_MAKE_TYPE(CV_32F, cn); 1653 1654 Size roiSize = randomSize(1, 10); 1655 Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); 1656 randomSubMat(src, src_roi, roiSize, srcBorder, type, -40, 40); 1657 1658 // generating NaNs 1659 roiSize.width *= cn; 1660 for (int y = 0; y < roiSize.height; ++y) 1661 { 1662 float * const ptr = src_roi.ptr<float>(y); 1663 for (int x = 0; x < roiSize.width; ++x) 1664 ptr[x] = randomInt(-1, 1) == 0 ? std::numeric_limits<float>::quiet_NaN() : ptr[x]; 1665 } 1666 1667 value = randomDouble(-100, 100); 1668 1669 UMAT_UPLOAD_INPUT_PARAMETER(src); 1670 } 1671 1672 void Near() 1673 { 1674 OCL_EXPECT_MATS_NEAR(src, 0); 1675 } 1676 }; 1677 1678 OCL_TEST_P(PatchNaNs, Mat) 1679 { 1680 for (int j = 0; j < test_loop_times; j++) 1681 { 1682 generateTestData(); 1683 1684 OCL_OFF(cv::patchNaNs(src_roi, value)); 1685 OCL_ON(cv::patchNaNs(usrc_roi, value)); 1686 1687 Near(); 1688 } 1689 } 1690 1691 //////////////////////////////// Psnr //////////////////////////////////////////////// 1692 1693 typedef ArithmTestBase Psnr; 1694 1695 OCL_TEST_P(Psnr, Mat) 1696 { 1697 for (int j = 0; j < test_loop_times; j++) 1698 { 1699 generateTestData(); 1700 1701 double cpuRes = 0, gpuRes = 0; 1702 1703 OCL_OFF(cpuRes = cv::PSNR(src1_roi, src2_roi)); 1704 OCL_ON(gpuRes = cv::PSNR(usrc1_roi, usrc2_roi)); 1705 1706 EXPECT_PRED3(relativeError, cpuRes, gpuRes, 1e-6); 1707 } 1708 } 1709 1710 //////////////////////////////////////// Reduce ///////////////////////////////////////////// 1711 1712 PARAM_TEST_CASE(Reduce, std::pair<MatDepth, MatDepth>, Channels, int, bool) 1713 { 1714 int sdepth, ddepth, cn, dim, dtype; 1715 bool use_roi; 1716 1717 TEST_DECLARE_INPUT_PARAMETER(src); 1718 TEST_DECLARE_OUTPUT_PARAMETER(dst); 1719 1720 virtual void SetUp() 1721 { 1722 const std::pair<MatDepth, MatDepth> p = GET_PARAM(0); 1723 sdepth = p.first; 1724 ddepth = p.second; 1725 cn = GET_PARAM(1); 1726 dim = GET_PARAM(2); 1727 use_roi = GET_PARAM(3); 1728 } 1729 1730 virtual void generateTestData() 1731 { 1732 const int stype = CV_MAKE_TYPE(sdepth, cn); 1733 dtype = CV_MAKE_TYPE(ddepth, cn); 1734 1735 Size roiSize = randomSize(1, MAX_VALUE); 1736 Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); 1737 randomSubMat(src, src_roi, roiSize, srcBorder, stype, -40, 40); 1738 1739 Size dstRoiSize = Size(dim == 0 ? roiSize.width : 1, dim == 0 ? 1 : roiSize.height); 1740 Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); 1741 randomSubMat(dst, dst_roi, dstRoiSize, dstBorder, dtype, 5, 16); 1742 1743 UMAT_UPLOAD_INPUT_PARAMETER(src); 1744 UMAT_UPLOAD_OUTPUT_PARAMETER(dst); 1745 } 1746 }; 1747 1748 typedef Reduce ReduceSum; 1749 1750 OCL_TEST_P(ReduceSum, Mat) 1751 { 1752 for (int j = 0; j < test_loop_times; j++) 1753 { 1754 generateTestData(); 1755 1756 OCL_OFF(cv::reduce(src_roi, dst_roi, dim, CV_REDUCE_SUM, dtype)); 1757 OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_SUM, dtype)); 1758 1759 double eps = ddepth <= CV_32S ? 1 : 7e-4; 1760 OCL_EXPECT_MATS_NEAR(dst, eps); 1761 } 1762 } 1763 1764 typedef Reduce ReduceMax; 1765 1766 OCL_TEST_P(ReduceMax, Mat) 1767 { 1768 for (int j = 0; j < test_loop_times; j++) 1769 { 1770 generateTestData(); 1771 1772 OCL_OFF(cv::reduce(src_roi, dst_roi, dim, CV_REDUCE_MAX, dtype)); 1773 OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_MAX, dtype)); 1774 1775 OCL_EXPECT_MATS_NEAR(dst, 0); 1776 } 1777 } 1778 1779 typedef Reduce ReduceMin; 1780 1781 OCL_TEST_P(ReduceMin, Mat) 1782 { 1783 for (int j = 0; j < test_loop_times; j++) 1784 { 1785 generateTestData(); 1786 1787 OCL_OFF(cv::reduce(src_roi, dst_roi, dim, CV_REDUCE_MIN, dtype)); 1788 OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_MIN, dtype)); 1789 1790 OCL_EXPECT_MATS_NEAR(dst, 0); 1791 } 1792 } 1793 1794 typedef Reduce ReduceAvg; 1795 1796 OCL_TEST_P(ReduceAvg, Mat) 1797 { 1798 for (int j = 0; j < test_loop_times; j++) 1799 { 1800 generateTestData(); 1801 1802 OCL_OFF(cv::reduce(src_roi, dst_roi, dim, CV_REDUCE_AVG, dtype)); 1803 OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_AVG, dtype)); 1804 1805 double eps = ddepth <= CV_32S ? 1 : 6e-6; 1806 OCL_EXPECT_MATS_NEAR(dst, eps); 1807 } 1808 } 1809 1810 //////////////////////////////////////// Instantiation ///////////////////////////////////////// 1811 1812 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Lut, Combine(::testing::Values(CV_8U, CV_8S), OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool(), Bool())); 1813 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Add, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1814 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Subtract, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1815 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Mul, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1816 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Div, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1817 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Min, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1818 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Max, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1819 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Absdiff, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1820 OCL_INSTANTIATE_TEST_CASE_P(Arithm, CartToPolar, Combine(testing::Values(CV_32F, CV_64F), OCL_ALL_CHANNELS, Bool())); 1821 OCL_INSTANTIATE_TEST_CASE_P(Arithm, PolarToCart, Combine(testing::Values(CV_32F, CV_64F), OCL_ALL_CHANNELS, Bool())); 1822 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Transpose, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1823 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Bitwise_and, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1824 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Bitwise_not, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1825 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Bitwise_xor, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1826 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Bitwise_or, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1827 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Pow, Combine(testing::Values(CV_32F, CV_64F), OCL_ALL_CHANNELS, Bool())); 1828 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Compare, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1829 OCL_INSTANTIATE_TEST_CASE_P(Arithm, AddWeighted, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1830 OCL_INSTANTIATE_TEST_CASE_P(Arithm, SetIdentity, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1831 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Repeat, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1832 OCL_INSTANTIATE_TEST_CASE_P(Arithm, CountNonZero, Combine(OCL_ALL_DEPTHS, testing::Values(Channels(1)), Bool())); 1833 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Sum, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1834 OCL_INSTANTIATE_TEST_CASE_P(Arithm, MeanStdDev, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1835 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Log, Combine(::testing::Values(CV_32F, CV_64F), OCL_ALL_CHANNELS, Bool())); 1836 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Exp, Combine(::testing::Values(CV_32F, CV_64F), OCL_ALL_CHANNELS, Bool())); 1837 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Phase, Combine(::testing::Values(CV_32F, CV_64F), OCL_ALL_CHANNELS, Bool())); 1838 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Magnitude, Combine(::testing::Values(CV_32F, CV_64F), OCL_ALL_CHANNELS, Bool())); 1839 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Flip, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1840 OCL_INSTANTIATE_TEST_CASE_P(Arithm, MinMaxIdx, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1841 OCL_INSTANTIATE_TEST_CASE_P(Arithm, MinMaxIdx_Mask, Combine(OCL_ALL_DEPTHS, ::testing::Values(Channels(1)), Bool())); 1842 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Norm, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1843 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Sqrt, Combine(::testing::Values(CV_32F, CV_64F), OCL_ALL_CHANNELS, Bool())); 1844 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Normalize, Combine(OCL_ALL_DEPTHS, Values(Channels(1)), Bool())); 1845 OCL_INSTANTIATE_TEST_CASE_P(Arithm, InRange, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool(), Bool())); 1846 OCL_INSTANTIATE_TEST_CASE_P(Arithm, ConvertScaleAbs, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1847 OCL_INSTANTIATE_TEST_CASE_P(Arithm, ScaleAdd, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1848 OCL_INSTANTIATE_TEST_CASE_P(Arithm, PatchNaNs, Combine(OCL_ALL_CHANNELS, Bool())); 1849 OCL_INSTANTIATE_TEST_CASE_P(Arithm, Psnr, Combine(::testing::Values((MatDepth)CV_8U), OCL_ALL_CHANNELS, Bool())); 1850 OCL_INSTANTIATE_TEST_CASE_P(Arithm, UMatDot, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool())); 1851 1852 OCL_INSTANTIATE_TEST_CASE_P(Arithm, ReduceSum, Combine(testing::Values(std::make_pair<MatDepth, MatDepth>(CV_8U, CV_32S), 1853 std::make_pair<MatDepth, MatDepth>(CV_8U, CV_32F), 1854 std::make_pair<MatDepth, MatDepth>(CV_8U, CV_64F), 1855 std::make_pair<MatDepth, MatDepth>(CV_16U, CV_32F), 1856 std::make_pair<MatDepth, MatDepth>(CV_16U, CV_64F), 1857 std::make_pair<MatDepth, MatDepth>(CV_16S, CV_32F), 1858 std::make_pair<MatDepth, MatDepth>(CV_16S, CV_64F), 1859 std::make_pair<MatDepth, MatDepth>(CV_32F, CV_32F), 1860 std::make_pair<MatDepth, MatDepth>(CV_32F, CV_64F), 1861 std::make_pair<MatDepth, MatDepth>(CV_64F, CV_64F)), 1862 OCL_ALL_CHANNELS, testing::Values(0, 1), Bool())); 1863 OCL_INSTANTIATE_TEST_CASE_P(Arithm, ReduceAvg, Combine(testing::Values(std::make_pair<MatDepth, MatDepth>(CV_8U, CV_32S), 1864 std::make_pair<MatDepth, MatDepth>(CV_8U, CV_32F), 1865 std::make_pair<MatDepth, MatDepth>(CV_8U, CV_64F), 1866 std::make_pair<MatDepth, MatDepth>(CV_16U, CV_32F), 1867 std::make_pair<MatDepth, MatDepth>(CV_16U, CV_64F), 1868 std::make_pair<MatDepth, MatDepth>(CV_16S, CV_32F), 1869 std::make_pair<MatDepth, MatDepth>(CV_16S, CV_64F), 1870 std::make_pair<MatDepth, MatDepth>(CV_32F, CV_32F), 1871 std::make_pair<MatDepth, MatDepth>(CV_32F, CV_64F), 1872 std::make_pair<MatDepth, MatDepth>(CV_64F, CV_64F)), 1873 OCL_ALL_CHANNELS, testing::Values(0, 1), Bool())); 1874 OCL_INSTANTIATE_TEST_CASE_P(Arithm, ReduceMax, Combine(testing::Values(std::make_pair<MatDepth, MatDepth>(CV_8U, CV_8U), 1875 std::make_pair<MatDepth, MatDepth>(CV_16U, CV_16U), 1876 std::make_pair<MatDepth, MatDepth>(CV_16S, CV_16S), 1877 std::make_pair<MatDepth, MatDepth>(CV_32F, CV_32F), 1878 std::make_pair<MatDepth, MatDepth>(CV_64F, CV_64F)), 1879 OCL_ALL_CHANNELS, testing::Values(0, 1), Bool())); 1880 OCL_INSTANTIATE_TEST_CASE_P(Arithm, ReduceMin, Combine(testing::Values(std::make_pair<MatDepth, MatDepth>(CV_8U, CV_8U), 1881 std::make_pair<MatDepth, MatDepth>(CV_16U, CV_16U), 1882 std::make_pair<MatDepth, MatDepth>(CV_16S, CV_16S), 1883 std::make_pair<MatDepth, MatDepth>(CV_32F, CV_32F), 1884 std::make_pair<MatDepth, MatDepth>(CV_64F, CV_64F)), 1885 OCL_ALL_CHANNELS, testing::Values(0, 1), Bool())); 1886 1887 1888 } } // namespace cvtest::ocl 1889 1890 #endif // HAVE_OPENCL 1891