Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/gapi/test/common/gapi_imgproc_tests_inl.hpp
16339 views
1
// This file is part of OpenCV project.
2
// It is subject to the license terms in the LICENSE file found in the top-level directory
3
// of this distribution and at http://opencv.org/license.html.
4
//
5
// Copyright (C) 2018 Intel Corporation
6
7
8
#ifndef OPENCV_GAPI_IMGPROC_TESTS_INL_HPP
9
#define OPENCV_GAPI_IMGPROC_TESTS_INL_HPP
10
11
#include "opencv2/gapi/imgproc.hpp"
12
#include "gapi_imgproc_tests.hpp"
13
14
namespace opencv_test
15
{
16
TEST_P(Filter2DTest, AccuracyTest)
17
{
18
compare_f cmpF;
19
MatType type = 0;
20
int kernSize = 0, borderType = 0, dtype = 0;
21
cv::Size sz;
22
bool initOut = false;
23
cv::GCompileArgs compile_args;
24
std::tie(cmpF, type, kernSize, sz, borderType, dtype, initOut, compile_args) = GetParam();
25
initMatsRandN(type, sz, dtype, initOut);
26
27
cv::Point anchor = {-1, -1};
28
double delta = 0;
29
30
cv::Mat kernel = cv::Mat(kernSize, kernSize, CV_32FC1 );
31
cv::Scalar kernMean = cv::Scalar(1.0);
32
cv::Scalar kernStddev = cv::Scalar(2.0/3);
33
randn(kernel, kernMean, kernStddev);
34
35
// G-API code //////////////////////////////////////////////////////////////
36
cv::GMat in;
37
auto out = cv::gapi::filter2D(in, dtype, kernel, anchor, delta, borderType);
38
39
cv::GComputation c(in, out);
40
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
41
// OpenCV code /////////////////////////////////////////////////////////////
42
{
43
cv::filter2D(in_mat1, out_mat_ocv, dtype, kernel, anchor, delta, borderType);
44
}
45
// Comparison //////////////////////////////////////////////////////////////
46
{
47
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
48
EXPECT_EQ(out_mat_gapi.size(), sz);
49
}
50
}
51
52
TEST_P(BoxFilterTest, AccuracyTest)
53
{
54
compare_f cmpF;
55
MatType type = 0;
56
int filterSize = 0, borderType = 0, dtype = 0;
57
cv::Size sz;
58
bool initOut = false;
59
cv::GCompileArgs compile_args;
60
std::tie(cmpF, type, filterSize, sz, borderType, dtype, initOut, compile_args) = GetParam();
61
initMatsRandN(type, sz, dtype, initOut);
62
63
cv::Point anchor = {-1, -1};
64
bool normalize = true;
65
66
// G-API code //////////////////////////////////////////////////////////////
67
cv::GMat in;
68
auto out = cv::gapi::boxFilter(in, dtype, cv::Size(filterSize, filterSize), anchor, normalize, borderType);
69
70
cv::GComputation c(in, out);
71
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
72
// OpenCV code /////////////////////////////////////////////////////////////
73
{
74
cv::boxFilter(in_mat1, out_mat_ocv, dtype, cv::Size(filterSize, filterSize), anchor, normalize, borderType);
75
}
76
// Comparison //////////////////////////////////////////////////////////////
77
{
78
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
79
EXPECT_EQ(out_mat_gapi.size(), sz);
80
}
81
}
82
83
TEST_P(SepFilterTest, AccuracyTest)
84
{
85
compare_f cmpF;
86
MatType type = 0;
87
int kernSize = 0, dtype = 0;
88
cv::Size sz;
89
bool initOut = false;
90
cv::GCompileArgs compile_args;
91
std::tie(cmpF, type, kernSize, sz, dtype, initOut, compile_args) = GetParam();
92
93
cv::Mat kernelX(kernSize, 1, CV_32F);
94
cv::Mat kernelY(kernSize, 1, CV_32F);
95
randu(kernelX, -1, 1);
96
randu(kernelY, -1, 1);
97
initMatsRandN(type, sz, dtype, initOut);
98
99
cv::Point anchor = cv::Point(-1, -1);
100
101
// G-API code //////////////////////////////////////////////////////////////
102
cv::GMat in;
103
auto out = cv::gapi::sepFilter(in, dtype, kernelX, kernelY, anchor, cv::Scalar() );
104
105
cv::GComputation c(in, out);
106
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
107
// OpenCV code /////////////////////////////////////////////////////////////
108
{
109
cv::sepFilter2D(in_mat1, out_mat_ocv, dtype, kernelX, kernelY );
110
}
111
// Comparison //////////////////////////////////////////////////////////////
112
{
113
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
114
EXPECT_EQ(out_mat_gapi.size(), sz);
115
}
116
}
117
118
TEST_P(BlurTest, AccuracyTest)
119
{
120
compare_f cmpF;
121
MatType type = 0;
122
int filterSize = 0, borderType = 0;
123
cv::Size sz;
124
bool initOut = false;
125
cv::GCompileArgs compile_args;
126
std::tie(cmpF, type, filterSize, sz, borderType, initOut, compile_args) = GetParam();
127
initMatsRandN(type, sz, type, initOut);
128
129
cv::Point anchor = {-1, -1};
130
131
// G-API code //////////////////////////////////////////////////////////////
132
cv::GMat in;
133
auto out = cv::gapi::blur(in, cv::Size(filterSize, filterSize), anchor, borderType);
134
135
cv::GComputation c(in, out);
136
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
137
// OpenCV code /////////////////////////////////////////////////////////////
138
{
139
cv::blur(in_mat1, out_mat_ocv, cv::Size(filterSize, filterSize), anchor, borderType);
140
}
141
// Comparison //////////////////////////////////////////////////////////////
142
{
143
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
144
EXPECT_EQ(out_mat_gapi.size(), sz);
145
}
146
}
147
148
TEST_P(GaussianBlurTest, AccuracyTest)
149
{
150
compare_f cmpF;
151
MatType type = 0;
152
int kernSize = 0;
153
cv::Size sz;
154
bool initOut = false;
155
cv::GCompileArgs compile_args;
156
std::tie(cmpF,type, kernSize, sz, initOut, compile_args) = GetParam();
157
initMatsRandN(type, sz, type, initOut);
158
159
cv::Size kSize = cv::Size(kernSize, kernSize);
160
double sigmaX = rand();
161
162
// G-API code //////////////////////////////////////////////////////////////
163
cv::GMat in;
164
auto out = cv::gapi::gaussianBlur(in, kSize, sigmaX);
165
166
cv::GComputation c(in, out);
167
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
168
// OpenCV code /////////////////////////////////////////////////////////////
169
{
170
cv::GaussianBlur(in_mat1, out_mat_ocv, kSize, sigmaX);
171
}
172
// Comparison //////////////////////////////////////////////////////////////
173
{
174
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
175
EXPECT_EQ(out_mat_gapi.size(), sz);
176
}
177
}
178
179
TEST_P(MedianBlurTest, AccuracyTest)
180
{
181
compare_f cmpF;
182
MatType type = 0;
183
int kernSize = 0;
184
cv::Size sz;
185
bool initOut = false;
186
cv::GCompileArgs compile_args;
187
std::tie(cmpF, type, kernSize, sz, initOut, compile_args) = GetParam();
188
initMatsRandN(type, sz, type, initOut);
189
190
// G-API code //////////////////////////////////////////////////////////////
191
cv::GMat in;
192
auto out = cv::gapi::medianBlur(in, kernSize);
193
194
cv::GComputation c(in, out);
195
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
196
// OpenCV code /////////////////////////////////////////////////////////////
197
{
198
cv::medianBlur(in_mat1, out_mat_ocv, kernSize);
199
}
200
// Comparison //////////////////////////////////////////////////////////////
201
{
202
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
203
EXPECT_EQ(out_mat_gapi.size(), sz);
204
}
205
}
206
207
TEST_P(ErodeTest, AccuracyTest)
208
{
209
compare_f cmpF;
210
MatType type = 0;
211
int kernSize = 0, kernType = 0;
212
cv::Size sz;
213
bool initOut = false;
214
cv::GCompileArgs compile_args;
215
std::tie(cmpF, type, kernSize, sz, kernType, initOut, compile_args) = GetParam();
216
initMatsRandN(type, sz, type, initOut);
217
218
cv::Mat kernel = cv::getStructuringElement(kernType, cv::Size(kernSize, kernSize));
219
220
// G-API code //////////////////////////////////////////////////////////////
221
cv::GMat in;
222
auto out = cv::gapi::erode(in, kernel);
223
224
cv::GComputation c(in, out);
225
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
226
// OpenCV code /////////////////////////////////////////////////////////////
227
{
228
cv::erode(in_mat1, out_mat_ocv, kernel);
229
}
230
// Comparison //////////////////////////////////////////////////////////////
231
{
232
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
233
EXPECT_EQ(out_mat_gapi.size(), sz);
234
}
235
}
236
237
TEST_P(Erode3x3Test, AccuracyTest)
238
{
239
compare_f cmpF;
240
MatType type = 0;
241
int numIters = 0;
242
cv::Size sz;
243
bool initOut = false;
244
cv::GCompileArgs compile_args;
245
std::tie(cmpF, type, sz, initOut, numIters, compile_args) = GetParam();
246
initMatsRandN(type, sz, type, initOut);
247
248
cv::Mat kernel = cv::getStructuringElement(cv::MorphShapes::MORPH_RECT, cv::Size(3,3));
249
250
// G-API code //////////////////////////////////////////////////////////////
251
cv::GMat in;
252
auto out = cv::gapi::erode3x3(in, numIters);
253
254
cv::GComputation c(in, out);
255
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
256
// OpenCV code /////////////////////////////////////////////////////////////
257
{
258
cv::erode(in_mat1, out_mat_ocv, kernel, cv::Point(-1, -1), numIters);
259
}
260
// Comparison //////////////////////////////////////////////////////////////
261
{
262
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
263
EXPECT_EQ(out_mat_gapi.size(), sz);
264
}
265
}
266
267
TEST_P(DilateTest, AccuracyTest)
268
{
269
compare_f cmpF;
270
MatType type = 0;
271
int kernSize = 0, kernType = 0;
272
cv::Size sz;
273
bool initOut = false;
274
cv::GCompileArgs compile_args;
275
std::tie(cmpF, type, kernSize, sz, kernType, initOut, compile_args) = GetParam();
276
initMatsRandN(type, sz, type, initOut);
277
278
cv::Mat kernel = cv::getStructuringElement(kernType, cv::Size(kernSize, kernSize));
279
280
// G-API code //////////////////////////////////////////////////////////////
281
cv::GMat in;
282
auto out = cv::gapi::dilate(in, kernel);
283
284
cv::GComputation c(in, out);
285
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
286
// OpenCV code /////////////////////////////////////////////////////////////
287
{
288
cv::dilate(in_mat1, out_mat_ocv, kernel);
289
}
290
// Comparison //////////////////////////////////////////////////////////////
291
{
292
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
293
EXPECT_EQ(out_mat_gapi.size(), sz);
294
}
295
}
296
297
TEST_P(Dilate3x3Test, AccuracyTest)
298
{
299
compare_f cmpF;
300
MatType type = 0;
301
int numIters = 0;
302
cv::Size sz;
303
bool initOut = false;
304
cv::GCompileArgs compile_args;
305
std::tie(cmpF, type, sz, initOut, numIters, compile_args) = GetParam();
306
initMatsRandN(type, sz, type, initOut);
307
308
cv::Mat kernel = cv::getStructuringElement(cv::MorphShapes::MORPH_RECT, cv::Size(3,3));
309
310
// G-API code //////////////////////////////////////////////////////////////
311
cv::GMat in;
312
auto out = cv::gapi::dilate3x3(in, numIters);
313
314
cv::GComputation c(in, out);
315
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
316
// OpenCV code /////////////////////////////////////////////////////////////
317
{
318
cv::dilate(in_mat1, out_mat_ocv, kernel, cv::Point(-1,-1), numIters);
319
}
320
// Comparison //////////////////////////////////////////////////////////////
321
{
322
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
323
EXPECT_EQ(out_mat_gapi.size(), sz);
324
}
325
}
326
327
328
TEST_P(SobelTest, AccuracyTest)
329
{
330
compare_f cmpF;
331
MatType type = 0;
332
int kernSize = 0, dtype = 0, dx = 0, dy = 0;
333
cv::Size sz;
334
bool initOut = false;
335
cv::GCompileArgs compile_args;
336
std::tie(cmpF, type, kernSize, sz, dtype, dx, dy, initOut, compile_args) = GetParam();
337
initMatsRandN(type, sz, dtype, initOut);
338
339
// G-API code //////////////////////////////////////////////////////////////
340
cv::GMat in;
341
auto out = cv::gapi::Sobel(in, dtype, dx, dy, kernSize );
342
343
cv::GComputation c(in, out);
344
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
345
// OpenCV code /////////////////////////////////////////////////////////////
346
{
347
cv::Sobel(in_mat1, out_mat_ocv, dtype, dx, dy, kernSize);
348
}
349
// Comparison //////////////////////////////////////////////////////////////
350
{
351
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
352
EXPECT_EQ(out_mat_gapi.size(), sz);
353
}
354
}
355
356
TEST_P(EqHistTest, AccuracyTest)
357
{
358
compare_f cmpF;
359
cv::Size sz;
360
bool initOut = false;
361
cv::GCompileArgs compile_args;
362
std::tie(cmpF, sz, initOut, compile_args) = GetParam();
363
initMatsRandN(CV_8UC1, sz, CV_8UC1, initOut);
364
365
// G-API code //////////////////////////////////////////////////////////////
366
cv::GMat in;
367
auto out = cv::gapi::equalizeHist(in);
368
369
cv::GComputation c(in, out);
370
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
371
// OpenCV code /////////////////////////////////////////////////////////////
372
{
373
cv::equalizeHist(in_mat1, out_mat_ocv);
374
}
375
// Comparison //////////////////////////////////////////////////////////////
376
{
377
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
378
EXPECT_EQ(out_mat_gapi.size(), std::get<1>(GetParam()));
379
}
380
}
381
382
TEST_P(CannyTest, AccuracyTest)
383
{
384
compare_f cmpF;
385
MatType type;
386
int apSize = 0;
387
double thrLow = 0.0, thrUp = 0.0;
388
cv::Size sz;
389
bool l2gr = false, initOut = false;
390
cv::GCompileArgs compile_args;
391
std::tie(cmpF, type, sz, thrLow, thrUp, apSize, l2gr, initOut, compile_args) = GetParam();
392
393
initMatsRandN(type, sz, CV_8UC1, initOut);
394
395
// G-API code //////////////////////////////////////////////////////////////
396
cv::GMat in;
397
auto out = cv::gapi::Canny(in, thrLow, thrUp, apSize, l2gr);
398
399
cv::GComputation c(in, out);
400
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
401
// OpenCV code /////////////////////////////////////////////////////////////
402
{
403
cv::Canny(in_mat1, out_mat_ocv, thrLow, thrUp, apSize, l2gr);
404
}
405
// Comparison //////////////////////////////////////////////////////////////
406
{
407
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
408
EXPECT_EQ(out_mat_gapi.size(), sz);
409
}
410
}
411
412
TEST_P(RGB2GrayTest, AccuracyTest)
413
{
414
auto param = GetParam();
415
auto compile_args = std::get<3>(param);
416
compare_f cmpF = std::get<0>(param);
417
initMatsRandN(CV_8UC3, std::get<1>(param), CV_8UC1, std::get<2>(param));
418
419
// G-API code //////////////////////////////////////////////////////////////
420
cv::GMat in;
421
auto out = cv::gapi::RGB2Gray(in);
422
423
cv::GComputation c(in, out);
424
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
425
// OpenCV code /////////////////////////////////////////////////////////////
426
{
427
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_RGB2GRAY);
428
}
429
// Comparison //////////////////////////////////////////////////////////////
430
{
431
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
432
EXPECT_EQ(out_mat_gapi.size(), std::get<1>(param));
433
}
434
}
435
436
TEST_P(BGR2GrayTest, AccuracyTest)
437
{
438
auto param = GetParam();
439
auto compile_args = std::get<3>(param);
440
compare_f cmpF = std::get<0>(param);
441
initMatsRandN(CV_8UC3, std::get<1>(param), CV_8UC1, std::get<2>(param));
442
443
// G-API code //////////////////////////////////////////////////////////////
444
cv::GMat in;
445
auto out = cv::gapi::BGR2Gray(in);
446
447
cv::GComputation c(in, out);
448
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
449
// OpenCV code /////////////////////////////////////////////////////////////
450
{
451
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_BGR2GRAY);
452
}
453
// Comparison //////////////////////////////////////////////////////////////
454
{
455
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
456
EXPECT_EQ(out_mat_gapi.size(), std::get<1>(param));
457
}
458
}
459
460
TEST_P(RGB2YUVTest, AccuracyTest)
461
{
462
auto param = GetParam();
463
auto compile_args = std::get<3>(param);
464
compare_f cmpF = std::get<0>(param);
465
initMatsRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param));
466
467
// G-API code //////////////////////////////////////////////////////////////
468
cv::GMat in;
469
auto out = cv::gapi::RGB2YUV(in);
470
471
cv::GComputation c(in, out);
472
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
473
// OpenCV code /////////////////////////////////////////////////////////////
474
{
475
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_RGB2YUV);
476
}
477
// Comparison //////////////////////////////////////////////////////////////
478
{
479
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
480
EXPECT_EQ(out_mat_gapi.size(), std::get<1>(param));
481
}
482
}
483
484
TEST_P(YUV2RGBTest, AccuracyTest)
485
{
486
auto param = GetParam();
487
auto compile_args = std::get<3>(param);
488
compare_f cmpF = std::get<0>(param);
489
initMatsRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param));
490
491
492
// G-API code //////////////////////////////////////////////////////////////
493
cv::GMat in;
494
auto out = cv::gapi::YUV2RGB(in);
495
496
cv::GComputation c(in, out);
497
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
498
// OpenCV code /////////////////////////////////////////////////////////////
499
{
500
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_YUV2RGB);
501
}
502
// Comparison //////////////////////////////////////////////////////////////
503
{
504
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
505
EXPECT_EQ(out_mat_gapi.size(), std::get<1>(param));
506
}
507
}
508
509
TEST_P(RGB2LabTest, AccuracyTest)
510
{
511
auto param = GetParam();
512
auto compile_args = std::get<3>(param);
513
compare_f cmpF = std::get<0>(param);
514
initMatsRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param));
515
516
// G-API code //////////////////////////////////////////////////////////////
517
cv::GMat in;
518
auto out = cv::gapi::RGB2Lab(in);
519
520
cv::GComputation c(in, out);
521
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
522
// OpenCV code /////////////////////////////////////////////////////////////
523
{
524
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_RGB2Lab);
525
}
526
// Comparison //////////////////////////////////////////////////////////////
527
{
528
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
529
EXPECT_EQ(out_mat_gapi.size(), std::get<1>(param));
530
}
531
}
532
533
TEST_P(BGR2LUVTest, AccuracyTest)
534
{
535
auto param = GetParam();
536
auto compile_args = std::get<3>(param);
537
compare_f cmpF = std::get<0>(param);
538
initMatsRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param));
539
540
// G-API code //////////////////////////////////////////////////////////////
541
cv::GMat in;
542
auto out = cv::gapi::BGR2LUV(in);
543
544
cv::GComputation c(in, out);
545
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
546
// OpenCV code /////////////////////////////////////////////////////////////
547
{
548
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_BGR2Luv);
549
}
550
// Comparison //////////////////////////////////////////////////////////////
551
{
552
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
553
EXPECT_EQ(out_mat_gapi.size(), std::get<1>(param));
554
}
555
}
556
557
TEST_P(LUV2BGRTest, AccuracyTest)
558
{
559
auto param = GetParam();
560
auto compile_args = std::get<3>(param);
561
compare_f cmpF = std::get<0>(param);
562
initMatsRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param));
563
564
// G-API code //////////////////////////////////////////////////////////////
565
cv::GMat in;
566
auto out = cv::gapi::LUV2BGR(in);
567
568
cv::GComputation c(in, out);
569
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
570
// OpenCV code /////////////////////////////////////////////////////////////
571
{
572
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_Luv2BGR);
573
}
574
// Comparison //////////////////////////////////////////////////////////////
575
{
576
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
577
EXPECT_EQ(out_mat_gapi.size(), std::get<1>(param));
578
}
579
}
580
581
TEST_P(BGR2YUVTest, AccuracyTest)
582
{
583
auto param = GetParam();
584
auto compile_args = std::get<3>(param);
585
compare_f cmpF = std::get<0>(param);
586
initMatsRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param));
587
588
// G-API code //////////////////////////////////////////////////////////////
589
cv::GMat in;
590
auto out = cv::gapi::BGR2YUV(in);
591
592
cv::GComputation c(in, out);
593
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
594
// OpenCV code /////////////////////////////////////////////////////////////
595
{
596
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_BGR2YUV);
597
}
598
// Comparison //////////////////////////////////////////////////////////////
599
{
600
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
601
EXPECT_EQ(out_mat_gapi.size(), std::get<1>(param));
602
}
603
}
604
605
TEST_P(YUV2BGRTest, AccuracyTest)
606
{
607
auto param = GetParam();
608
auto compile_args = std::get<3>(param);
609
compare_f cmpF = std::get<0>(param);
610
initMatsRandN(CV_8UC3, std::get<1>(param), CV_8UC3, std::get<2>(param));
611
612
// G-API code //////////////////////////////////////////////////////////////
613
cv::GMat in;
614
auto out = cv::gapi::YUV2BGR(in);
615
616
cv::GComputation c(in, out);
617
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
618
// OpenCV code /////////////////////////////////////////////////////////////
619
{
620
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_YUV2BGR);
621
}
622
// Comparison //////////////////////////////////////////////////////////////
623
{
624
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
625
EXPECT_EQ(out_mat_gapi.size(), std::get<1>(param));
626
}
627
}
628
} // opencv_test
629
630
#endif //OPENCV_GAPI_IMGPROC_TESTS_INL_HPP
631
632