Skip to content

Commit fcdd69f

Browse files
authored
Merge pull request opencv#19103 from OrestChura:oc/cvtI420_perftests
[G-API]: Performance tests for color conversion kernels * Performance tests for 5 new color conversion kernels: - BGR2RGB - BGR2I420 - RGB2I420 - I4202BGR - I4202RGB * Addressing comment
1 parent 46e275d commit fcdd69f

File tree

4 files changed

+222
-2
lines changed

4 files changed

+222
-2
lines changed

modules/gapi/perf/common/gapi_imgproc_perf_tests.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ class GoodFeaturesPerfTest : public TestPerfParams<tuple<compare_vector_f<cv:
4242
int,int,double,double,int,bool,
4343
cv::GCompileArgs>> {};
4444
class EqHistPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
45+
class BGR2RGBPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
4546
class RGB2GrayPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
4647
class BGR2GrayPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
4748
class RGB2YUVPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
4849
class YUV2RGBPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
50+
class BGR2I420PerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
51+
class RGB2I420PerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
52+
class I4202BGRPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
53+
class I4202RGBPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
4954
class RGB2LabPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
5055
class BGR2LUVPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
5156
class LUV2BGRPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};

modules/gapi/perf/common/gapi_imgproc_perf_tests_inl.hpp

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,44 @@ PERF_TEST_P_(EqHistPerfTest, TestPerformance)
788788

789789
//------------------------------------------------------------------------------
790790

