test_filters.cpp 16.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
/*M///////////////////////////////////////////////////////////////////////////////////////
//
//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
//  By downloading, copying, installing or using the software you agree to this license.
//  If you do not agree to this license, do not download, install,
//  copy or use the software.
//
//
//                        Intel License Agreement
//                For Open Source Computer Vision Library
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//   * Redistribution's of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//
//   * Redistribution's in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//
//   * The name of Intel Corporation may not be used to endorse or promote products
//     derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/

#include "test_precomp.hpp"

44
#ifdef HAVE_CUDA
45

46 47 48
using namespace cvtest;
using namespace testing;

49
namespace
50
{
51
    double checkNorm(const cv::Mat& m1, const cv::Mat& m2, const cv::Size& ksize)
52
    {
53 54 55 56
        cv::Rect roi(ksize.width, ksize.height, m1.cols - 2 * ksize.width, m1.rows - 2 * ksize.height);
        cv::Mat m1ROI = m1(roi);
        cv::Mat m2ROI = m2(roi);
        return ::checkNorm(m1ROI, m2ROI);
57 58
    }

59
    double checkNorm(const cv::Mat& m1, const cv::Mat& m2, int ksize)
60
    {
61
        return checkNorm(m1, m2, cv::Size(ksize, ksize));
62
    }
63 64 65 66 67 68 69
}

#define EXPECT_MAT_NEAR_KSIZE(mat1, mat2, ksize, eps) \
    { \
        ASSERT_EQ(mat1.type(), mat2.type()); \
        ASSERT_EQ(mat1.size(), mat2.size()); \
        EXPECT_LE(checkNorm(mat1, mat2, ksize), eps); \
70 71
    }

72 73 74
/////////////////////////////////////////////////////////////////////////////////////////////////
// blur

75
PARAM_TEST_CASE(Blur, cv::gpu::DeviceInfo, cv::Size, UseRoi)
76 77 78
{
    cv::gpu::DeviceInfo devInfo;
    cv::Size ksize;
79
    bool useRoi;
80 81 82
    
    cv::Mat img_rgba;
    cv::Mat img_gray;
83 84 85

    cv::Mat dst_gold_rgba;
    cv::Mat dst_gold_gray;
86
    
87
    virtual void SetUp()
88
    {
89 90 91
        devInfo = GET_PARAM(0);
        ksize = GET_PARAM(1);
        useRoi = GET_PARAM(2);
92 93

        cv::gpu::setDevice(devInfo.deviceID());
94 95 96 97 98 99
                
        cv::Mat img = readImage("stereobp/aloe-L.png");
        ASSERT_FALSE(img.empty());
        
        cv::cvtColor(img, img_rgba, CV_BGR2BGRA);
        cv::cvtColor(img, img_gray, CV_BGR2GRAY);
100 101 102

        cv::blur(img_rgba, dst_gold_rgba, ksize);
        cv::blur(img_gray, dst_gold_gray, ksize);
103
    }
104 105
};

106
TEST_P(Blur, Rgba)
107 108
{
    cv::Mat dst_rgba;
109

V
Vladislav Vinogradov 已提交
110
    cv::gpu::GpuMat dev_dst_rgba;
111

V
Vladislav Vinogradov 已提交
112
    cv::gpu::blur(loadMat(img_rgba, useRoi), dev_dst_rgba, ksize);
113

V
Vladislav Vinogradov 已提交
114
    dev_dst_rgba.download(dst_rgba);
115

116
    EXPECT_MAT_NEAR_KSIZE(dst_gold_rgba, dst_rgba, ksize, 1.0);
117 118 119 120 121 122
}

TEST_P(Blur, Gray)
{
    cv::Mat dst_gray;

V
Vladislav Vinogradov 已提交
123
    cv::gpu::GpuMat dev_dst_gray;
124

V
Vladislav Vinogradov 已提交
125
    cv::gpu::blur(loadMat(img_gray, useRoi), dev_dst_gray, ksize);
126

V
Vladislav Vinogradov 已提交
127
    dev_dst_gray.download(dst_gray);
128

129
    EXPECT_MAT_NEAR_KSIZE(dst_gold_gray, dst_gray, ksize, 1.0);
130 131
}

132 133 134 135
INSTANTIATE_TEST_CASE_P(Filter, Blur, Combine(
                        ALL_DEVICES, 
                        Values(cv::Size(3, 3), cv::Size(5, 5), cv::Size(7, 7)),
                        USE_ROI));
136 137 138 139

/////////////////////////////////////////////////////////////////////////////////////////////////
// sobel

140
PARAM_TEST_CASE(Sobel, cv::gpu::DeviceInfo, int, int, int, UseRoi)
141
{
142 143
    cv::gpu::DeviceInfo devInfo;
    int ksize;
144 145 146
    int dx;
    int dy;
    bool useRoi;
147 148 149
    
    cv::Mat img_rgba;
    cv::Mat img_gray;
150 151 152 153 154

    cv::Mat dst_gold_rgba;
    cv::Mat dst_gold_gray;
    
    virtual void SetUp()
155
    {
156 157 158 159 160 161 162 163
        devInfo = GET_PARAM(0);
        ksize = GET_PARAM(1);
        dx = GET_PARAM(2);
        dy = GET_PARAM(3);
        useRoi = GET_PARAM(4);

        if (dx == 0 && dy == 0)
            return;
164

165 166
        cv::gpu::setDevice(devInfo.deviceID());
        
167 168 169 170 171 172
        cv::Mat img = readImage("stereobp/aloe-L.png");
        ASSERT_FALSE(img.empty());
        
        cv::cvtColor(img, img_rgba, CV_BGR2BGRA);
        cv::cvtColor(img, img_gray, CV_BGR2GRAY);
        
173 174 175 176 177
        cv::Sobel(img_rgba, dst_gold_rgba, -1, dx, dy, ksize);
        cv::Sobel(img_gray, dst_gold_gray, -1, dx, dy, ksize);
    }
};

178
TEST_P(Sobel, Rgba)
179
{
180 181
    if (dx == 0 && dy == 0)
        return;
182 183

    cv::Mat dst_rgba;
184

V
Vladislav Vinogradov 已提交
185
    cv::gpu::GpuMat dev_dst_rgba;
186

V
Vladislav Vinogradov 已提交
187
    cv::gpu::Sobel(loadMat(img_rgba, useRoi), dev_dst_rgba, -1, dx, dy, ksize);
188

V
Vladislav Vinogradov 已提交
189
    dev_dst_rgba.download(dst_rgba);
190

191
    EXPECT_MAT_NEAR_KSIZE(dst_gold_rgba, dst_rgba, ksize, 0.0);
192 193 194 195 196 197 198 199 200
}

TEST_P(Sobel, Gray)
{
    if (dx == 0 && dy == 0)
        return;

    cv::Mat dst_gray;

V
Vladislav Vinogradov 已提交
201
    cv::gpu::GpuMat dev_dst_gray;
202

V
Vladislav Vinogradov 已提交
203
    cv::gpu::Sobel(loadMat(img_gray, useRoi), dev_dst_gray, -1, dx, dy, ksize);
204

V
Vladislav Vinogradov 已提交
205
    dev_dst_gray.download(dst_gray);
206

207 208 209
    EXPECT_MAT_NEAR_KSIZE(dst_gold_gray, dst_gray, ksize, 0.0);
}

210 211 212 213 214 215
INSTANTIATE_TEST_CASE_P(Filter, Sobel, Combine(
                        ALL_DEVICES, 
                        Values(3, 5, 7), 
                        Values(0, 1, 2),
                        Values(0, 1, 2),
                        USE_ROI));
216

217 218 219
/////////////////////////////////////////////////////////////////////////////////////////////////
// scharr

220
PARAM_TEST_CASE(Scharr, cv::gpu::DeviceInfo, int, int, UseRoi)
221 222
{
    cv::gpu::DeviceInfo devInfo;
223 224 225
    int dx;
    int dy;
    bool useRoi;
226 227 228
    
    cv::Mat img_rgba;
    cv::Mat img_gray;
229

230 231 232 233 234
    cv::Mat dst_gold_rgba;
    cv::Mat dst_gold_gray;
    
    virtual void SetUp()
    {
235 236 237 238 239 240 241
        devInfo = GET_PARAM(0);
        dx = GET_PARAM(1);
        dy = GET_PARAM(2);
        useRoi = GET_PARAM(3);

        if (dx + dy != 1)
            return;
242 243

        cv::gpu::setDevice(devInfo.deviceID());
244 245 246 247 248 249
        
        cv::Mat img = readImage("stereobp/aloe-L.png");
        ASSERT_FALSE(img.empty());
        
        cv::cvtColor(img, img_rgba, CV_BGR2BGRA);
        cv::cvtColor(img, img_gray, CV_BGR2GRAY);
250 251 252

        cv::Scharr(img_rgba, dst_gold_rgba, -1, dx, dy);
        cv::Scharr(img_gray, dst_gold_gray, -1, dx, dy);
253 254 255
    }
};

256
TEST_P(Scharr, Rgba)
257
{
258 259
    if (dx + dy != 1)
        return;
260

261
    cv::Mat dst_rgba;
262

V
Vladislav Vinogradov 已提交
263
    cv::gpu::GpuMat dev_dst_rgba;
264

V
Vladislav Vinogradov 已提交
265
    cv::gpu::Scharr(loadMat(img_rgba, useRoi), dev_dst_rgba, -1, dx, dy);
266

V
Vladislav Vinogradov 已提交
267
    dev_dst_rgba.download(dst_rgba);
268

269
    EXPECT_MAT_NEAR_KSIZE(dst_gold_rgba, dst_rgba, 3, 0.0);
270 271 272 273 274 275 276 277 278
}

TEST_P(Scharr, Gray)
{
    if (dx + dy != 1)
        return;

    cv::Mat dst_gray;

V
Vladislav Vinogradov 已提交
279
    cv::gpu::GpuMat dev_dst_gray;
280

V
Vladislav Vinogradov 已提交
281
    cv::gpu::Scharr(loadMat(img_gray, useRoi), dev_dst_gray, -1, dx, dy);
282

V
Vladislav Vinogradov 已提交
283
    dev_dst_gray.download(dst_gray);
284

285 286
    EXPECT_MAT_NEAR_KSIZE(dst_gold_gray, dst_gray, 3, 0.0);
}
287

288 289 290 291 292
INSTANTIATE_TEST_CASE_P(Filter, Scharr, Combine(
                        ALL_DEVICES, 
                        Values(0, 1),
                        Values(0, 1),
                        USE_ROI));
293

294 295
/////////////////////////////////////////////////////////////////////////////////////////////////
// gaussianBlur
296

297
PARAM_TEST_CASE(GaussianBlur, cv::gpu::DeviceInfo, cv::Size, UseRoi)
298
{
299 300
    cv::gpu::DeviceInfo devInfo;
    cv::Size ksize;
301
    bool useRoi;
302 303 304
    
    cv::Mat img_rgba;
    cv::Mat img_gray;
305 306

    double sigma1, sigma2;
307

308 309 310 311
    cv::Mat dst_gold_rgba;
    cv::Mat dst_gold_gray;
    
    virtual void SetUp()
312
    {
313 314 315
        devInfo = GET_PARAM(0);
        ksize = GET_PARAM(1);
        useRoi = GET_PARAM(2);
316

317 318
        cv::gpu::setDevice(devInfo.deviceID());
        
319 320 321 322 323 324
        cv::Mat img = readImage("stereobp/aloe-L.png");
        ASSERT_FALSE(img.empty());
        
        cv::cvtColor(img, img_rgba, CV_BGR2BGRA);
        cv::cvtColor(img, img_gray, CV_BGR2GRAY);
        
325
        cv::RNG& rng = cvtest::TS::ptr()->get_rng();
326

327 328 329 330 331
        sigma1 = rng.uniform(0.1, 1.0); 
        sigma2 = rng.uniform(0.1, 1.0);
        
        cv::GaussianBlur(img_rgba, dst_gold_rgba, ksize, sigma1, sigma2);
        cv::GaussianBlur(img_gray, dst_gold_gray, ksize, sigma1, sigma2);
332 333 334
    }
};

335
TEST_P(GaussianBlur, Rgba)
336
{
337
    cv::Mat dst_rgba;
338

V
Vladislav Vinogradov 已提交
339
    cv::gpu::GpuMat dev_dst_rgba;
340

V
Vladislav Vinogradov 已提交
341
    cv::gpu::GaussianBlur(loadMat(img_rgba, useRoi), dev_dst_rgba, ksize, sigma1, sigma2);
342

V
Vladislav Vinogradov 已提交
343
    dev_dst_rgba.download(dst_rgba);
344

345
    EXPECT_MAT_NEAR_KSIZE(dst_gold_rgba, dst_rgba, ksize, 3.0);
346 347 348 349 350 351
}

TEST_P(GaussianBlur, Gray)
{
    cv::Mat dst_gray;

V
Vladislav Vinogradov 已提交
352
    cv::gpu::GpuMat dev_dst_gray;
353

V
Vladislav Vinogradov 已提交
354
    cv::gpu::GaussianBlur(loadMat(img_gray, useRoi), dev_dst_gray, ksize, sigma1, sigma2);
355

V
Vladislav Vinogradov 已提交
356
    dev_dst_gray.download(dst_gray);
357

358 359 360
    EXPECT_MAT_NEAR_KSIZE(dst_gold_gray, dst_gray, ksize, 3.0);
}

361 362 363 364
INSTANTIATE_TEST_CASE_P(Filter, GaussianBlur, Combine(
                        ALL_DEVICES, 
                        Values(cv::Size(3, 3), cv::Size(5, 5), cv::Size(7, 7)),
                        USE_ROI));
365

366 367 368
/////////////////////////////////////////////////////////////////////////////////////////////////
// laplacian

369
PARAM_TEST_CASE(Laplacian, cv::gpu::DeviceInfo, int, UseRoi)
370 371 372
{
    cv::gpu::DeviceInfo devInfo;
    int ksize;
373
    bool useRoi;
374 375 376
    
    cv::Mat img_rgba;
    cv::Mat img_gray;
377 378 379 380 381 382

    cv::Mat dst_gold_rgba;
    cv::Mat dst_gold_gray;
    
    virtual void SetUp()
    {
383 384 385
        devInfo = GET_PARAM(0);
        ksize = GET_PARAM(1);
        useRoi = GET_PARAM(2);
386

387
        cv::gpu::setDevice(devInfo.deviceID());
388 389 390 391 392 393
        
        cv::Mat img = readImage("stereobp/aloe-L.png");
        ASSERT_FALSE(img.empty());
        
        cv::cvtColor(img, img_rgba, CV_BGR2BGRA);
        cv::cvtColor(img, img_gray, CV_BGR2GRAY);
394

395 396
        cv::Laplacian(img_rgba, dst_gold_rgba, -1, ksize);
        cv::Laplacian(img_gray, dst_gold_gray, -1, ksize);
397 398 399
    }
};

400
TEST_P(Laplacian, Rgba)
401
{
402
    cv::Mat dst_rgba;
403

V
Vladislav Vinogradov 已提交
404
    cv::gpu::GpuMat dev_dst_rgba;
405

V
Vladislav Vinogradov 已提交
406
    cv::gpu::Laplacian(loadMat(img_rgba, useRoi), dev_dst_rgba, -1, ksize);
407

V
Vladislav Vinogradov 已提交
408
    dev_dst_rgba.download(dst_rgba);
409

410
    EXPECT_MAT_NEAR_KSIZE(dst_gold_rgba, dst_rgba, 3, 0.0);
411 412 413 414 415 416
}

TEST_P(Laplacian, Gray)
{
    cv::Mat dst_gray;

V
Vladislav Vinogradov 已提交
417
    cv::gpu::GpuMat dev_dst_gray;
418

V
Vladislav Vinogradov 已提交
419
    cv::gpu::Laplacian(loadMat(img_gray, useRoi), dev_dst_gray, -1, ksize);
420

V
Vladislav Vinogradov 已提交
421
    dev_dst_gray.download(dst_gray);
422

423 424
    EXPECT_MAT_NEAR_KSIZE(dst_gold_gray, dst_gray, 3, 0.0);
}
425

426 427 428 429
INSTANTIATE_TEST_CASE_P(Filter, Laplacian, Combine(
                        ALL_DEVICES,
                        Values(1, 3),
                        USE_ROI));
430 431 432

/////////////////////////////////////////////////////////////////////////////////////////////////
// erode
433

434
PARAM_TEST_CASE(Erode, cv::gpu::DeviceInfo, UseRoi)
435
{
436
    cv::gpu::DeviceInfo devInfo;
437
    bool useRoi;
438 439 440
    
    cv::Mat img_rgba;
    cv::Mat img_gray;
441 442

    cv::Mat kernel;
443

444 445 446 447
    cv::Mat dst_gold_rgba;
    cv::Mat dst_gold_gray;
    
    virtual void SetUp()
448
    {
449 450
        devInfo = GET_PARAM(0);
        useRoi = GET_PARAM(1);
451

452
        cv::gpu::setDevice(devInfo.deviceID());
453

454
        kernel = cv::Mat::ones(3, 3, CV_8U);
455 456 457 458 459 460
        
        cv::Mat img = readImage("stereobp/aloe-L.png");
        ASSERT_FALSE(img.empty());
        
        cv::cvtColor(img, img_rgba, CV_BGR2BGRA);
        cv::cvtColor(img, img_gray, CV_BGR2GRAY);
461

462 463
        cv::erode(img_rgba, dst_gold_rgba, kernel);
        cv::erode(img_gray, dst_gold_gray, kernel);
464 465 466
    }
};

467
TEST_P(Erode, Rgba)
468 469 470
{
    cv::Mat dst_rgba;

V
Vladislav Vinogradov 已提交
471
    cv::gpu::GpuMat dev_dst_rgba;
472

V
Vladislav Vinogradov 已提交
473
    cv::gpu::erode(loadMat(img_rgba, useRoi), dev_dst_rgba, kernel);
474

V
Vladislav Vinogradov 已提交
475
    dev_dst_rgba.download(dst_rgba);
476 477

    EXPECT_MAT_NEAR_KSIZE(dst_gold_rgba, dst_rgba, 3, 0.0);
478 479 480 481 482 483
}

TEST_P(Erode, Gray)
{
    cv::Mat dst_gray;

V
Vladislav Vinogradov 已提交
484
    cv::gpu::GpuMat dev_dst_gray;
485

V
Vladislav Vinogradov 已提交
486
    cv::gpu::erode(loadMat(img_gray, useRoi), dev_dst_gray, kernel);
487

V
Vladislav Vinogradov 已提交
488
    dev_dst_gray.download(dst_gray);
489

490 491 492
    EXPECT_MAT_NEAR_KSIZE(dst_gold_gray, dst_gray, 3, 0.0);
}

493 494 495
INSTANTIATE_TEST_CASE_P(Filter, Erode, Combine(
                        ALL_DEVICES,
                        USE_ROI));
496 497 498 499

/////////////////////////////////////////////////////////////////////////////////////////////////
// dilate

500
PARAM_TEST_CASE(Dilate, cv::gpu::DeviceInfo, UseRoi)
501
{
502
    cv::gpu::DeviceInfo devInfo;
503
    bool useRoi;
504 505 506
    
    cv::Mat img_rgba;
    cv::Mat img_gray;
507 508

    cv::Mat kernel;
509

510 511 512 513
    cv::Mat dst_gold_rgba;
    cv::Mat dst_gold_gray;
    
    virtual void SetUp()
514
    {
515 516
        devInfo = GET_PARAM(0);
        useRoi = GET_PARAM(1);
517

518
        cv::gpu::setDevice(devInfo.deviceID());
519

520
        kernel = cv::Mat::ones(3, 3, CV_8U);
521 522 523 524 525 526
        
        cv::Mat img = readImage("stereobp/aloe-L.png");
        ASSERT_FALSE(img.empty());
        
        cv::cvtColor(img, img_rgba, CV_BGR2BGRA);
        cv::cvtColor(img, img_gray, CV_BGR2GRAY);
527 528 529

        cv::dilate(img_rgba, dst_gold_rgba, kernel);
        cv::dilate(img_gray, dst_gold_gray, kernel);
530 531 532
    }
};

533
TEST_P(Dilate, Rgba)
534
{
535 536
    cv::Mat dst_rgba;

V
Vladislav Vinogradov 已提交
537
    cv::gpu::GpuMat dev_dst_rgba;
538

V
Vladislav Vinogradov 已提交
539
    cv::gpu::dilate(loadMat(img_rgba, useRoi), dev_dst_rgba, kernel);
540

V
Vladislav Vinogradov 已提交
541
    dev_dst_rgba.download(dst_rgba);
542

543
    EXPECT_MAT_NEAR_KSIZE(dst_gold_rgba, dst_rgba, 3, 0.0);
544 545 546 547 548 549
}

TEST_P(Dilate, Gray)
{
    cv::Mat dst_gray;

V
Vladislav Vinogradov 已提交
550
    cv::gpu::GpuMat dev_dst_gray;
551

V
Vladislav Vinogradov 已提交
552
    cv::gpu::dilate(loadMat(img_gray, useRoi), dev_dst_gray, kernel);
553

V
Vladislav Vinogradov 已提交
554
    dev_dst_gray.download(dst_gray);
555

556 557 558
    EXPECT_MAT_NEAR_KSIZE(dst_gold_gray, dst_gray, 3, 0.0);
}

559 560 561
INSTANTIATE_TEST_CASE_P(Filter, Dilate, Combine(
                        ALL_DEVICES,
                        USE_ROI));
562

563 564
/////////////////////////////////////////////////////////////////////////////////////////////////
// morphEx
565

566
PARAM_TEST_CASE(MorphEx, cv::gpu::DeviceInfo, MorphOp, UseRoi)
567 568
{
    cv::gpu::DeviceInfo devInfo;
569 570
    int morphOp;
    bool useRoi;
571 572 573
    
    cv::Mat img_rgba;
    cv::Mat img_gray;
574

575
    cv::Mat kernel;
576

577 578 579 580 581
    cv::Mat dst_gold_rgba;
    cv::Mat dst_gold_gray;
    
    virtual void SetUp()
    {
582 583 584
        devInfo = GET_PARAM(0);
        morphOp = GET_PARAM(1);
        useRoi = GET_PARAM(2);
585 586

        cv::gpu::setDevice(devInfo.deviceID());
587 588 589 590 591 592
        
        cv::Mat img = readImage("stereobp/aloe-L.png");
        ASSERT_FALSE(img.empty());
        
        cv::cvtColor(img, img_rgba, CV_BGR2BGRA);
        cv::cvtColor(img, img_gray, CV_BGR2GRAY);
593 594

        kernel = cv::Mat::ones(3, 3, CV_8U);
595
        
596 597
        cv::morphologyEx(img_rgba, dst_gold_rgba, morphOp, kernel);
        cv::morphologyEx(img_gray, dst_gold_gray, morphOp, kernel);
598 599 600
    }
};

601
TEST_P(MorphEx, Rgba)
602
{
603 604
    cv::Mat dst_rgba;

V
Vladislav Vinogradov 已提交
605
    cv::gpu::GpuMat dev_dst_rgba;
606

V
Vladislav Vinogradov 已提交
607
    cv::gpu::morphologyEx(loadMat(img_rgba, useRoi), dev_dst_rgba, morphOp, kernel);
608

V
Vladislav Vinogradov 已提交
609
    dev_dst_rgba.download(dst_rgba);
610 611 612 613 614 615

    EXPECT_MAT_NEAR_KSIZE(dst_gold_rgba, dst_rgba, 4, 0.0);
}

TEST_P(MorphEx, Gray)
{
616 617
    cv::Mat dst_gray;

V
Vladislav Vinogradov 已提交
618
    cv::gpu::GpuMat dev_dst_gray;
619

V
Vladislav Vinogradov 已提交
620
    cv::gpu::morphologyEx(loadMat(img_gray, useRoi), dev_dst_gray, morphOp, kernel);
621

V
Vladislav Vinogradov 已提交
622
    dev_dst_gray.download(dst_gray);
623 624 625 626

    EXPECT_MAT_NEAR_KSIZE(dst_gold_gray, dst_gray, 4, 0.0);
}

627 628 629 630
INSTANTIATE_TEST_CASE_P(Filter, MorphEx, Combine(
                        ALL_DEVICES,
                        Values((int)cv::MORPH_OPEN, (int)cv::MORPH_CLOSE, (int)cv::MORPH_GRADIENT, (int)cv::MORPH_TOPHAT, (int)cv::MORPH_BLACKHAT),
                        USE_ROI));
631

632
#endif // HAVE_CUDA