diff --git a/modules/gapi/include/opencv2/gapi/garray.hpp b/modules/gapi/include/opencv2/gapi/garray.hpp index 0b89249ce4..35b1f00996 100644 --- a/modules/gapi/include/opencv2/gapi/garray.hpp +++ b/modules/gapi/include/opencv2/gapi/garray.hpp @@ -115,6 +115,7 @@ namespace detail virtual ~BasicVectorRef() {} virtual void mov(BasicVectorRef &ref) = 0; + virtual const void* ptr() const = 0; }; template class VectorRefT final: public BasicVectorRef @@ -207,6 +208,8 @@ namespace detail GAPI_Assert(tv != nullptr); wref() = std::move(tv->wref()); } + + virtual const void* ptr() const override { return &rref(); } }; // This class strips type information from VectorRefT<> and makes it usable @@ -263,7 +266,7 @@ namespace detail } // May be used to uniquely identify this object internally - const void *ptr() const { return static_cast(m_ref.get()); } + const void *ptr() const { return m_ref->ptr(); } }; // Helper (FIXME: work-around?) diff --git a/modules/gapi/include/opencv2/gapi/gopaque.hpp b/modules/gapi/include/opencv2/gapi/gopaque.hpp index 999e567de7..f5d06bbed7 100644 --- a/modules/gapi/include/opencv2/gapi/gopaque.hpp +++ b/modules/gapi/include/opencv2/gapi/gopaque.hpp @@ -106,6 +106,7 @@ namespace detail virtual ~BasicOpaqueRef() {} virtual void mov(BasicOpaqueRef &ref) = 0; + virtual const void* ptr() const = 0; }; template class OpaqueRefT final: public BasicOpaqueRef @@ -197,6 +198,8 @@ namespace detail GAPI_Assert(tv != nullptr); wref() = std::move(tv->wref()); } + + virtual const void* ptr() const override { return &rref(); } }; // This class strips type information from OpaqueRefT<> and makes it usable @@ -251,7 +254,7 @@ namespace detail } // May be used to uniquely identify this object internally - const void *ptr() const { return static_cast(m_ref.get()); } + const void *ptr() const { return m_ref->ptr(); } }; } // namespace detail diff --git a/modules/gapi/src/api/gproto.cpp b/modules/gapi/src/api/gproto.cpp index 79a357ecfb..83df8371c7 100644 --- a/modules/gapi/src/api/gproto.cpp +++ b/modules/gapi/src/api/gproto.cpp @@ -266,7 +266,6 @@ std::ostream& operator<<(std::ostream& os, const cv::GMetaArg &arg) } } // namespace cv -// TODO: This function requires thorough testing const void* cv::gimpl::proto::ptr(const GRunArgP &arg) { switch (arg.index()) diff --git a/modules/gapi/src/api/gproto_priv.hpp b/modules/gapi/src/api/gproto_priv.hpp index f6f49e1de2..b1d71df881 100644 --- a/modules/gapi/src/api/gproto_priv.hpp +++ b/modules/gapi/src/api/gproto_priv.hpp @@ -28,7 +28,8 @@ GAPI_EXPORTS const GOrigin& origin_of (const GArg &arg); bool is_dynamic(const GArg &arg); GProtoArg rewrap (const GArg &arg); -const void* ptr (const GRunArgP &arg); +// FIXME:: GAPI_EXPORTS because of tests only!! +GAPI_EXPORTS const void* ptr (const GRunArgP &arg); } // proto } // gimpl diff --git a/modules/gapi/src/compiler/gislandmodel.cpp b/modules/gapi/src/compiler/gislandmodel.cpp index 46b58caf19..7406ea04a6 100644 --- a/modules/gapi/src/compiler/gislandmodel.cpp +++ b/modules/gapi/src/compiler/gislandmodel.cpp @@ -344,6 +344,7 @@ void GIslandExecutable::run(GIslandExecutable::IInput &in, GIslandExecutable::IO // This kludge should go as a result of de-ownification const cv::GRunArg& in_data_orig = std::get<1>(it); cv::GRunArg in_data; +#if !defined(GAPI_STANDALONE) switch (in_data_orig.index()) { case cv::GRunArg::index_of(): @@ -356,6 +357,9 @@ void GIslandExecutable::run(GIslandExecutable::IInput &in, GIslandExecutable::IO in_data = in_data_orig; break; } +#else + in_data = in_data_orig; +#endif // GAPI_STANDALONE in_objs.emplace_back(std::get<0>(it), std::move(in_data)); } for (auto &&it: ade::util::indexed(ade::util::toRange(out_desc))) diff --git a/modules/gapi/src/executor/gstreamingexecutor.cpp b/modules/gapi/src/executor/gstreamingexecutor.cpp index 04e8258c52..52433b5d61 100644 --- a/modules/gapi/src/executor/gstreamingexecutor.cpp +++ b/modules/gapi/src/executor/gstreamingexecutor.cpp @@ -420,8 +420,13 @@ class StreamingOutput final: public cv::gimpl::GIslandExecutable::IOutput // Prepare this object for posting virtual cv::GRunArgP get(int idx) override { +#if !defined(GAPI_STANDALONE) using MatType = cv::Mat; using SclType = cv::Scalar; +#else + using MatType = cv::gapi::own::Mat; + using SclType = cv::gapi::own::Scalar; +#endif // GAPI_STANDALONE // Allocate a new posting first, then bind this GRunArgP to this item auto iter = m_postings[idx].insert(m_postings[idx].end(), Posting{}); diff --git a/modules/gapi/test/internal/gapi_int_proto_tests.cpp b/modules/gapi/test/internal/gapi_int_proto_tests.cpp new file mode 100644 index 0000000000..1fe9fbb44a --- /dev/null +++ b/modules/gapi/test/internal/gapi_int_proto_tests.cpp @@ -0,0 +1,34 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + + +#include "../test_precomp.hpp" +#include "../src/api/gproto_priv.hpp" + +namespace opencv_test { + +template +struct ProtoPtrTest : public ::testing::Test { using Type = T; }; + +using ProtoPtrTestTypes = ::testing::Types< cv::Mat + , cv::UMat + , cv::gapi::own::Mat + , cv::Scalar + , std::vector + , int + >; + +TYPED_TEST_CASE(ProtoPtrTest, ProtoPtrTestTypes); + +TYPED_TEST(ProtoPtrTest, NonZero) +{ + typename TestFixture::Type value; + const auto arg = cv::gout(value).front(); + const auto ptr = cv::gimpl::proto::ptr(arg); + EXPECT_EQ(ptr, &value); +} + +} // namespace opencv_test