791+
PERF_TEST_P_(BGR2RGBPerfTest, TestPerformance)
792+
{
793+
compare_f cmpF;
794+
cv::Size sz;
795+
cv::GCompileArgs compile_args;
796+
std::tie(cmpF, sz, compile_args) = GetParam();
797+
798+
initMatrixRandN(CV_8UC3, sz, CV_8UC3, false);
799+
800+
// OpenCV code /////////////////////////////////////////////////////////////
801+
{
802+
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_BGR2RGB);
803+
}
804+
805+
// G-API code //////////////////////////////////////////////////////////////
806+
cv::GMat in;
807+
auto out = cv::gapi::BGR2RGB(in);
808+
cv::GComputation c(in, out);
809+
810+
// Warm-up graph engine:
811+
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
812+
813+
TEST_CYCLE()
814+
{
815+
c.apply(in_mat1, out_mat_gapi);
816+
}
817+
818+
// Comparison //////////////////////////////////////////////////////////////
819+
{
820+
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
821+
EXPECT_EQ(out_mat_gapi.size(), sz);
822+
}
823+
824+
SANITY_CHECK_NOTHING();
825+
}
826+
827+
//------------------------------------------------------------------------------
828+
791829
PERF_TEST_P_(RGB2GrayPerfTest, TestPerformance)
792830
{
793831
compare_f cmpF = get<0>(GetParam());
@@ -940,6 +978,158 @@ PERF_TEST_P_(YUV2RGBPerfTest, TestPerformance)
940978

941979
//------------------------------------------------------------------------------
942980

981+
PERF_TEST_P_(BGR2I420PerfTest, TestPerformance)
982+
{
983+
compare_f cmpF;
984+
cv::Size sz;
985+
cv::GCompileArgs compile_args;
986+
std::tie(cmpF, sz, compile_args) = GetParam();
987+
988+
initMatrixRandN(CV_8UC3, sz, CV_8UC1, false);
989+
990+
// OpenCV code /////////////////////////////////////////////////////////////
991+
{
992+
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_BGR2YUV_I420);
993+
}
994+
995+
// G-API code //////////////////////////////////////////////////////////////
996+
cv::GMat in;
997+
auto out = cv::gapi::BGR2I420(in);
998+
cv::GComputation c(in, out);
999+
1000+
// Warm-up graph engine:
1001+
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
1002+
1003+
TEST_CYCLE()
1004+
{
1005+
c.apply(in_mat1, out_mat_gapi);
1006+
}
1007+
1008+
// Comparison //////////////////////////////////////////////////////////////
1009+
{
1010+
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
1011+
EXPECT_EQ(out_mat_gapi.size(), Size(sz.width, sz.height * 3 / 2));
1012+
}
1013+
1014+
SANITY_CHECK_NOTHING();
1015+
}
1016+
1017+
//------------------------------------------------------------------------------
1018+
1019+
PERF_TEST_P_(RGB2I420PerfTest, TestPerformance)
1020+
{
1021+
compare_f cmpF;
1022+
cv::Size sz;
1023+
cv::GCompileArgs compile_args;
1024+
std::tie(cmpF, sz, compile_args) = GetParam();
1025+
1026+
initMatrixRandN(CV_8UC3, sz, CV_8UC1, false);
1027+
1028+
// OpenCV code /////////////////////////////////////////////////////////////
1029+
{
1030+
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_RGB2YUV_I420);
1031+
}
1032+
1033+
// G-API code //////////////////////////////////////////////////////////////
1034+
cv::GMat in;
1035+
auto out = cv::gapi::RGB2I420(in);
1036+
cv::GComputation c(in, out);
1037+
1038+
// Warm-up graph engine:
1039+
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
1040+
1041+
TEST_CYCLE()
1042+
{
1043+
c.apply(in_mat1, out_mat_gapi);
1044+
}
1045+
1046+
// Comparison //////////////////////////////////////////////////////////////
1047+
{
1048+
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
1049+
EXPECT_EQ(out_mat_gapi.size(), Size(sz.width, sz.height * 3 / 2));
1050+
}
1051+
1052+
SANITY_CHECK_NOTHING();
1053+
}
1054+
1055+
//------------------------------------------------------------------------------
1056+
1057+
PERF_TEST_P_(I4202BGRPerfTest, TestPerformance)
1058+
{
1059+
compare_f cmpF;
1060+
cv::Size sz;
1061+
cv::GCompileArgs compile_args;
1062+
std::tie(cmpF, sz, compile_args) = GetParam();
1063+
1064+
initMatrixRandN(CV_8UC1, sz, CV_8UC3, false);
1065+
1066+
// OpenCV code /////////////////////////////////////////////////////////////
1067+
{
1068+
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_YUV2BGR_I420);
1069+
}
1070+
1071+
// G-API code //////////////////////////////////////////////////////////////
1072+
cv::GMat in;
1073+
auto out = cv::gapi::I4202BGR(in);
1074+
cv::GComputation c(in, out);
1075+
1076+
// Warm-up graph engine:
1077+
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
1078+
1079+
TEST_CYCLE()
1080+
{
1081+
c.apply(in_mat1, out_mat_gapi);
1082+
}
1083+
1084+
// Comparison //////////////////////////////////////////////////////////////
1085+
{
1086+
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
1087+
EXPECT_EQ(out_mat_gapi.size(), Size(sz.width, sz.height * 2 / 3));
1088+
}
1089+
1090+
SANITY_CHECK_NOTHING();
1091+
}
1092+
1093+
//------------------------------------------------------------------------------
1094+
1095+
PERF_TEST_P_(I4202RGBPerfTest, TestPerformance)
1096+
{
1097+
compare_f cmpF;
1098+
cv::Size sz;
1099+
cv::GCompileArgs compile_args;
1100+
std::tie(cmpF, sz, compile_args) = GetParam();
1101+
1102+
initMatrixRandN(CV_8UC1, sz, CV_8UC3, false);
1103+
1104+
// OpenCV code /////////////////////////////////////////////////////////////
1105+
{
1106+
cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_YUV2RGB_I420);
1107+
}
1108+
1109+
// G-API code //////////////////////////////////////////////////////////////
1110+
cv::GMat in;
1111+
auto out = cv::gapi::I4202RGB(in);
1112+
cv::GComputation c(in, out);
1113+
1114+
// Warm-up graph engine:
1115+
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
1116+
1117+
TEST_CYCLE()
1118+
{
1119+
c.apply(in_mat1, out_mat_gapi);
1120+
}
1121+
1122+
// Comparison //////////////////////////////////////////////////////////////
1123+
{
1124+
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
1125+
EXPECT_EQ(out_mat_gapi.size(), Size(sz.width, sz.height * 2 / 3));
1126+
}
1127+
1128+
SANITY_CHECK_NOTHING();
1129+
}
1130+
1131+
//------------------------------------------------------------------------------
1132+
9431133
PERF_TEST_P_(RGB2LabPerfTest, TestPerformance)
9441134
{
9451135
compare_f cmpF = get<0>(GetParam());

modules/gapi/perf/cpu/gapi_imgproc_perf_tests_cpu.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ INSTANTIATE_TEST_CASE_P(EqHistPerfTestCPU, EqHistPerfTest,
179179
Values(szVGA, sz720p, sz1080p),
180180
Values(cv::compile_args(IMGPROC_CPU))));
181181

