OpenCV  4.10.0-dev
Open Source Computer Vision
Loading...
Searching...
No Matches
Namespaces | Classes | Functions
G-API Serialization functionality

G-API functions and classes for serialization and deserialization. More...

Detailed Description

G-API functions and classes for serialization and deserialization.

Namespaces

namespace  cv::gapi
 
namespace  cv::gapi::s11n
 This namespace contains G-API serialization and deserialization functions and data structures.
 

Classes

struct  cv::gapi::s11n::detail::NotImplemented
 
struct  cv::gapi::s11n::detail::S11N< T >
 This structure allows to implement serialization routines for custom types. More...
 

Functions

cv::GRunArg cv::gapi::bind (cv::GRunArgP &out)
 Wraps output GRunArgsP available during graph execution to GRunArgs which can be serialized.
 
cv::GRunArgsP cv::gapi::bind (cv::GRunArgs &out_args)
 Wraps deserialized output GRunArgs to GRunArgsP which can be used by GCompiled.
 
template<>
cv::GComputation cv::gapi::deserialize (const std::vector< char > &bytes)
 Deserialize GComputation from a byte array.
 
template<typename T , typename... Types>
std::enable_if< std::is_same< T, GCompileArgs >::value, GCompileArgs >::type cv::gapi::deserialize (const std::vector< char > &bytes)
 Deserialize GCompileArgs which types were specified in the template from a byte array.
 
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)
 Deserialize GRunArgs including RMat and MediaFrame objects if any from a byte array.
 
std::vector< char > cv::gapi::serialize (const cv::GCompileArgs &ca)
 
std::vector< char > cv::gapi::serialize (const cv::GComputation &c)
 Serialize a graph represented by GComputation into an array of bytes.
 
std::vector< char > cv::gapi::serialize (const cv::GMetaArgs &ma)
 
std::vector< char > cv::gapi::serialize (const cv::GRunArgs &ra)
 
std::vector< char > cv::gapi::serialize (const std::vector< std::string > &vs)
 

Function Documentation

◆ bind() [1/2]

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);
cv::GRunArgsP bind(cv::GRunArgs &out_args)
Wraps deserialized output GRunArgs to GRunArgsP which can be used by GCompiled.
std::vector< char > serialize(const cv::GComputation &c)
Serialize a graph represented by GComputation into an array of bytes.
std::vector< GRunArg > GRunArgs
Definition garg.hpp:165
Parameters
outoutput GRunArgsP available during graph execution.
Returns
the same GRunArgsP wrapped in serializable GRunArgs.
See also
serialize

◆ bind() [2/2]

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:

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));
Represents a compiled computation (graph). Can only be used with image / data formats & resolutions i...
Definition gcompiled.hpp:67
GCompileArgs compile_args(Ts &&... args)
Wraps a list of arguments (a parameter pack) into a vector of compilation arguments (cv::GCompileArg)...
Definition gcommon.hpp:214
Parameters
out_argsdeserialized GRunArgs.
Returns
the same GRunArgs wrapped in GRunArgsP.
See also
deserialize

◆ deserialize() [1/3]

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

#include <opencv2/gapi/s11n.hpp>

Deserialize GComputation from a byte array.

Check different overloads for more examples.

Parameters
bytesserialized vector of bytes.
Returns
deserialized GComputation object.

◆ deserialize() [2/3]

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

#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
bytesvector of bytes to deserialize GCompileArgs object from.
Returns
GCompileArgs object.
See also
GCompileArgs cv::gapi::s11n::detail::S11N

◆ deserialize() [3/3]

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)
inline

#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.
Parameters
bytesvector of bytes to deserialize GRunArgs object from.
Returns
GRunArgs including RMat and MediaFrame objects if any.
See also
RMat MediaFrame

◆ serialize() [1/5]

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
caGCompileArgs to serialize.

◆ serialize() [2/5]

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
cGComputation to serialize.
Returns
serialized vector of bytes.

◆ serialize() [3/5]

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
maGMetaArgs to serialize.

◆ serialize() [4/5]

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
raGRunArgs to serialize.

◆ serialize() [5/5]

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
vsstd::vector<std::string> to serialize.