1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Merge pull request #18496 from AsyaPronina:comp_args_serialization

Serialization && deserialization for compile arguments

* Initial stub

* Add test on serialization of a custom type

* Namespaces rework

* Fix isSupported in test struct

* Fix clang lookup issue

* Initial implementation

* Drop the isSupported flag

* Initial implementation

* Removed internal header inclusion

* Switched to public API

* Implemented serialization

* Adding desirialize: WIP

* Fixed merge errors

* Implemented

* Final polishing

* Addressed review comments and added debug throw

* Added FluidROI test

* Polishing

* Polishing

* Polishing

* Polishing

* Polishing

* Updated CMakeLists.txt

* Fixed comments

* Addressed review comments

* Removed decay from deserialize_arg

* Addressed review comments

* Removed extra inclusion

* Fixed Win64 warning

* Update gcommon.hpp

* Update serialization.cpp

* Update gcommon.hpp

* gapi: drop GAPI_EXPORTS_W_SIMPLE from GCompileArg

Co-authored-by: Smirnov Alexey <alexey.smirnov@intel.com>
Co-authored-by: AsyaPronina <155jj@mail.ru>
This commit is contained in:
Anastasiya(Asya) Pronina
2020-10-08 00:48:49 +03:00
committed by GitHub
parent 46ccde82cf
commit af2f8c69f0
10 changed files with 180 additions and 20 deletions
+7
View File
@@ -44,6 +44,13 @@ std::vector<char> cv::gapi::serialize(const cv::GRunArgs& ra)
return os.data();
}
std::vector<char> cv::gapi::serialize(const cv::GCompileArgs& ca)
{
cv::gapi::s11n::ByteMemoryOutStream os;
serialize(os, ca);
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)
@@ -329,6 +329,13 @@ IIStream& operator>> (IIStream& is, cv::gapi::wip::draw::Line &l) {
// G-API types /////////////////////////////////////////////////////////////////
IOStream& operator<< (IOStream& os, const cv::GCompileArg& arg)
{
os << arg.tag;
arg.serialize(os);
return os;
}
// Stubs (empty types)
IOStream& operator<< (IOStream& os, cv::util::monostate ) {return os;}
@@ -865,6 +872,14 @@ IIStream& ByteMemoryInStream::operator>> (std::string& str) {
return *this;
}
GAPI_EXPORTS std::unique_ptr<IIStream> detail::getInStream(const std::vector<char> &p) {
return std::unique_ptr<ByteMemoryInStream>(new ByteMemoryInStream(p));
}
GAPI_EXPORTS void serialize(IOStream& os, const cv::GCompileArgs &ca) {
os << ca;
}
GAPI_EXPORTS void serialize(IOStream& os, const cv::GMetaArgs &ma) {
os << ma;
}
@@ -882,7 +897,6 @@ GAPI_EXPORTS GRunArgs run_args_deserialize(IIStream& is) {
return s;
}
} // namespace s11n
} // namespace gapi
} // namespace cv
@@ -40,6 +40,8 @@ struct GSerialized {
// G-API types /////////////////////////////////////////////////////////////////
GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::GCompileArg& arg);
GAPI_EXPORTS IOStream& operator<< (IOStream& os, cv::util::monostate );
GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::util::monostate &);
@@ -268,6 +270,11 @@ public:
virtual IIStream& operator>> (std::string &) override;
};
namespace detail {
GAPI_EXPORTS std::unique_ptr<IIStream> getInStream(const std::vector<char> &p);
} // namespace detail
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 GMetaArgs meta_args_deserialize(IIStream& is);