// 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-2021 Intel Corporation #include #include #include "backends/common/serialization.hpp" std::vector cv::gapi::serialize(const cv::GComputation &c) { cv::gapi::s11n::ByteMemoryOutStream os; c.serialize(os); return os.data(); } cv::GComputation cv::gapi::detail::getGraph(const std::vector &p) { cv::gapi::s11n::ByteMemoryInStream is(p); return cv::GComputation(is); } cv::GMetaArgs cv::gapi::detail::getMetaArgs(const std::vector &p) { cv::gapi::s11n::ByteMemoryInStream is(p); return meta_args_deserialize(is); } cv::GRunArgs cv::gapi::detail::getRunArgs(const std::vector &p) { cv::gapi::s11n::ByteMemoryInStream is(p); return run_args_deserialize(is); } std::vector cv::gapi::detail::getVectorOfStrings(const std::vector &p) { cv::gapi::s11n::ByteMemoryInStream is(p); return vector_of_strings_deserialize(is); } std::vector cv::gapi::serialize(const cv::GMetaArgs& ma) { cv::gapi::s11n::ByteMemoryOutStream os; serialize(os, ma); return os.data(); } std::vector cv::gapi::serialize(const cv::GRunArgs& ra) { cv::gapi::s11n::ByteMemoryOutStream os; serialize(os, ra); return os.data(); } std::vector cv::gapi::serialize(const cv::GCompileArgs& ca) { cv::gapi::s11n::ByteMemoryOutStream os; serialize(os, ca); return os.data(); } std::vector cv::gapi::serialize(const std::vector& 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 &out_args) { cv::GRunArgsP outputs; outputs.reserve(out_args.size()); for (cv::GRunArg &res_obj : out_args) { using T = cv::GRunArg; switch (res_obj.index()) { #if !defined(GAPI_STANDALONE) case T::index_of() : outputs.emplace_back(&(cv::util::get(res_obj))); break; #endif case cv::GRunArg::index_of() : outputs.emplace_back(&(cv::util::get(res_obj))); break; case cv::GRunArg::index_of() : outputs.emplace_back(&(cv::util::get(res_obj))); break; case T::index_of() : outputs.emplace_back(cv::util::get(res_obj)); break; case T::index_of() : outputs.emplace_back(cv::util::get(res_obj)); break; case cv::GRunArg::index_of() : outputs.emplace_back(&(cv::util::get(res_obj))); break; case cv::GRunArg::index_of() : outputs.emplace_back(&(cv::util::get(res_obj))); break; default: GAPI_Error("This value type is not supported!"); // ...maybe because of STANDALONE mode. break; } } return outputs; } // FIXME: move it out of s11n to api/ // FIXME: don't we have such function already? cv::GRunArg cv::gapi::bind(cv::GRunArgP &out) { using T = cv::GRunArgP; switch (out.index()) { #if !defined(GAPI_STANDALONE) case T::index_of() : GAPI_Error("Please implement this!"); break; #endif case T::index_of() : return cv::GRunArg(cv::util::get(out)); case T::index_of() : return cv::GRunArg(cv::util::get(out)); case T::index_of() : return cv::GRunArg(*cv::util::get(out)); case T::index_of() : return cv::GRunArg(*cv::util::get(out)); case T::index_of() : return cv::GRunArg(*cv::util::get(out)); case T::index_of() : return cv::GRunArg(*cv::util::get(out)); default: // ...maybe our types were extended GAPI_Error("This value type is UNKNOWN!"); break; } return cv::GRunArg(); }