From 18ca998f67bbf9e950a847a621928012f8b0ca1e Mon Sep 17 00:00:00 2001 From: Trutnev Aleksei Date: Thu, 11 Nov 2021 14:52:38 +0300 Subject: [PATCH] Merge pull request #21040 from alexgiving:atrutnev/rename_RMatAdapter GAPI: Rename MatAdapter to RMatOnMat --- modules/gapi/src/backends/common/gbackend.hpp | 4 ++-- modules/gapi/src/backends/python/gpythonbackend.cpp | 2 +- .../gapi/src/backends/streaming/gstreamingbackend.cpp | 6 +++--- modules/gapi/src/executor/gexecutor.cpp | 11 +++++------ modules/gapi/src/executor/gstreamingexecutor.cpp | 4 ++-- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/modules/gapi/src/backends/common/gbackend.hpp b/modules/gapi/src/backends/common/gbackend.hpp index f005135d87..7532486dbd 100644 --- a/modules/gapi/src/backends/common/gbackend.hpp +++ b/modules/gapi/src/backends/common/gbackend.hpp @@ -45,11 +45,11 @@ namespace gimpl { #endif } - class RMatAdapter : public RMat::IAdapter { + class RMatOnMat : public RMat::IAdapter { cv::Mat m_mat; public: const void* data() const { return m_mat.data; } - RMatAdapter(cv::Mat m) : m_mat(m) {} + RMatOnMat(cv::Mat m) : m_mat(m) {} virtual RMat::View access(RMat::Access) override { return asView(m_mat); } virtual cv::GMatDesc desc() const override { return cv::descr_of(m_mat); } }; diff --git a/modules/gapi/src/backends/python/gpythonbackend.cpp b/modules/gapi/src/backends/python/gpythonbackend.cpp index 7f4a867f89..4361bab75d 100644 --- a/modules/gapi/src/backends/python/gpythonbackend.cpp +++ b/modules/gapi/src/backends/python/gpythonbackend.cpp @@ -128,7 +128,7 @@ static void writeBack(cv::GRunArg& arg, cv::GRunArgP& out) case cv::GRunArg::index_of(): { auto& rmat = *cv::util::get(out); - rmat = cv::make_rmat(cv::util::get(arg)); + rmat = cv::make_rmat(cv::util::get(arg)); break; } case cv::GRunArg::index_of(): diff --git a/modules/gapi/src/backends/streaming/gstreamingbackend.cpp b/modules/gapi/src/backends/streaming/gstreamingbackend.cpp index 09abd32c05..8dc3dfe73f 100644 --- a/modules/gapi/src/backends/streaming/gstreamingbackend.cpp +++ b/modules/gapi/src/backends/streaming/gstreamingbackend.cpp @@ -279,7 +279,7 @@ void GOCVBGR::Actor::extractRMat(const cv::MediaFrame& frame, cv::RMat& rmat) cv::Mat y_plane (desc.size, CV_8UC1, view.ptr[0], view.stride[0]); cv::Mat uv_plane(desc.size / 2, CV_8UC2, view.ptr[1], view.stride[1]); cv::cvtColorTwoPlane(y_plane, uv_plane, bgr, cv::COLOR_YUV2BGR_NV12); - rmat = cv::make_rmat(bgr); + rmat = cv::make_rmat(bgr); break; } default: @@ -327,7 +327,7 @@ void GOCVY::Actor::extractRMat(const cv::MediaFrame& frame, cv::RMat& rmat) cv::Mat tmp_bgr(desc.size, CV_8UC3, view.ptr[0], view.stride[0]); cv::Mat yuv; cvtColor(tmp_bgr, yuv, cv::COLOR_BGR2YUV_I420); - rmat = cv::make_rmat(yuv.rowRange(0, desc.size.height)); + rmat = cv::make_rmat(yuv.rowRange(0, desc.size.height)); break; } case cv::MediaFormat::NV12: @@ -396,7 +396,7 @@ void GOCVUV::Actor::extractRMat(const cv::MediaFrame& frame, cv::RMat& rmat) yuv.rowRange(start + range_h, start + range_h * 2).reshape(0, dims) }; cv::merge(uv_planes, uv); - rmat = cv::make_rmat(uv); + rmat = cv::make_rmat(uv); break; } case cv::MediaFormat::NV12: diff --git a/modules/gapi/src/executor/gexecutor.cpp b/modules/gapi/src/executor/gexecutor.cpp index ad9d380b4e..6c15d1dfc9 100644 --- a/modules/gapi/src/executor/gexecutor.cpp +++ b/modules/gapi/src/executor/gexecutor.cpp @@ -100,7 +100,7 @@ void bindInArgExec(Mag& mag, const RcDesc &rc, const GRunArg &arg) switch (arg.index()) { case GRunArg::index_of() : - mag_rmat = make_rmat(util::get(arg)); break; + mag_rmat = make_rmat(util::get(arg)); break; case GRunArg::index_of() : mag_rmat = util::get(arg); break; default: util::throw_error(std::logic_error("content type of the runtime argument does not match to resource description ?")); @@ -121,7 +121,7 @@ void bindOutArgExec(Mag& mag, const RcDesc &rc, const GRunArgP &arg) switch (arg.index()) { case GRunArgP::index_of() : - mag_rmat = make_rmat(*util::get(arg)); break; + mag_rmat = make_rmat(*util::get(arg)); break; case GRunArgP::index_of() : mag_rmat = *util::get(arg); break; default: util::throw_error(std::logic_error("content type of the runtime argument does not match to resource description ?")); @@ -155,12 +155,11 @@ void writeBackExec(const Mag& mag, const RcDesc &rc, GRunArgP &g_arg) // FIXME: // Rework, find a better way to check if there should be // a real copy (add a pass to StreamingBackend?) - // NB: In case RMat adapter not equal to "RMatAdapter" need to + // NB: In case RMat adapter not equal to "RMatOnMat" need to // copy data back to the host as well. - // FIXME: Rename "RMatAdapter" to "OpenCVAdapter". auto& out_mat = *util::get(g_arg); const auto& rmat = mag.template slot().at(rc.id); - auto* adapter = rmat.get(); + auto* adapter = rmat.get(); if ((adapter != nullptr && out_mat.data != adapter->data()) || (adapter == nullptr)) { auto view = rmat.access(RMat::Access::R); @@ -221,7 +220,7 @@ void cv::gimpl::GExecutor::initResource(const ade::NodeHandle & nh, const ade::N } else { Mat mat; createMat(desc, mat); - rmat = make_rmat(mat); + rmat = make_rmat(mat); } } break; diff --git a/modules/gapi/src/executor/gstreamingexecutor.cpp b/modules/gapi/src/executor/gstreamingexecutor.cpp index bc43db8a37..ef93833143 100644 --- a/modules/gapi/src/executor/gstreamingexecutor.cpp +++ b/modules/gapi/src/executor/gstreamingexecutor.cpp @@ -662,7 +662,7 @@ class StreamingInput final: public cv::gimpl::GIslandExecutable::IInput // Wrap all input cv::Mats with RMats for (auto& arg : isl_input_args) { if (arg.index() == cv::GRunArg::index_of()) { - arg = cv::GRunArg{ cv::make_rmat(cv::util::get(arg)) + arg = cv::GRunArg{ cv::make_rmat(cv::util::get(arg)) , arg.meta }; } @@ -745,7 +745,7 @@ class StreamingOutput final: public cv::gimpl::GIslandExecutable::IOutput { MatType newMat; cv::gimpl::createMat(desc, newMat); - auto rmat = cv::make_rmat(newMat); + auto rmat = cv::make_rmat(newMat); out_arg = cv::GRunArg(std::move(rmat)); } ret_val = cv::GRunArgP(&cv::util::get(out_arg));