mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
gapi: Full calcOpticalFlowPyrLK implementation (2 overloads) and tests
- opencv_gapi module is linked with opencv_video module (optional dependency)
- kernels added to a new cv::gapi::video namespace and a brand new files created to provide gapi_video environment
- there are 2 different kernels as G-API should provide GMat AND GArray<GMat> implementation: cv::calcOptFlowPyrLK doesn't calculate pyramids if vector<Mat> is given so just the cast GMat -> GArray<GMat> wouldn't represent all the cv:: functionality
- tests to check both kernels (based on cv::video tests for cv::calcOpticalFlowPyrLK())
- tests for internal purposes added
- vectors<T> comparison in tests implemented
- new (and old too) common test structures refactored to avoid code copypasting
- "modules/gapi/test/common/gapi_video_tests_common.hpp" created to share some code snippets between perf and acc tests and avoid code copypasting
This commit is contained in:
@@ -49,5 +49,6 @@ class YUV2BGRPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCo
|
||||
class RGB2HSVPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
class BayerGR2RGBPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
class RGB2YUV422PerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
}
|
||||
} // opencv_test
|
||||
|
||||
#endif //OPENCV_GAPI_IMGPROC_PERF_TESTS_HPP
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
|
||||
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "gapi_video_perf_tests_inl.hpp"
|
||||
@@ -0,0 +1,26 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
|
||||
#ifndef OPENCV_GAPI_VIDEO_PERF_TESTS_HPP
|
||||
#define OPENCV_GAPI_VIDEO_PERF_TESTS_HPP
|
||||
|
||||
#include "../../test/common/gapi_video_tests_common.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
|
||||
using namespace perf;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
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>> {};
|
||||
} // opencv_test
|
||||
|
||||
#endif // OPENCV_GAPI_VIDEO_PERF_TESTS_HPP
|
||||
@@ -0,0 +1,90 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
|
||||
#ifndef OPENCV_GAPI_VIDEO_PERF_TESTS_INL_HPP
|
||||
#define OPENCV_GAPI_VIDEO_PERF_TESTS_INL_HPP
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "gapi_video_perf_tests.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
|
||||
using namespace perf;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
PERF_TEST_P_(OptFlowLKPerfTest, TestPerformance)
|
||||
{
|
||||
std::vector<cv::Point2f> outPtsOCV, outPtsGAPI, inPts;
|
||||
std::vector<uchar> outStatusOCV, outStatusGAPI;
|
||||
std::vector<float> outErrOCV, outErrGAPI;
|
||||
|
||||
OptFlowLKTestParams params;
|
||||
std::tie(params.fileNamePattern, params.channels,
|
||||
params.pointsNum, params.winSize, params.criteria,
|
||||
params.compileArgs) = GetParam();
|
||||
|
||||
OptFlowLKTestOutput outOCV { outPtsOCV, outStatusOCV, outErrOCV };
|
||||
OptFlowLKTestOutput outGAPI { outPtsGAPI, outStatusGAPI, outErrGAPI };
|
||||
|
||||
cv::GComputation c = runOCVnGAPIOptFlowLK(*this, inPts, params, outOCV, outGAPI);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
PERF_TEST_P_(OptFlowLKForPyrPerfTest, TestPerformance)
|
||||
{
|
||||
std::vector<cv::Mat> inPyr1, inPyr2;
|
||||
std::vector<cv::Point2f> outPtsOCV, outPtsGAPI, inPts;
|
||||
std::vector<uchar> outStatusOCV, outStatusGAPI;
|
||||
std::vector<float> outErrOCV, outErrGAPI;
|
||||
|
||||
bool withDeriv = false;
|
||||
OptFlowLKTestParams params;
|
||||
std::tie(params.fileNamePattern, params.channels,
|
||||
params.pointsNum, params.winSize, params.criteria,
|
||||
withDeriv, params.compileArgs) = GetParam();
|
||||
|
||||
OptFlowLKTestInput<std::vector<cv::Mat>> in { inPyr1, inPyr2, inPts };
|
||||
OptFlowLKTestOutput outOCV { outPtsOCV, outStatusOCV, outErrOCV };
|
||||
OptFlowLKTestOutput outGAPI { outPtsGAPI, outStatusGAPI, outErrGAPI };
|
||||
|
||||
cv::GComputation c = runOCVnGAPIOptFlowLKForPyr(*this, in, params, withDeriv, outOCV, outGAPI);
|
||||
|
||||
declare.in(inPyr1, inPyr2, inPts).out(outPtsGAPI, outStatusGAPI, outErrGAPI);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
c.apply(cv::gin(inPyr1, inPyr2, inPts, std::vector<cv::Point2f>{ }),
|
||||
cv::gout(outPtsGAPI, outStatusGAPI, outErrGAPI));
|
||||
}
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
compareOutputsOptFlow(outOCV, outGAPI);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
} // opencv_test
|
||||
|
||||
#endif // OPENCV_GAPI_VIDEO_PERF_TESTS_INL_HPP
|
||||
@@ -220,4 +220,4 @@ INSTANTIATE_TEST_CASE_P(RGB2YUV422PerfTestCPU, RGB2YUV422PerfTest,
|
||||
Combine(Values(ToleranceColor(1e-3).to_compare_f()),
|
||||
Values(szVGA, sz720p, sz1080p),
|
||||
Values(cv::compile_args(IMGPROC_CPU))));
|
||||
}
|
||||
} // opencv_test
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
|
||||
|
||||
#include "../perf_precomp.hpp"
|
||||
|
||||
#include "../common/gapi_video_perf_tests.hpp"
|
||||
#include <opencv2/gapi/cpu/video.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
#define VIDEO_CPU cv::gapi::video::cpu::kernels()
|
||||
|
||||
#ifdef HAVE_OPENCV_VIDEO
|
||||
#define WITH_VIDEO(X) X
|
||||
#else
|
||||
#define WITH_VIDEO(X) DISABLED_##X
|
||||
#endif // HAVE_OPENCV_VIDEO
|
||||
|
||||
#define INSTANTIATE_TEST_CASE_MACRO_P(prefix, test_case_name, generator, ...) \
|
||||
INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator, __VA_ARGS__)
|
||||
} // namespace
|
||||
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
INSTANTIATE_TEST_CASE_MACRO_P(WITH_VIDEO(OptFlowLKPerfTestCPU), OptFlowLKPerfTest,
|
||||
Combine(Values("cv/optflow/rock_%01d.bmp",
|
||||
"cv/optflow/frames/1080p_%02d.png"),
|
||||
Values(1, 3, 4),
|
||||
Values(std::make_tuple(9, 9), std::make_tuple(15, 15)),
|
||||
Values(7, 11),
|
||||
Values(cv::TermCriteria(cv::TermCriteria::COUNT |
|
||||
cv::TermCriteria::EPS,
|
||||
30, 0.01)),
|
||||
Values(cv::compile_args(VIDEO_CPU))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_MACRO_P(WITH_VIDEO(OptFlowLKForPyrPerfTestCPU), OptFlowLKForPyrPerfTest,
|
||||
Combine(Values("cv/optflow/rock_%01d.bmp",
|
||||
"cv/optflow/frames/1080p_%02d.png"),
|
||||
Values(1, 3, 4),
|
||||
Values(std::make_tuple(9, 9), std::make_tuple(15, 15)),
|
||||
Values(7, 11),
|
||||
Values(cv::TermCriteria(cv::TermCriteria::COUNT |
|
||||
cv::TermCriteria::EPS,
|
||||
30, 0.01)),
|
||||
Values(true, false),
|
||||
Values(cv::compile_args(VIDEO_CPU))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_MACRO_P(WITH_VIDEO(OptFlowLKInternalPerfTestCPU),
|
||||
OptFlowLKForPyrPerfTest,
|
||||
Combine(Values("cv/optflow/rock_%01d.bmp"),
|
||||
Values(1),
|
||||
Values(std::make_tuple(10, 10)),
|
||||
Values(15),
|
||||
Values(cv::TermCriteria(cv::TermCriteria::COUNT |
|
||||
cv::TermCriteria::EPS,
|
||||
21, 0.05)),
|
||||
Values(true),
|
||||
Values(cv::compile_args(VIDEO_CPU))));
|
||||
} // opencv_test
|
||||
@@ -2,7 +2,7 @@
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
// Copyright (C) 2018-2020 Intel Corporation
|
||||
|
||||
|
||||
#ifndef __OPENCV_GAPI_PERF_PRECOMP_HPP__
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <opencv2/ts.hpp>
|
||||
#include <opencv2/gapi.hpp>
|
||||
#include <opencv2/gapi/imgproc.hpp>
|
||||
#include <opencv2/gapi/video.hpp>
|
||||
#include <opencv2/gapi/core.hpp>
|
||||
#include <opencv2/gapi/cpu/gcpukernel.hpp>
|
||||
#include <opencv2/gapi/gpu/ggpukernel.hpp>
|
||||
|
||||
Reference in New Issue
Block a user