Next step would be figuring out, how to serialize the whole graph and deploy it somewhere, with no prior knowledge of the details. With a simple graph, it would be the following.
// Make simple graph
cv::GMat in;
cv:GMat out = cv::gapi::resize(in, cv::Size(), 0.01, 0.01);
auto p = cv::gapi::serialize(cv::GComputation(in, out));
std::ofstream fout(“gcomp.bin”, std::ios::out | std::ios::binary);
fout.write((const char*)&p[0], p.size()); fout.close();
// Load graph
cv::Mat imgIn = cv::Mat::ones(8000, 4000, CV_8U);
cv::Mat imgOut;
std::ifstream file(“gcomp.bin”, std::ios::binary);
file.unsetf(std::ios::skipws);
std::streampos fileSize;
file.seekg(0, std::ios::end);
fileSize = file.tellg();
file.seekg(0, std::ios::beg);
std::vector<char> vec;
vec.reserve(fileSize);
vec.insert(vec.begin(), std::istream_iterator<char>(file), std::istream_iterator<char>());
auto c = cv::gapi::deserialize<cv::GComputation>(vec);
c.apply(imgIn, imgOut);
Now this cannot be applied to the upper example, as the kernels are not known by the consumer. Maybe someone is also interested in this approach. I’ll post a solution if I find one. Trying ot contact contributors and authors on this issue (G-API : how is serialize/deserialize supposed to be used properly ? · Issue #17965 · opencv/opencv · GitHub).