Skip to content

Commit e982ad2

Browse files
authored
Merge pull request opencv#19337 from OrestChura:oc/fLine_fCont_perftests
[G-API]: Performance tests for fitLine and findContours * Perf.Test for findContours(H) * Perf.Test for fitLine(2D.3D;Mat,vector<Point2i/2f/2d/3i/3f/3d>) * Reducing the template specializations number * Applying comments
1 parent cd59516 commit e982ad2

File tree

7 files changed

+551
-265
lines changed

7 files changed

+551
-265
lines changed

modules/gapi/perf/common/gapi_imgproc_perf_tests.hpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,44 @@ class CannyPerfTest : public TestPerfParams<tuple<compare_f, MatType,c
4343
class GoodFeaturesPerfTest : public TestPerfParams<tuple<compare_vector_f<cv::Point2f>, std::string,
4444
int,int,double,double,int,bool,
4545
cv::GCompileArgs>> {};
46+
class FindContoursPerfTest : public TestPerfParams<tuple<CompareMats, MatType,cv::Size,
47+
cv::RetrievalModes,
48+
cv::ContourApproximationModes,
49+
cv::GCompileArgs>> {};
50+
class FindContoursHPerfTest : public TestPerfParams<tuple<CompareMats, MatType,cv::Size,
51+
cv::RetrievalModes,
52+
cv::ContourApproximationModes,
53+
cv::GCompileArgs>> {};
4654
class BoundingRectMatPerfTest :
4755
public TestPerfParams<tuple<CompareRects, MatType,cv::Size,bool, cv::GCompileArgs>> {};
4856
class BoundingRectVector32SPerfTest :
4957
public TestPerfParams<tuple<CompareRects, cv::Size, cv::GCompileArgs>> {};
5058
class BoundingRectVector32FPerfTest :
5159
public TestPerfParams<tuple<CompareRects, cv::Size, cv::GCompileArgs>> {};
60+
class FitLine2DMatVectorPerfTest : public TestPerfParams<tuple<CompareVecs<float, 4>,
61+
MatType,cv::Size,cv::DistanceTypes,
62+
cv::GCompileArgs>> {};
63+
class FitLine2DVector32SPerfTest : public TestPerfParams<tuple<CompareVecs<float, 4>,
64+
cv::Size,cv::DistanceTypes,
65+
cv::GCompileArgs>> {};
66+
class FitLine2DVector32FPerfTest : public TestPerfParams<tuple<CompareVecs<float, 4>,
67+
cv::Size,cv::DistanceTypes,
68+
cv::GCompileArgs>> {};
69+
class FitLine2DVector64FPerfTest : public TestPerfParams<tuple<CompareVecs<float, 4>,
70+
cv::Size,cv::DistanceTypes,
71+
cv::GCompileArgs>> {};
72+
class FitLine3DMatVectorPerfTest : public TestPerfParams<tuple<CompareVecs<float, 6>,
73+
MatType,cv::Size,cv::DistanceTypes,
74+
cv::GCompileArgs>> {};
75+
class FitLine3DVector32SPerfTest : public TestPerfParams<tuple<CompareVecs<float, 6>,
76+
cv::Size,cv::DistanceTypes,
77+
cv::GCompileArgs>> {};
78+
class FitLine3DVector32FPerfTest : public TestPerfParams<tuple<CompareVecs<float, 6>,
79+
cv::Size,cv::DistanceTypes,
80+
cv::GCompileArgs>> {};
81+
class FitLine3DVector64FPerfTest : public TestPerfParams<tuple<CompareVecs<float, 6>,
82+
cv::Size,cv::DistanceTypes,
83+
cv::GCompileArgs>> {};
5284
class EqHistPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
5385
class BGR2RGBPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
5486
class RGB2GrayPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};

modules/gapi/perf/common/gapi_imgproc_perf_tests_inl.hpp

Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,64 @@ PERF_TEST_P_(GoodFeaturesPerfTest, TestPerformance)
795795