182+
INSTANTIATE_TEST_CASE_P(BGR2RGBPerfTestCPU, BGR2RGBPerfTest,
183+
Combine(Values(AbsExact().to_compare_f()),
184+
Values(szVGA, sz720p, sz1080p),
185+
Values(cv::compile_args(IMGPROC_CPU))));
186+
182187
INSTANTIATE_TEST_CASE_P(RGB2GrayPerfTestCPU, RGB2GrayPerfTest,
183188
Combine(Values(AbsExact().to_compare_f()),
184189
Values(szVGA, sz720p, sz1080p),
@@ -199,6 +204,26 @@ INSTANTIATE_TEST_CASE_P(YUV2RGBPerfTestCPU, YUV2RGBPerfTest,
199204
Values(szVGA, sz720p, sz1080p),
200205
Values(cv::compile_args(IMGPROC_CPU))));
201206

207+
INSTANTIATE_TEST_CASE_P(BGR2I420PerfTestCPU, BGR2I420PerfTest,
208+
Combine(Values(AbsExact().to_compare_f()),
209+
Values(szVGA, sz720p, sz1080p),
210+
Values(cv::compile_args(IMGPROC_CPU))));
211+
212+
INSTANTIATE_TEST_CASE_P(RGB2I420PerfTestCPU, RGB2I420PerfTest,
213+
Combine(Values(AbsExact().to_compare_f()),
214+
Values(szVGA, sz720p, sz1080p),
215+
Values(cv::compile_args(IMGPROC_CPU))));
216+
217+
INSTANTIATE_TEST_CASE_P(I4202BGRPerfTestCPU, I4202BGRPerfTest,
218+
Combine(Values(AbsExact().to_compare_f()),
219+
Values(szVGA, sz720p, sz1080p),
220+
Values(cv::compile_args(IMGPROC_CPU))));
221+
222+
INSTANTIATE_TEST_CASE_P(I4202RGBPerfTestCPU, I4202RGBPerfTest,
223+
Combine(Values(AbsExact().to_compare_f()),
224+
Values(szVGA, sz720p, sz1080p),
225+
Values(cv::compile_args(IMGPROC_CPU))));
226+
202227
INSTANTIATE_TEST_CASE_P(RGB2LabPerfTestCPU, RGB2LabPerfTest,
203228
Combine(Values(AbsExact().to_compare_f()),
204229
Values(szVGA, sz720p, sz1080p),

modules/gapi/test/common/gapi_imgproc_tests.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ GAPI_TEST_FIXTURE(BoundingRectMatVector32STest, initNothing, FIXTURE_API(Compare
8181
GAPI_TEST_FIXTURE(BoundingRectMatVector32FTest, initNothing, FIXTURE_API(CompareRects), 1, cmpF)
8282
GAPI_TEST_FIXTURE(BoundingRectVector32STest, initNothing, FIXTURE_API(CompareRects), 1, cmpF)
8383
GAPI_TEST_FIXTURE(BoundingRectVector32FTest, initNothing, FIXTURE_API(CompareRects), 1, cmpF)
84-
GAPI_TEST_FIXTURE(BGR2RGBTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
85-
GAPI_TEST_FIXTURE(RGB2GrayTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
8684
GAPI_TEST_FIXTURE(FitLine2DMatVectorTest, initMatByPointsVectorRandU<cv::Point_>,
8785
FIXTURE_API(CompareVecs<float, 4>,cv::DistanceTypes), 2, cmpF, distType)
8886
GAPI_TEST_FIXTURE(FitLine2DVector32STest, initNothing,
@@ -99,6 +97,8 @@ GAPI_TEST_FIXTURE(FitLine3DVector32FTest, initNothing,
9997
FIXTURE_API(CompareVecs<float, 6>,cv::DistanceTypes), 2, cmpF, distType)
10098
GAPI_TEST_FIXTURE(FitLine3DVector64FTest, initNothing,
10199
FIXTURE_API(CompareVecs<float, 6>,cv::DistanceTypes), 2, cmpF, distType)
100+
GAPI_TEST_FIXTURE(BGR2RGBTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
101+
GAPI_TEST_FIXTURE(RGB2GrayTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
102102
GAPI_TEST_FIXTURE(BGR2GrayTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
103103
GAPI_TEST_FIXTURE(RGB2YUVTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
104104
GAPI_TEST_FIXTURE(BGR2I420Test, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)

0 commit comments

Comments
 (0)