OpenCV 4.12.0
开源计算机视觉
加载中...
搜索中...
无匹配项
G-API 序列化功能

G-API 函数和类,用于序列化和反序列化。 更多...

详细描述

G-API 函数和类,用于序列化和反序列化。

命名空间

命名空间  cv::gapi
 
命名空间  cv::gapi::s11n
 此命名空间包含 G-API 序列化和反序列化函数及数据结构。
 

结构体  cv::gapi::s11n::detail::NotImplemented
 
结构体  cv::gapi::s11n::detail::S11N< T >
 此结构允许为自定义类型实现序列化例程。 更多...
 

函数

cv::GRunArg cv::gapi::bind (cv::GRunArgP &out)
 将图执行期间可用的输出 GRunArgsP 包装为可以序列化的 GRunArgs。
 
cv::GRunArgsP cv::gapi::bind (cv::GRunArgs &out_args)
 将反序列化的输出 GRunArgs 包装为 GCompiled 可以使用的 GRunArgsP。
 
template<>
cv::GComputation cv::gapi::deserialize (const std::vector< char > &bytes)
 从字节数组反序列化 GComputation
 
template<typename T , typename... Types>
std::enable_if< std::is_same< T, GCompileArgs >::value, GCompileArgs >::type cv::gapi::deserialize (const std::vector< char > &bytes)
 从字节数组反序列化模板中指定类型的 GCompileArgs。
 
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)
 反序列化 GRunArgs,包括 RMatMediaFrame 对象(如果有)从字节数组。
 
std::vector< char > cv::gapi::serialize (const cv::GCompileArgs &ca)
 
std::vector< char > cv::gapi::serialize (const cv::GComputation &c)
 GComputation 表示的图序列化为字节数组。
 
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)
 

函数文档

◆ bind() [1/2]

cv::GRunArg cv::gapi::bind ( cv::GRunArgP & 输出3D仿射变换矩阵,尺寸为\(3 \times 4\),形式如下)

#include <opencv2/gapi/garg.hpp>

将图执行期间可用的输出 GRunArgsP 包装为可以序列化的 GRunArgs。

GRunArgsP 是指向值的指针,因此要序列化它们,需要绑定到此函数执行的实际值。

使用示例

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);
参数
输出3D仿射变换矩阵,尺寸为\(3 \times 4\),形式如下图执行期间可用的输出 GRunArgsP。
返回
包装在可序列化 GRunArgs 中的相同 GRunArgsP。
另请参见
序列化

◆ bind() [2/2]

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

#include <opencv2/gapi/garg.hpp>

将反序列化的输出 GRunArgs 包装为 GCompiled 可以使用的 GRunArgsP。

由于无法从反序列化中获取可修改的输出参数,因此需要由此函数包装。

使用示例

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));
参数
out_args反序列化的 GRunArgs。
返回
包装在 GRunArgsP 中的相同 GRunArgs。
另请参见
反序列化

◆ deserialize() [1/3]

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

#include <opencv2/gapi/s11n.hpp>

从字节数组反序列化 GComputation

检查不同的重载以获取更多示例。

参数
bytes序列化的字节向量。
返回
反序列化的 GComputation 对象。

◆ 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>

从字节数组反序列化模板中指定类型的 GCompileArgs。

注意
必须提供 cv::gapi::s11n::detail::S11N 模板特化,以使 GCompileArgs 中的自定义类型可反序列化。
参数
bytes用于从中反序列化 GCompileArgs 对象的字节向量。
返回
GCompileArgs 对象。
另请参见
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>

反序列化 GRunArgs,包括 RMatMediaFrame 对象(如果有)从字节数组。

适配器类型在模板中指定。

注意
要正确使用,指定的适配器类型必须重载其 deserialize() 方法。
参数
bytes用于从中反序列化 GRunArgs 对象的字节向量。
返回
GRunArgs,包括 RMatMediaFrame 对象(如果有)。
另请参见
RMat MediaFrame

◆ serialize() [1/5]

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

#include <opencv2/gapi/s11n.hpp>

这是一个重载的成员函数,为方便起见而提供。它与上述函数的不同之处仅在于它接受的参数。

参数
ca要序列化的 GCompileArgs。

◆ serialize() [2/5]

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

#include <opencv2/gapi/s11n.hpp>

GComputation 表示的图序列化为字节数组。

检查不同的重载以获取更多示例。

参数
c要序列化的 GComputation
返回
序列化的字节向量。

◆ serialize() [3/5]

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

#include <opencv2/gapi/s11n.hpp>

这是一个重载的成员函数,为方便起见而提供。它与上述函数的不同之处仅在于它接受的参数。

参数
ma要序列化的 GMetaArgs。

◆ serialize() [4/5]

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

#include <opencv2/gapi/s11n.hpp>

这是一个重载的成员函数,为方便起见而提供。它与上述函数的不同之处仅在于它接受的参数。

参数
ra要序列化的 GRunArgs。

◆ serialize() [5/5]

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

#include <opencv2/gapi/s11n.hpp>

这是一个重载的成员函数,为方便起见而提供。它与上述函数的不同之处仅在于它接受的参数。

参数
vs要序列化的 std::vector<std::string>。