Fixed standalone build, added cv::gapi::proto::ptr test

pull/17000/head
Ruslan Garnov 5 years ago
parent b1f42a6506
commit ce772b346c
  1. 5
      modules/gapi/include/opencv2/gapi/garray.hpp
  2. 5
      modules/gapi/include/opencv2/gapi/gopaque.hpp
  3. 1
      modules/gapi/src/api/gproto.cpp
  4. 3
      modules/gapi/src/api/gproto_priv.hpp
  5. 4
      modules/gapi/src/compiler/gislandmodel.cpp
  6. 5
      modules/gapi/src/executor/gstreamingexecutor.cpp
  7. 34
      modules/gapi/test/internal/gapi_int_proto_tests.cpp

@ -115,6 +115,7 @@ namespace detail
virtual ~BasicVectorRef() {}
virtual void mov(BasicVectorRef &ref) = 0;
virtual const void* ptr() const = 0;
};
template<typename T> 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<const void*>(m_ref.get()); }
const void *ptr() const { return m_ref->ptr(); }
};
// Helper (FIXME: work-around?)

@ -106,6 +106,7 @@ namespace detail
virtual ~BasicOpaqueRef() {}
virtual void mov(BasicOpaqueRef &ref) = 0;
virtual const void* ptr() const = 0;
};
template<typename T> 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<const void*>(m_ref.get()); }
const void *ptr() const { return m_ref->ptr(); }
};
} // namespace detail

@ -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())

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

@ -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<cv::Mat>():
@ -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)))

@ -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{});

@ -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<typename T>
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>
, 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
Loading…
Cancel
Save