1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

gapi: buildOpticalFlowPyramid() interface, CPUkernel and CPUtests implementation

- kernel added to a cv::gapi::video namespace
     - tests to check a kernels (based on cv::video tests for cv::buildOpticalFlowPyramid())
     - tests for a combined G-API-pipeline (buildOpticalFlowPyramid() -> calcOpticalFlowPyrLK())
     - tests for internal purposes added
     - custom function for comparison in tests implemented
This commit is contained in:
OrestChura
2020-04-14 00:53:01 +03:00
parent f19d0ae41d
commit 05d5c284f6
11 changed files with 487 additions and 41 deletions
@@ -16,11 +16,16 @@ using namespace perf;
//------------------------------------------------------------------------------
class BuildOptFlowPyramidPerfTest : public TestPerfParams<tuple<std::string,int,int,bool,int,int,
bool,GCompileArgs>> {};
class OptFlowLKPerfTest : public TestPerfParams<tuple<std::string,int,tuple<int,int>,int,
cv::TermCriteria,cv::GCompileArgs>> {};
class OptFlowLKForPyrPerfTest : public TestPerfParams<tuple<std::string,int,tuple<int,int>,int,
cv::TermCriteria,bool,
cv::GCompileArgs>> {};
class BuildPyr_CalcOptFlow_PipelinePerfTest : public TestPerfParams<tuple<std::string,int,int,bool,
cv::GCompileArgs>> {};
} // opencv_test
#endif // OPENCV_GAPI_VIDEO_PERF_TESTS_HPP
@@ -18,6 +18,37 @@ namespace opencv_test
//------------------------------------------------------------------------------
PERF_TEST_P_(BuildOptFlowPyramidPerfTest, TestPerformance)
{
std::vector<Mat> outPyrOCV, outPyrGAPI;
int outMaxLevelOCV = 0, outMaxLevelGAPI = 0;
Scalar outMaxLevelSc;
BuildOpticalFlowPyramidTestParams params;
std::tie(params.fileName, params.winSize,
params.maxLevel, params.withDerivatives,
params.pyrBorder, params.derivBorder,
params.tryReuseInputImage, params.compileArgs) = GetParam();
BuildOpticalFlowPyramidTestOutput outOCV { outPyrOCV, outMaxLevelOCV };
BuildOpticalFlowPyramidTestOutput outGAPI { outPyrGAPI, outMaxLevelGAPI };
GComputation c = runOCVnGAPIBuildOptFlowPyramid(*this, params, outOCV, outGAPI);
declare.in(in_mat1).out(outPyrGAPI);
TEST_CYCLE()
{
c.apply(cv::gin(in_mat1), cv::gout(outPyrGAPI, outMaxLevelSc));
}
outMaxLevelGAPI = static_cast<int>(outMaxLevelSc[0]);
// Comparison //////////////////////////////////////////////////////////////
compareOutputPyramids(outOCV, outGAPI);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P_(OptFlowLKPerfTest, TestPerformance)
{
std::vector<cv::Point2f> outPtsOCV, outPtsGAPI, inPts;
@@ -83,6 +114,44 @@ PERF_TEST_P_(OptFlowLKForPyrPerfTest, TestPerformance)
SANITY_CHECK_NOTHING();
}
PERF_TEST_P_(BuildPyr_CalcOptFlow_PipelinePerfTest, TestPerformance)
{
std::vector<Point2f> outPtsOCV, outPtsGAPI, inPts;
std::vector<uchar> outStatusOCV, outStatusGAPI;
std::vector<float> outErrOCV, outErrGAPI;
BuildOpticalFlowPyramidTestParams params;
params.pyrBorder = BORDER_DEFAULT;
params.derivBorder = BORDER_DEFAULT;
params.tryReuseInputImage = true;
std::tie(params.fileName, params.winSize,
params.maxLevel, params.withDerivatives,
params.compileArgs) = GetParam();
auto customKernel = gapi::kernels<GCPUMinScalar>();
auto kernels = gapi::combine(customKernel,
params.compileArgs[0].get<gapi::GKernelPackage>());
params.compileArgs = compile_args(kernels);
OptFlowLKTestOutput outOCV { outPtsOCV, outStatusOCV, outErrOCV };
OptFlowLKTestOutput outGAPI { outPtsGAPI, outStatusGAPI, outErrGAPI };
cv::GComputation c = runOCVnGAPIOptFlowPipeline(*this, params, outOCV, outGAPI, inPts);
declare.in(in_mat1, in_mat2, inPts).out(outPtsGAPI, outStatusGAPI, outErrGAPI);
TEST_CYCLE()
{
c.apply(cv::gin(in_mat1, in_mat2, inPts, std::vector<cv::Point2f>{ }),
cv::gout(outPtsGAPI, outStatusGAPI, outErrGAPI));
}
// Comparison //////////////////////////////////////////////////////////////
compareOutputsOptFlow(outOCV, outGAPI);
SANITY_CHECK_NOTHING();
}
//------------------------------------------------------------------------------
} // opencv_test