796796
//------------------------------------------------------------------------------
797797

798+
PERF_TEST_P_(FindContoursPerfTest, TestPerformance)
799+
{
800+
CompareMats cmpF;
801+
MatType type;
802+
cv::Size sz;
803+
cv::RetrievalModes mode;
804+
cv::ContourApproximationModes method;
805+
cv::GCompileArgs compile_args;
806+
std::tie(cmpF, type, sz, mode, method, compile_args) = GetParam();
807+
808+
cv::Mat in;
809+
initMatForFindingContours(in, sz, type);
810+
cv::Point offset = cv::Point();
811+
std::vector<cv::Vec4i> out_hier_gapi = std::vector<cv::Vec4i>();
812+
813+
std::vector<std::vector<cv::Point>> out_cnts_gapi;
814+
cv::GComputation c(findContoursTestGAPI(in, mode, method, std::move(compile_args),
815+
out_cnts_gapi, out_hier_gapi, offset));
816+
817+
TEST_CYCLE()
818+
{
819+
c.apply(gin(in, offset), gout(out_cnts_gapi));
820+
}
821+
822+
findContoursTestOpenCVCompare(in, mode, method, out_cnts_gapi, out_hier_gapi, cmpF);
823+
SANITY_CHECK_NOTHING();
824+
}
825+
826+
PERF_TEST_P_(FindContoursHPerfTest, TestPerformance)
827+
{
828+
CompareMats cmpF;
829+
MatType type;
830+
cv::Size sz;
831+
cv::RetrievalModes mode;
832+
cv::ContourApproximationModes method;
833+
cv::GCompileArgs compile_args;
834+
std::tie(cmpF, type, sz, mode, method, compile_args) = GetParam();
835+
836+
cv::Mat in;
837+
initMatForFindingContours(in, sz, type);
838+
cv::Point offset = cv::Point();
839+
840+
std::vector<std::vector<cv::Point>> out_cnts_gapi;
841+
std::vector<cv::Vec4i> out_hier_gapi;
842+
cv::GComputation c(findContoursTestGAPI<HIERARCHY>(in, mode, method, std::move(compile_args),
843+
out_cnts_gapi, out_hier_gapi, offset));
844+
845+
TEST_CYCLE()
846+
{
847+
c.apply(gin(in, offset), gout(out_cnts_gapi, out_hier_gapi));
848+
}
849+
850+
findContoursTestOpenCVCompare<HIERARCHY>(in, mode, method, out_cnts_gapi, out_hier_gapi, cmpF);
851+
SANITY_CHECK_NOTHING();
852+
}
853+
854+
//------------------------------------------------------------------------------
855+
798856
PERF_TEST_P_(BoundingRectMatPerfTest, TestPerformance)
799857
{
800858
CompareRects cmpF;
@@ -871,6 +929,198 @@ PERF_TEST_P_(BoundingRectVector32FPerfTest, TestPerformance)
871929

872930
//------------------------------------------------------------------------------
873931

932+
PERF_TEST_P_(FitLine2DMatVectorPerfTest, TestPerformance)
933+
{
934+
CompareVecs<float, 4> cmpF;
935+
cv::Size sz;
936+
MatType type;
937+
cv::DistanceTypes distType;
938+
cv::GCompileArgs compile_args;
939+
std::tie(cmpF, type, sz, distType, compile_args) = GetParam();
940+
941+
initMatByPointsVectorRandU<cv::Point_>(type, sz, -1);
942+
943+
cv::Vec4f out_vec_gapi;
944+
cv::GComputation c(fitLineTestGAPI(in_mat1, distType, std::move(compile_args), out_vec_gapi));
945+
946+
TEST_CYCLE()
947+
{
948+
c.apply(cv::gin(in_mat1), cv::gout(out_vec_gapi));
949+
}
950+
951+
fitLineTestOpenCVCompare(in_mat1, distType, out_vec_gapi, cmpF);
952+
SANITY_CHECK_NOTHING();
953+
}
954+
955+
PERF_TEST_P_(FitLine2DVector32SPerfTest, TestPerformance)
956+
{
957+
CompareVecs<float, 4> cmpF;
958+
cv::Size sz;
959+
cv::DistanceTypes distType;
960+
cv::GCompileArgs compile_args;
961+
std::tie(cmpF, sz, distType, compile_args) = GetParam();
962+
963+
std::vector<cv::Point2i> in_vector;
964+
initPointsVectorRandU(sz.width, in_vector);
965+
966+
cv::Vec4f out_vec_gapi;
967+
cv::GComputation c(fitLineTestGAPI(in_vector, distType, std::move(compile_args),
968+
out_vec_gapi));
969+
970+
TEST_CYCLE()
971+
{
972+
c.apply(cv::gin(in_vector), cv::gout(out_vec_gapi));
973+
}
974+
975+
fitLineTestOpenCVCompare(in_vector, distType, out_vec_gapi, cmpF);
976+
SANITY_CHECK_NOTHING();
977+
}
978+
979+
PERF_TEST_P_(FitLine2DVector32FPerfTest, TestPerformance)
980+
{
981+
CompareVecs<float, 4> cmpF;
982+
cv::Size sz;
983+
cv::DistanceTypes distType;
984+
cv::GCompileArgs compile_args;
985+
std::tie(cmpF, sz, distType, compile_args) = GetParam();
986+
987+
std::vector<cv::Point2f> in_vector;
988+
initPointsVectorRandU(sz.width, in_vector);
989+
990+
cv::Vec4f out_vec_gapi;
991+
cv::GComputation c(fitLineTestGAPI(in_vector, distType, std::move(compile_args),
992+
out_vec_gapi));
993+
994+
TEST_CYCLE()
995+
{
996+
c.apply(cv::gin(in_vector), cv::gout(out_vec_gapi));
997+
}
998+
999+
fitLineTestOpenCVCompare(in_vector, distType, out_vec_gapi, cmpF);
1000+
SANITY_CHECK_NOTHING();
1001+
}
1002+
1003+
PERF_TEST_P_(FitLine2DVector64FPerfTest, TestPerformance)
1004+
{
1005+
CompareVecs<float, 4> cmpF;
1006+
cv::Size sz;
1007+
cv::DistanceTypes distType;
1008+
cv::GCompileArgs compile_args;
1009+
std::tie(cmpF, sz, distType, compile_args) = GetParam();
1010+
1011+
std::vector<cv::Point2d> in_vector;
1012+
initPointsVectorRandU(sz.width, in_vector);
1013+
1014+
cv::Vec4f out_vec_gapi;
1015+
cv::GComputation c(fitLineTestGAPI(in_vector, distType, std::move(compile_args),
1016+
out_vec_gapi));
1017+
1018+
TEST_CYCLE()
1019+
{
1020+
c.apply(cv::gin(in_vector), cv::gout(out_vec_gapi));
1021+
}
1022+
1023+
fitLineTestOpenCVCompare(in_vector, distType, out_vec_gapi, cmpF);
1024+
SANITY_CHECK_NOTHING();
1025+
}
1026+
1027+
PERF_TEST_P_(FitLine3DMatVectorPerfTest, TestPerformance)
1028+
{
1029+
CompareVecs<float, 6> cmpF;
1030+
cv::Size sz;
1031+
MatType type;
1032+
cv::DistanceTypes distType;
1033+
cv::GCompileArgs compile_args;
1034+
std::tie(cmpF, type, sz, distType, compile_args) = GetParam();
1035+
1036+
initMatByPointsVectorRandU<cv::Point3_>(type, sz, -1);
1037+
1038+
cv::Vec6f out_vec_gapi;
1039+
cv::GComputation c(fitLineTestGAPI(in_mat1, distType, std::move(compile_args), out_vec_gapi));
1040+
1041+
TEST_CYCLE()
1042+
{
1043+
c.apply(cv::gin(in_mat1), cv::gout(out_vec_gapi));
1044+
}
1045+
1046+
fitLineTestOpenCVCompare(in_mat1, distType, out_vec_gapi, cmpF);
1047+
SANITY_CHECK_NOTHING();
1048+
}
1049+
1050+
PERF_TEST_P_(FitLine3DVector32SPerfTest, TestPerformance)
1051+
{
1052+
CompareVecs<float, 6> cmpF;
1053+
cv::Size sz;
1054+
cv::DistanceTypes distType;
1055+
cv::GCompileArgs compile_args;
1056+
std::tie(cmpF, sz, distType, compile_args) = GetParam();
1057+
1058+
std::vector<cv::Point3i> in_vector;
1059+
initPointsVectorRandU(sz.width, in_vector);
1060+
1061+
cv::Vec6f out_vec_gapi;
1062+
cv::GComputation c(fitLineTestGAPI(in_vector, distType, std::move(compile_args),
1063+
out_vec_gapi));
1064+
1065+
TEST_CYCLE()
1066+
{
1067+
c.apply(cv::gin(in_vector), cv::gout(out_vec_gapi));
1068+
}
1069+
1070+
fitLineTestOpenCVCompare(in_vector, distType, out_vec_gapi, cmpF);
1071+
SANITY_CHECK_NOTHING();
1072+
}
1073+
1074+
PERF_TEST_P_(FitLine3DVector32FPerfTest, TestPerformance)
1075+
{
1076+
CompareVecs<float, 6> cmpF;
1077+
cv::Size sz;
1078+
cv::DistanceTypes distType;
1079+
cv::GCompileArgs compile_args;
1080+
std::tie(cmpF, sz, distType, compile_args) = GetParam();
1081+
1082+
std::vector<cv::Point3f> in_vector;
1083+
initPointsVectorRandU(sz.width, in_vector);
1084+
1085+
cv::Vec6f out_vec_gapi;
1086+
cv::GComputation c(fitLineTestGAPI(in_vector, distType, std::move(compile_args),
1087+
out_vec_gapi));
1088+
1089+
TEST_CYCLE()
1090+
{
1091+
c.apply(cv::gin(in_vector), cv::gout(out_vec_gapi));
1092+
}
1093+
1094+
fitLineTestOpenCVCompare(in_vector, distType, out_vec_gapi, cmpF);
1095+
SANITY_CHECK_NOTHING();
1096+
}
1097+
1098+
PERF_TEST_P_(FitLine3DVector64FPerfTest, TestPerformance)
1099+
{
1100+
CompareVecs<float, 6> cmpF;
1101+
cv::Size sz;
1102+
cv::DistanceTypes distType;
1103+
cv::GCompileArgs compile_args;
1104+
std::tie(cmpF, sz, distType, compile_args) = GetParam();
1105+
1106+
std::vector<cv::Point3d> in_vector;
1107+
initPointsVectorRandU(sz.width, in_vector);
1108+
1109+
cv::Vec6f out_vec_gapi;
1110+
cv::GComputation c(fitLineTestGAPI(in_vector, distType, std::move(compile_args),
1111+
out_vec_gapi));
1112+
1113+
TEST_CYCLE()
1114+
{
1115+
c.apply(cv::gin(in_vector), cv::gout(out_vec_gapi));
1116+
}
1117+
1118+
fitLineTestOpenCVCompare(in_vector, distType, out_vec_gapi, cmpF);
1119+
SANITY_CHECK_NOTHING();
1120+
}
1121+
1122+
//------------------------------------------------------------------------------
1123+
8741124
PERF_TEST_P_(EqHistPerfTest, TestPerformance)
8751125
{
8761126
compare_f cmpF = get<0>(GetParam());

0 commit comments

Comments
 (0)