1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53: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:
OrestChura
2020-04-08 17:05:43 +03:00
parent acede976e4
commit d50c21e571
22 changed files with 921 additions and 26 deletions
+27 -12
View File
@@ -196,25 +196,32 @@ public:
}
}
void initMatsFromImages(int channels, const std::string& pattern, int imgNum)
{
initTestDataPath();
GAPI_Assert(channels == 1 || channels == 3 || channels == 4);
const int flags = (channels == 1) ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR;
cv::Mat m1 = cv::imread(findDataFile(cv::format(pattern.c_str(), imgNum)), flags);
cv::Mat m2 = cv::imread(findDataFile(cv::format(pattern.c_str(), imgNum + 1)), flags);
if (channels == 4)
{
cvtColor(m1, in_mat1, cv::COLOR_BGR2BGRA);
cvtColor(m2, in_mat2, cv::COLOR_BGR2BGRA);
}
else
{
std::tie(in_mat1, in_mat2) = std::make_tuple(m1, m2);
}
}
// empty function intended to show that nothing is to be initialized via TestFunctional methods
void initNothing(int, cv::Size, int, bool = true) {}
};
template<class T>
class TestParams: public TestFunctional, public TestWithParam<T>{};
template<class T>
class TestPerfParams: public TestFunctional, public perf::TestBaseWithParam<T>{};
using compare_f = std::function<bool(const cv::Mat &a, const cv::Mat &b)>;
using compare_scalar_f = std::function<bool(const cv::Scalar &a, const cv::Scalar &b)>;
template<typename Elem>
using compare_vector_f = std::function<bool(const std::vector<Elem> &a,
const std::vector<Elem> &b)>;
// FIXME: re-use MatType. current problem: "special values" interpreted incorrectly (-1 is printed
// as 16FC512)
struct MatType2
@@ -368,6 +375,14 @@ struct TestWithParamsSpecific : public TestWithParamsBase<ParamsSpecific<Specifi
// Example: FIXTURE_API(int, bool) expands to <int, bool>
#define FIXTURE_API(...) <__VA_ARGS__>
using compare_f = std::function<bool(const cv::Mat &a, const cv::Mat &b)>;
using compare_scalar_f = std::function<bool(const cv::Scalar &a, const cv::Scalar &b)>;
template<typename Elem>
using compare_vector_f = std::function<bool(const std::vector<Elem> &a,
const std::vector<Elem> &b)>;
template<typename T1, typename T2>
struct CompareF
{