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

Merge pull request #19617 from smirnov-alexey:as/extend_kernel_package_api

G-API: Extend GKernelPackage and serialization API

* Extend GKernelPackage API

* Adding tests

* Extend serialization API

* Address review comments
This commit is contained in:
Alexey Smirnov
2021-03-10 18:58:34 +03:00
committed by GitHub
parent 04d907fb97
commit ddd2447192
8 changed files with 100 additions and 7 deletions
+11 -1
View File
@@ -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-2019 Intel Corporation
// Copyright (C) 2018-2021 Intel Corporation
#include "precomp.hpp"
@@ -55,6 +55,16 @@ const std::vector<cv::GTransform> &cv::gapi::GKernelPackage::get_transformations
return m_transformations;
}
std::vector<std::string> cv::gapi::GKernelPackage::get_kernel_ids() const
{
std::vector<std::string> ids;
for (auto &&id : m_id_kernels)
{
ids.emplace_back(id.first);
}
return ids;
}
cv::gapi::GKernelPackage cv::gapi::combine(const GKernelPackage &lhs,
const GKernelPackage &rhs)
{
+13 -1
View File
@@ -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) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
#include <opencv2/gapi/s11n.hpp>
#include <opencv2/gapi/garg.hpp>
@@ -30,6 +30,11 @@ cv::GRunArgs cv::gapi::detail::getRunArgs(const std::vector<char> &p) {
return run_args_deserialize(is);
}
std::vector<std::string> cv::gapi::detail::getVectorOfStrings(const std::vector<char> &p) {
cv::gapi::s11n::ByteMemoryInStream is(p);
return vector_of_strings_deserialize(is);
}
std::vector<char> cv::gapi::serialize(const cv::GMetaArgs& ma)
{
cv::gapi::s11n::ByteMemoryOutStream os;
@@ -51,6 +56,13 @@ std::vector<char> cv::gapi::serialize(const cv::GCompileArgs& ca)
return os.data();
}
std::vector<char> cv::gapi::serialize(const std::vector<std::string>& vs)
{
cv::gapi::s11n::ByteMemoryOutStream os;
serialize(os, vs);
return os.data();
}
// FIXME: This function should move from S11N to GRunArg-related entities.
// it has nothing to do with the S11N as it is
cv::GRunArgsP cv::gapi::bind(cv::GRunArgs &results)
@@ -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) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
#include <set> // set
#include <map> // map
@@ -906,6 +906,9 @@ GAPI_EXPORTS void serialize(IOStream& os, const cv::GMetaArgs &ma) {
GAPI_EXPORTS void serialize(IOStream& os, const cv::GRunArgs &ra) {
os << ra;
}
GAPI_EXPORTS void serialize(IOStream& os, const std::vector<std::string> &vs) {
os << vs;
}
GAPI_EXPORTS GMetaArgs meta_args_deserialize(IIStream& is) {
GMetaArgs s;
is >> s;
@@ -916,6 +919,11 @@ GAPI_EXPORTS GRunArgs run_args_deserialize(IIStream& is) {
is >> s;
return s;
}
GAPI_EXPORTS std::vector<std::string> vector_of_strings_deserialize(IIStream& is) {
std::vector<std::string> s;
is >> s;
return s;
}
} // namespace s11n
} // namespace gapi
@@ -5,7 +5,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) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
#include <iostream>
#include <fstream>
@@ -217,8 +217,10 @@ GAPI_EXPORTS std::unique_ptr<IIStream> getInStream(const std::vector<char> &p);
GAPI_EXPORTS void serialize(IOStream& os, const cv::GCompileArgs &ca);
GAPI_EXPORTS void serialize(IOStream& os, const cv::GMetaArgs &ma);
GAPI_EXPORTS void serialize(IOStream& os, const cv::GRunArgs &ra);
GAPI_EXPORTS void serialize(IOStream& os, const std::vector<std::string> &vs);
GAPI_EXPORTS GMetaArgs meta_args_deserialize(IIStream& is);
GAPI_EXPORTS GRunArgs run_args_deserialize(IIStream& is);
GAPI_EXPORTS std::vector<std::string> vector_of_strings_deserialize(IIStream& is);
} // namespace s11n
} // namespace gapi