Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/gapi/perf/common/gapi_imgproc_perf_tests_inl.hpp
16358 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_PERF_TESTS_INL_HPP
9
#define OPENCV_GAPI_IMGPROC_PERF_TESTS_INL_HPP
10
11
12
#include <iostream>
13
14
#include "gapi_imgproc_perf_tests.hpp"
15
16
namespace opencv_test
17
{
18
19
using namespace perf;
20
21
//------------------------------------------------------------------------------
22
23
PERF_TEST_P_(SepFilterPerfTest, TestPerformance)
24
{
25
compare_f cmpF;
26
MatType type = 0;
27
int kernSize = 0, dtype = 0;
28
cv::Size sz;
29
cv::GCompileArgs compile_args;
30
std::tie(cmpF, type, kernSize, sz, dtype, compile_args) = GetParam();
31
32
cv::Mat kernelX(kernSize, 1, CV_32F);
33
cv::Mat kernelY(kernSize, 1, CV_32F);
34
randu(kernelX, -1, 1);
35
randu(kernelY, -1, 1);
36
initMatsRandN(type, sz, dtype, false);
37
38
cv::Point anchor = cv::Point(-1, -1);
39
40
// OpenCV code /////////////////////////////////////////////////////////////
41
{
42
cv::sepFilter2D(in_mat1, out_mat_ocv, dtype, kernelX, kernelY );
43
}
44
45
// G-API code //////////////////////////////////////////////////////////////
46
cv::GMat in;
47
auto out = cv::gapi::sepFilter(in, dtype, kernelX, kernelY, anchor, cv::Scalar() );
48
cv::GComputation c(in, out);
49
50
// Warm-up graph engine:
51
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
52
53
TEST_CYCLE()
54
{
55
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
56
}
57
58
// Comparison //////////////////////////////////////////////////////////////
59
{
60
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
61
EXPECT_EQ(out_mat_gapi.size(), sz);
62
}
63
64
SANITY_CHECK_NOTHING();
65
}
66
67
//------------------------------------------------------------------------------
68
69
PERF_TEST_P_(Filter2DPerfTest, TestPerformance)
70
{
71
compare_f cmpF;
72
MatType type = 0;
73
int kernSize = 0, borderType = 0, dtype = 0;
74
cv::Size sz;
75
cv::GCompileArgs compile_args;
76
std::tie(cmpF, type, kernSize, sz, borderType, dtype, compile_args) = GetParam();
77
78
initMatsRandN(type, sz, dtype, false);
79
80
cv::Point anchor = {-1, -1};
81
double delta = 0;
82
83
cv::Mat kernel = cv::Mat(kernSize, kernSize, CV_32FC1 );
84
cv::Scalar kernMean = cv::Scalar::all(1.0);
85
cv::Scalar kernStddev = cv::Scalar::all(2.0/3);
86
randn(kernel, kernMean, kernStddev);
87
88
// OpenCV code /////////////////////////////////////////////////////////////
89
{
90
cv::filter2D(in_mat1, out_mat_ocv, dtype, kernel, anchor, delta, borderType);
91
}
92
93
// G-API code //////////////////////////////////////////////////////////////
94
cv::GMat in;
95
auto out = cv::gapi::filter2D(in, dtype, kernel, anchor, delta, borderType);
96
cv::GComputation c(in, out);
97
98
// Warm-up graph engine:
99
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
100
101
TEST_CYCLE()
102
{
103
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
104
}
105
106
// Comparison //////////////////////////////////////////////////////////////
107
{
108
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
109
EXPECT_EQ(out_mat_gapi.size(), sz);
110
}
111
112
113
SANITY_CHECK_NOTHING();
114
115
}
116
117
//------------------------------------------------------------------------------
118
119
PERF_TEST_P_(BoxFilterPerfTest, TestPerformance)
120
{
121
compare_f cmpF;
122
MatType type = 0;
123
int filterSize = 0, borderType = 0, dtype = 0;
124
cv::Size sz;
125
cv::GCompileArgs compile_args;
126
std::tie(cmpF, type, filterSize, sz, borderType, dtype, compile_args) = GetParam();
127
128
initMatsRandN(type, sz, dtype, false);
129
130
cv::Point anchor = {-1, -1};
131
bool normalize = true;
132
133
// OpenCV code /////////////////////////////////////////////////////////////
134
{
135
cv::boxFilter(in_mat1, out_mat_ocv, dtype, cv::Size(filterSize, filterSize), anchor, normalize, borderType);
136
}
137
138
// G-API code //////////////////////////////////////////////////////////////
139
cv::GMat in;
140
auto out = cv::gapi::boxFilter(in, dtype, cv::Size(filterSize, filterSize), anchor, normalize, borderType);
141
cv::GComputation c(in, out);
142
143
// Warm-up graph engine:
144
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
145
146
TEST_CYCLE()
147
{
148
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
149
}
150
151
// Comparison //////////////////////////////////////////////////////////////
152
{
153
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
154
EXPECT_EQ(out_mat_gapi.size(), sz);
155
}
156
157
SANITY_CHECK_NOTHING();
158
159
}
160
161
//------------------------------------------------------------------------------
162
163
PERF_TEST_P_(BlurPerfTest, TestPerformance)
164
{
165
compare_f cmpF;
166
MatType type = 0;
167
int filterSize = 0, borderType = 0;
168
cv::Size sz;
169
cv::GCompileArgs compile_args;
170
std::tie(cmpF, type, filterSize, sz, borderType, compile_args) = GetParam();
171
172
initMatsRandN(type, sz, type, false);
173
174
cv::Point anchor = {-1, -1};
175
176
// OpenCV code /////////////////////////////////////////////////////////////
177
{
178
cv::blur(in_mat1, out_mat_ocv, cv::Size(filterSize, filterSize), anchor, borderType);
179
}
180
181
// G-API code //////////////////////////////////////////////////////////////
182
cv::GMat in;
183
auto out = cv::gapi::blur(in, cv::Size(filterSize, filterSize), anchor, borderType);
184
cv::GComputation c(in, out);
185
186
// Warm-up graph engine:
187
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
188
189
TEST_CYCLE()
190
{
191
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
192
}
193
194
// Comparison //////////////////////////////////////////////////////////////
195
{
196
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
197
EXPECT_EQ(out_mat_gapi.size(), sz);
198
}
199
200
SANITY_CHECK_NOTHING();
201
202
}
203
204
//------------------------------------------------------------------------------
205
206
PERF_TEST_P_(GaussianBlurPerfTest, TestPerformance)
207
{
208
compare_f cmpF;
209
MatType type = 0;
210
int kernSize = 0;
211
cv::Size sz;
212
cv::GCompileArgs compile_args;
213
std::tie(cmpF, type, kernSize, sz, compile_args) = GetParam();
214
215
cv::Size kSize = cv::Size(kernSize, kernSize);
216
auto& rng = cv::theRNG();
217
double sigmaX = rng();
218
initMatsRandN(type, sz, type, false);
219
220
// OpenCV code ///////////////////////////////////////////////////////////
221
cv::GaussianBlur(in_mat1, out_mat_ocv, kSize, sigmaX);
222
223
// G-API code //////////////////////////////////////////////////////////////
224
cv::GMat in;
225
auto out = cv::gapi::gaussianBlur(in, kSize, sigmaX);
226
cv::GComputation c(in, out);
227
228
// Warm-up graph engine:
229
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
230
231
TEST_CYCLE()
232
{
233
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
234
}
235
236
// Comparison //////////////////////////////////////////////////////////////
237
{
238
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
239
EXPECT_EQ(out_mat_gapi.size(), sz);
240
}
241
242
243
SANITY_CHECK_NOTHING();
244
}
245
246
//------------------------------------------------------------------------------
247
248
PERF_TEST_P_(MedianBlurPerfTest, TestPerformance)
249
{
250
compare_f cmpF;
251
MatType type = 0;
252
int kernSize = 0;
253
cv::Size sz;
254
cv::GCompileArgs compile_args;
255
std::tie(cmpF, type, kernSize, sz, compile_args) = GetParam();
256
257
initMatsRandN(type, sz, type, false);
258
259
// OpenCV code /////////////////////////////////////////////////////////////
260
{
261
cv::medianBlur(in_mat1, out_mat_ocv, kernSize);
262
}
263
264
// G-API code //////////////////////////////////////////////////////////////
265
cv::GMat in;
266
auto out = cv::gapi::medianBlur(in, kernSize);
267
cv::GComputation c(in, out);
268
269
// Warm-up graph engine:
270
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
271
272
TEST_CYCLE()
273
{
274
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
275
}
276
277
// Comparison //////////////////////////////////////////////////////////////
278
{
279
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
280
EXPECT_EQ(out_mat_gapi.size(), sz);
281
}
282
283
SANITY_CHECK_NOTHING();
284
285
}
286
287
//------------------------------------------------------------------------------
288
289
PERF_TEST_P_(ErodePerfTest, TestPerformance)
290
{
291
compare_f cmpF;
292
MatType type = 0;
293
int kernSize = 0, kernType = 0;
294
cv::Size sz;
295
cv::GCompileArgs compile_args;
296
std::tie(cmpF, type, kernSize, sz, kernType, compile_args) = GetParam();
297
298
initMatsRandN(type, sz, type, false);
299
300
cv::Mat kernel = cv::getStructuringElement(kernType, cv::Size(kernSize, kernSize));
301
302
// OpenCV code /////////////////////////////////////////////////////////////
303
{
304
cv::erode(in_mat1, out_mat_ocv, kernel);
305
}
306
307
// G-API code //////////////////////////////////////////////////////////////
308
cv::GMat in;
309
auto out = cv::gapi::erode(in, kernel);
310
cv::GComputation c(in, out);
311
312
// Warm-up graph engine:
313
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
314
315
TEST_CYCLE()
316
{
317
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
318
}
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
SANITY_CHECK_NOTHING();
327
328
}
329
330
//------------------------------------------------------------------------------
331
332
PERF_TEST_P_(Erode3x3PerfTest, TestPerformance)
333
{
334
compare_f cmpF;
335
MatType type = 0;
336
int numIters = 0;
337
cv::Size sz;
338
cv::GCompileArgs compile_args;
339
std::tie(cmpF, type, sz, numIters, compile_args) = GetParam();
340
341
initMatsRandN(type, sz, type, false);
342
343
cv::Mat kernel = cv::getStructuringElement(cv::MorphShapes::MORPH_RECT, cv::Size(3, 3));
344
345
// OpenCV code /////////////////////////////////////////////////////////////
346
{
347
cv::erode(in_mat1, out_mat_ocv, kernel, cv::Point(-1, -1), numIters);
348
}
349
350
// G-API code //////////////////////////////////////////////////////////////
351
cv::GMat in;
352
auto out = cv::gapi::erode3x3(in, numIters);
353
cv::GComputation c(in, out);
354
355
// Warm-up graph engine:
356
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
357
358
TEST_CYCLE()
359
{
360
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
361
}
362
363
// Comparison //////////////////////////////////////////////////////////////
364
{
365
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
366
EXPECT_EQ(out_mat_gapi.size(), sz);
367
}
368
369
SANITY_CHECK_NOTHING();
370
371
}
372
373
//------------------------------------------------------------------------------
374
375
PERF_TEST_P_(DilatePerfTest, TestPerformance)
376
{
377
compare_f cmpF;
378
MatType type = 0;
379
int kernSize = 0, kernType = 0;
380
cv::Size sz;
381
cv::GCompileArgs compile_args;
382
std::tie(cmpF, type, kernSize, sz, kernType, compile_args) = GetParam();
383
384
initMatsRandN(type, sz, type, false);
385
386
cv::Mat kernel = cv::getStructuringElement(kernType, cv::Size(kernSize, kernSize));
387
388
// OpenCV code /////////////////////////////////////////////////////////////
389
{
390
cv::dilate(in_mat1, out_mat_ocv, kernel);
391
}
392
393
// G-API code //////////////////////////////////////////////////////////////
394
cv::GMat in;
395
auto out = cv::gapi::dilate(in, kernel);
396
cv::GComputation c(in, out);
397
398
// Warm-up graph engine:
399
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
400
401
TEST_CYCLE()
402
{
403
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
404
}
405
406
// Comparison //////////////////////////////////////////////////////////////
407
{
408
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
409
EXPECT_EQ(out_mat_gapi.size(), sz);
410
}
411
412
SANITY_CHECK_NOTHING();
413
414
}
415
416
//------------------------------------------------------------------------------
417
418
PERF_TEST_P_(Dilate3x3PerfTest, TestPerformance)
419
{
420
compare_f cmpF;
421
MatType type = 0;
422
int numIters = 0;
423
cv::Size sz;
424
cv::GCompileArgs compile_args;
425
std::tie(cmpF, type, sz, numIters, compile_args) = GetParam();
426
427
initMatsRandN(type, sz, type, false);
428
429
cv::Mat kernel = cv::getStructuringElement(cv::MorphShapes::MORPH_RECT, cv::Size(3, 3));
430
431
// OpenCV code /////////////////////////////////////////////////////////////
432
{
433
cv::dilate(in_mat1, out_mat_ocv, kernel, cv::Point(-1,-1), numIters);
434
}
435
436
// G-API code //////////////////////////////////////////////////////////////
437
cv::GMat in;
438
auto out = cv::gapi::dilate3x3(in, numIters);
439
cv::GComputation c(in, out);
440
441
// Warm-up graph engine:
442
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
443
444
TEST_CYCLE()
445
{
446
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
447
}
448
449
// Comparison //////////////////////////////////////////////////////////////
450
{
451
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
452
EXPECT_EQ(out_mat_gapi.size(), sz);
453
}
454
455
SANITY_CHECK_NOTHING();
456
457
}
458
459
//------------------------------------------------------------------------------
460
461
PERF_TEST_P_(SobelPerfTest, TestPerformance)
462
{
463
compare_f cmpF;
464
MatType type = 0;
465
int kernSize = 0, dtype = 0, dx = 0, dy = 0;
466
cv::Size sz;
467
cv::GCompileArgs compile_args;
468
std::tie(cmpF, type, kernSize, sz, dtype, dx, dy, compile_args) = GetParam();
469
470
initMatsRandN(type, sz, dtype, false);
471
472
// OpenCV code /////////////////////////////////////////////////////////////
473
{
474
cv::Sobel(in_mat1, out_mat_ocv, dtype, dx, dy, kernSize);
475
}
476
477
// G-API code //////////////////////////////////////////////////////////////
478
cv::GMat in;
479
auto out = cv::gapi::Sobel(in, dtype, dx, dy, kernSize );
480
cv::GComputation c(in, out);
481
482
// Warm-up graph engine:
483
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
484
485
TEST_CYCLE()
486
{
487
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
488
}
489
490
// Comparison //////////////////////////////////////////////////////////////
491
{
492
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
493
EXPECT_EQ(out_mat_gapi.size(), sz);
494
}
495
496
SANITY_CHECK_NOTHING();
497
498
}
499
500
//------------------------------------------------------------------------------
501
502
PERF_TEST_P_(CannyPerfTest, TestPerformance)
503
{
504
compare_f cmpF;
505
MatType type;
506
int apSize = 0;
507
double thrLow = 0.0, thrUp = 0.0;
508
cv::Size sz;
509
bool l2gr = false;
510
cv::GCompileArgs compile_args;
511
std::tie(cmpF, type, sz, thrLow, thrUp, apSize, l2gr, compile_args) = GetParam();
512
513
initMatsRandN(type, sz, CV_8UC1, false);
514
515
// OpenCV code /////////////////////////////////////////////////////////////
516
{
517
cv::Canny(in_mat1, out_mat_ocv, thrLow, thrUp, apSize, l2gr);
518
}
519
520
// G-API code //////////////////////////////////////////////////////////////
521
cv::GMat in;
522
auto out = cv::gapi::Canny(in, thrLow, thrUp, apSize, l2gr);
523
cv::GComputation c(in, out);
524
525
// Warm-up graph engine:
526
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
527
528
TEST_CYCLE()
529
{
530
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
531
}
532
533
// Comparison //////////////////////////////////////////////////////////////
534
{
535
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
536
EXPECT_EQ(out_mat_gapi.size(), sz);
537
}
538
539
SANITY_CHECK_NOTHING();
540
541
}
542
543
//------------------------------------------------------------------------------
544
545
PERF_TEST_P_(EqHistPerfTest, TestPerformance)
546
{
547
compare_f cmpF = get<0>(GetParam());
548
Size sz = get<1>(GetParam());
549
cv::GCompileArgs compile_args = get<2>(GetParam());
550
551
initMatsRandN(CV_8UC1, sz, CV_8UC1, false);
552
553
// OpenCV code /////////////////////////////////////////////////////////////
554
{
555
cv::equalizeHist(in_mat1, out_mat_ocv);
556
}
557
558
// G-API code //////////////////////////////////////////////////////////////
559
cv::GMat in;
560
auto out = cv::gapi::equalizeHist(in);
561
cv::GComputation c(in, out);
562
563
// Warm-up graph engine:
564
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
565
566
TEST_CYCLE()
567
{
568
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
569
}
570
571
// Comparison //////////////////////////////////////////////////////////////
572
{
573
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
574
EXPECT_EQ(out_mat_gapi.size(), sz);
575
}
576
577
SANITY_CHECK_NOTHING();
578
579
}
580
581
//------------------------------------------------------------------------------
582
583
PERF_TEST_P_(RGB2GrayPerfTest, TestPerformance)
584
{
585
compare_f cmpF = get<0>(GetParam());
586
Size sz = get<1>(GetParam());
587
cv::GCompileArgs compile_args = get<2>(GetParam());
588
589
initMatsRandN(CV_8UC3, sz, CV_8UC1, false);
590
591
// OpenCV code /////////////////////////////////////////////////////////////
592
{
593
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_RGB2GRAY);
594
}
595
596
// G-API code //////////////////////////////////////////////////////////////
597
cv::GMat in;
598
auto out = cv::gapi::RGB2Gray(in);
599
cv::GComputation c(in, out);
600
601
// Warm-up graph engine:
602
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
603
604
TEST_CYCLE()
605
{
606
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
607
}
608
609
// Comparison //////////////////////////////////////////////////////////////
610
{
611
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
612
EXPECT_EQ(out_mat_gapi.size(), sz);
613
}
614
615
SANITY_CHECK_NOTHING();
616
617
}
618
619
//------------------------------------------------------------------------------
620
621
PERF_TEST_P_(BGR2GrayPerfTest, TestPerformance)
622
{
623
compare_f cmpF = get<0>(GetParam());
624
Size sz = get<1>(GetParam());
625
cv::GCompileArgs compile_args = get<2>(GetParam());
626
627
initMatsRandN(CV_8UC3, sz, CV_8UC1, false);
628
629
// OpenCV code /////////////////////////////////////////////////////////////
630
{
631
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_BGR2GRAY);
632
}
633
634
// G-API code //////////////////////////////////////////////////////////////
635
cv::GMat in;
636
auto out = cv::gapi::BGR2Gray(in);
637
cv::GComputation c(in, out);
638
639
// Warm-up graph engine:
640
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
641
642
TEST_CYCLE()
643
{
644
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
645
}
646
647
// Comparison //////////////////////////////////////////////////////////////
648
{
649
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
650
EXPECT_EQ(out_mat_gapi.size(), sz);
651
}
652
653
SANITY_CHECK_NOTHING();
654
655
}
656
657
//------------------------------------------------------------------------------
658
659
PERF_TEST_P_(RGB2YUVPerfTest, TestPerformance)
660
{
661
compare_f cmpF = get<0>(GetParam());
662
Size sz = get<1>(GetParam());
663
cv::GCompileArgs compile_args = get<2>(GetParam());
664
665
initMatsRandN(CV_8UC3, sz, CV_8UC3, false);
666
667
// OpenCV code /////////////////////////////////////////////////////////////
668
{
669
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_RGB2YUV);
670
}
671
672
// G-API code //////////////////////////////////////////////////////////////
673
cv::GMat in;
674
auto out = cv::gapi::RGB2YUV(in);
675
cv::GComputation c(in, out);
676
677
// Warm-up graph engine:
678
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
679
680
TEST_CYCLE()
681
{
682
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
683
}
684
685
// Comparison //////////////////////////////////////////////////////////////
686
{
687
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
688
EXPECT_EQ(out_mat_gapi.size(), sz);
689
}
690
691
SANITY_CHECK_NOTHING();
692
693
}
694
695
//------------------------------------------------------------------------------
696
697
PERF_TEST_P_(YUV2RGBPerfTest, TestPerformance)
698
{
699
compare_f cmpF = get<0>(GetParam());
700
Size sz = get<1>(GetParam());
701
cv::GCompileArgs compile_args = get<2>(GetParam());
702
703
initMatsRandN(CV_8UC3, sz, CV_8UC3, false);
704
705
// OpenCV code /////////////////////////////////////////////////////////////
706
{
707
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_YUV2RGB);
708
}
709
710
// G-API code //////////////////////////////////////////////////////////////
711
cv::GMat in;
712
auto out = cv::gapi::YUV2RGB(in);
713
cv::GComputation c(in, out);
714
715
// Warm-up graph engine:
716
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
717
718
TEST_CYCLE()
719
{
720
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
721
}
722
723
// Comparison //////////////////////////////////////////////////////////////
724
{
725
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
726
EXPECT_EQ(out_mat_gapi.size(), sz);
727
}
728
729
SANITY_CHECK_NOTHING();
730
731
}
732
733
//------------------------------------------------------------------------------
734
735
PERF_TEST_P_(RGB2LabPerfTest, TestPerformance)
736
{
737
compare_f cmpF = get<0>(GetParam());
738
Size sz = get<1>(GetParam());
739
cv::GCompileArgs compile_args = get<2>(GetParam());
740
741
initMatsRandN(CV_8UC3, sz, CV_8UC3, false);
742
743
// OpenCV code /////////////////////////////////////////////////////////////
744
{
745
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_RGB2Lab);
746
}
747
748
// G-API code //////////////////////////////////////////////////////////////
749
cv::GMat in;
750
auto out = cv::gapi::RGB2Lab(in);
751
cv::GComputation c(in, out);
752
753
// Warm-up graph engine:
754
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
755
756
TEST_CYCLE()
757
{
758
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
759
}
760
761
// Comparison //////////////////////////////////////////////////////////////
762
{
763
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
764
EXPECT_EQ(out_mat_gapi.size(), sz);
765
}
766
767
SANITY_CHECK_NOTHING();
768
769
}
770
771
//------------------------------------------------------------------------------
772
773
PERF_TEST_P_(BGR2LUVPerfTest, TestPerformance)
774
{
775
compare_f cmpF = get<0>(GetParam());
776
Size sz = get<1>(GetParam());
777
cv::GCompileArgs compile_args = get<2>(GetParam());
778
779
initMatsRandN(CV_8UC3, sz, CV_8UC3, false);
780
781
// OpenCV code /////////////////////////////////////////////////////////////
782
{
783
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_BGR2Luv);
784
}
785
786
// G-API code //////////////////////////////////////////////////////////////
787
cv::GMat in;
788
auto out = cv::gapi::BGR2LUV(in);
789
cv::GComputation c(in, out);
790
791
// Warm-up graph engine:
792
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
793
794
TEST_CYCLE()
795
{
796
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
797
}
798
799
// Comparison //////////////////////////////////////////////////////////////
800
{
801
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
802
EXPECT_EQ(out_mat_gapi.size(), sz);
803
}
804
805
SANITY_CHECK_NOTHING();
806
807
}
808
809
//------------------------------------------------------------------------------
810
811
PERF_TEST_P_(LUV2BGRPerfTest, TestPerformance)
812
{
813
compare_f cmpF = get<0>(GetParam());
814
Size sz = get<1>(GetParam());
815
cv::GCompileArgs compile_args = get<2>(GetParam());
816
817
initMatsRandN(CV_8UC3, sz, CV_8UC3, false);
818
819
// OpenCV code /////////////////////////////////////////////////////////////
820
{
821
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_Luv2BGR);
822
}
823
824
// G-API code //////////////////////////////////////////////////////////////
825
cv::GMat in;
826
auto out = cv::gapi::LUV2BGR(in);
827
cv::GComputation c(in, out);
828
829
// Warm-up graph engine:
830
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
831
832
TEST_CYCLE()
833
{
834
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
835
}
836
837
// Comparison //////////////////////////////////////////////////////////////
838
{
839
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
840
EXPECT_EQ(out_mat_gapi.size(), sz);
841
}
842
843
SANITY_CHECK_NOTHING();
844
845
}
846
847
//------------------------------------------------------------------------------
848
849
PERF_TEST_P_(BGR2YUVPerfTest, TestPerformance)
850
{
851
compare_f cmpF = get<0>(GetParam());
852
Size sz = get<1>(GetParam());
853
cv::GCompileArgs compile_args = get<2>(GetParam());
854
855
initMatsRandN(CV_8UC3, sz, CV_8UC3, false);
856
857
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_BGR2YUV);
858
859
cv::GMat in;
860
auto out = cv::gapi::BGR2YUV(in);
861
cv::GComputation c(in, out);
862
863
// Warm-up graph engine:
864
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
865
866
TEST_CYCLE()
867
{
868
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
869
}
870
871
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
872
EXPECT_EQ(out_mat_gapi.size(), sz);
873
874
SANITY_CHECK_NOTHING();
875
}
876
877
//------------------------------------------------------------------------------
878
879
PERF_TEST_P_(YUV2BGRPerfTest, TestPerformance)
880
{
881
compare_f cmpF = get<0>(GetParam());
882
Size sz = get<1>(GetParam());
883
cv::GCompileArgs compile_args = get<2>(GetParam());
884
885
initMatsRandN(CV_8UC3, sz, CV_8UC3, false);
886
887
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_YUV2BGR);
888
889
cv::GMat in;
890
auto out = cv::gapi::YUV2BGR(in);
891
cv::GComputation c(in, out);
892
893
// Warm-up graph engine:
894
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
895
896
TEST_CYCLE()
897
{
898
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
899
}
900
901
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
902
EXPECT_EQ(out_mat_gapi.size(), sz);
903
904
SANITY_CHECK_NOTHING();
905
}
906
907
//------------------------------------------------------------------------------
908
909
}
910
#endif //OPENCV_GAPI_IMGPROC_PERF_TESTS_INL_HPP
911
912