From be1615b1c386cf3770dda8890c6675d3502321ba Mon Sep 17 00:00:00 2001 From: Ruslan Garnov Date: Mon, 6 Apr 2020 18:53:54 +0300 Subject: [PATCH] Merge pull request #16964 from rgarnov:rg/opaque_for_streaming_exec * Added GOpaque support to GStreamingExecutor * Added inter-island GOpaque support to GExecutor --- modules/gapi/src/executor/gexecutor.cpp | 1 + .../gapi/src/executor/gstreamingexecutor.cpp | 13 ++++++++++++ modules/gapi/test/gapi_opaque_tests.cpp | 20 +++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/modules/gapi/src/executor/gexecutor.cpp b/modules/gapi/src/executor/gexecutor.cpp index 74d107d908..36b9b44594 100644 --- a/modules/gapi/src/executor/gexecutor.cpp +++ b/modules/gapi/src/executor/gexecutor.cpp @@ -114,6 +114,7 @@ void cv::gimpl::GExecutor::initResource(const ade::NodeHandle &orig_nh) break; case GShape::GARRAY: + case GShape::GOPAQUE: // Constructed on Reset, do nothing here break; diff --git a/modules/gapi/src/executor/gstreamingexecutor.cpp b/modules/gapi/src/executor/gstreamingexecutor.cpp index 70be78f3d7..e5e497ce0b 100644 --- a/modules/gapi/src/executor/gstreamingexecutor.cpp +++ b/modules/gapi/src/executor/gstreamingexecutor.cpp @@ -122,6 +122,9 @@ void sync_data(cv::GRunArgs &results, cv::GRunArgsP &outputs) case T::index_of(): cv::util::get(out_obj).mov(cv::util::get(res_obj)); break; + case T::index_of(): + cv::util::get(out_obj).mov(cv::util::get(res_obj)); + break; default: GAPI_Assert(false && "This value type is not supported!"); // ...maybe because of STANDALONE mode. break; @@ -475,6 +478,16 @@ void islandActorThread(std::vector in_rcs, // isl_outputs[id] = { r, cv::GRunArgP(rr) }; } break; + case cv::GShape::GOPAQUE: + { + cv::detail::OpaqueRef newOpaque; + cv::util::get(r.ctor)(newOpaque); + out_data[id] = cv::GRunArg(std::move(newOpaque)); + // OpaqueRef is implicitly shared so no pointer is taken here + const auto &rr = cv::util::get(out_data[id]); // FIXME: that variant MOVE problem again + isl_outputs[id] = { r, cv::GRunArgP(rr) }; + } + break; default: cv::util::throw_error(std::logic_error("Unsupported GShape")); break; diff --git a/modules/gapi/test/gapi_opaque_tests.cpp b/modules/gapi/test/gapi_opaque_tests.cpp index 07e483fd0f..0623d2efdd 100644 --- a/modules/gapi/test/gapi_opaque_tests.cpp +++ b/modules/gapi/test/gapi_opaque_tests.cpp @@ -146,6 +146,26 @@ TEST(GOpaque, TestOpaqueBetween) EXPECT_EQ(painted, 77); } +TEST(GOpaque, TestOpaqueBetweenIslands) +{ + cv::Size sz = {50, 50}; + int depth = CV_8U; + int chan = 1; + cv::Mat mat_in = cv::Mat::zeros(sz, CV_MAKETYPE(depth, chan)); + cv::Mat mat_out = cv::Mat::zeros(sz, CV_MAKETYPE(depth, chan)); + + cv::GMat in, out; + auto betw = ThisTest::GeneratePoint::on(in); + out = ThisTest::PaintPoint::on(betw, depth, chan, sz); + + cv::gapi::island("test", cv::GIn(in), cv::GOut(betw)); + cv::GComputation c(cv::GIn(in), cv::GOut(out)); + c.apply(cv::gin(mat_in), cv::gout(mat_out), cv::compile_args(cv::gapi::kernels())); + + int painted = mat_out.at(42, 42); + EXPECT_EQ(painted, 77); +} + TEST(GOpaque, TestOpaqueCustomOut2) { cv::Mat input1 = cv::Mat(52, 52, CV_8U);