G-API Serialization functionality#

G-API functions and classes for serialization and deserialization.

Detailed Description#

Namespaces#

Classes#

Name

Description

struct cv::gapi::s11n::detail::NotImplemented

View details

struct cv::gapi::s11n::detail::S11N

This structure allows to implement serialization routines for custom types. View details

Function Documentation#

bind()#

cv::GRunArg cv::gapi::bind(cv::GRunArgP & out)

#include <opencv2/gapi/garg.hpp>

Wraps output GRunArgsP available during graph execution to GRunArgs which can be serialized.

GRunArgsP is pointer-to-value, so to be serialized they need to be binded to real values which this function does.

Example of usage:

    std::vector<cv::GRunArgP> graph_outs;
    cv::GRunArgs out_args;

    for (auto &&out : graph_outs) {
        out_args.emplace_back(cv::gapi::bind(out));
    }
    const auto sargsout = cv::gapi::serialize(out_args);

See also

serialize

Parameters

  • out — output GRunArgsP available during graph execution.

Returns

the same GRunArgsP wrapped in serializable GRunArgs.

bind()#

cv::GRunArgsP cv::gapi::bind(cv::GRunArgs & out_args)

#include <opencv2/gapi/garg.hpp>

Wraps deserialized output GRunArgs to GRunArgsP which can be used by GCompiled.

Since it’s impossible to get modifiable output arguments from deserialization it needs to be wrapped by this function.

Example of usage:

    cv::GCompiled compd;
    std::vector<char> bytes;
    auto graph = cv::gapi::deserialize<cv::GComputation>(bytes);
    auto meta = cv::gapi::deserialize<cv::GMetaArgs>(bytes);

    compd = graph.compile(std::move(meta), cv::compile_args());
    auto in_args  = cv::gapi::deserialize<cv::GRunArgs>(bytes);
    auto out_args = cv::gapi::deserialize<cv::GRunArgs>(bytes);
    compd(std::move(in_args), cv::gapi::bind(out_args));

See also

deserialize

Parameters

  • out_args — deserialized GRunArgs.

Returns

the same GRunArgs wrapped in GRunArgsP.

deserialize()#

template<typename T>
static T cv::gapi::deserialize(const std::vector< char > & bytes)

#include <opencv2/gapi/s11n.hpp>

deserialize()#

cv::GComputation cv::gapi::deserialize(const std::vector< char > & bytes)

#include <opencv2/gapi/s11n.hpp>

Deserialize GComputation from a byte array.

Check different overloads for more examples.

Parameters

  • bytes — serialized vector of bytes.

Returns

deserialized GComputation object.

deserialize()#

template<typename T, typename… Types>
std::enable_if< std::is_same< T, GCompileArgs >::value, GCompileArgs >::type cv::gapi::deserialize(const std::vector< char > & bytes)

#include <opencv2/gapi/s11n.hpp>

Deserialize GCompileArgs which types were specified in the template from a byte array.

Note

cv::gapi::s11n::detail::S11N template specialization must be provided to make a custom type in GCompileArgs deserializable.

Parameters

  • bytes — vector of bytes to deserialize GCompileArgs object from.

Returns

GCompileArgs object.

deserialize()#

template<typename T, typename AtLeastOneAdapterT, typename... AdapterTypes>
std::enable_if< std::is_same< T, GRunArgs >::value, GRunArgs >::type cv::gapi::deserialize(const std::vector< char > & bytes)

#include <opencv2/gapi/s11n.hpp>

Deserialize GRunArgs including RMat and MediaFrame objects if any from a byte array.

Adapter types are specified in the template.

Note

To be used properly specified adapter types must overload their deserialize() method.

See also

RMat MediaFrame

Parameters

  • bytes — vector of bytes to deserialize GRunArgs object from.

Returns

GRunArgs including RMat and MediaFrame objects if any.

serialize()#

std::vector< char > cv::gapi::serialize(const cv::GCompileArgs & ca)

#include <opencv2/gapi/s11n.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters

  • ca — GCompileArgs to serialize.

serialize()#

std::vector< char > cv::gapi::serialize(const cv::GComputation & c)

#include <opencv2/gapi/s11n.hpp>

Serialize a graph represented by GComputation into an array of bytes.

Check different overloads for more examples.

Parameters

Returns

serialized vector of bytes.

serialize()#

std::vector< char > cv::gapi::serialize(const cv::GMetaArgs & ma)

#include <opencv2/gapi/s11n.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters

  • ma — GMetaArgs to serialize.

serialize()#

std::vector< char > cv::gapi::serialize(const cv::GRunArgs & ra)

#include <opencv2/gapi/s11n.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters

  • ra — GRunArgs to serialize.

serialize()#

std::vector< char > cv::gapi::serialize(const std::vector< std::string > & vs)

#include <opencv2/gapi/s11n.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters