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