Merge pull request #16995 from mpashchenkov:mp/ocv-gapi-standalone-mat
G-API: Mat's "deownification" * deowned Mat * boner * Removed canDescribe test for own::Mat * Removed STANDALONE flag for apply() and operator() * Removed: desc_tests for own::Mat, descr_of for own::Mat. * Returned: tests, cv::gapi::own::descr_of; fixed alignment; Removed own::Mat's headers * Removed unused header own/mat.hpp from gbackend.hpp
This commit is contained in:
committed by
GitHub
parent
f19d0ae41d
commit
94e36d8c8d
@@ -10,7 +10,6 @@
|
||||
#include <functional> // multiplies
|
||||
|
||||
#include <opencv2/gapi/gkernel.hpp>
|
||||
#include <opencv2/gapi/own/convert.hpp>
|
||||
|
||||
#include "api/gbackend_priv.hpp"
|
||||
#include "backends/common/gbackend.hpp"
|
||||
@@ -114,36 +113,22 @@ void bindInArg(Mag& mag, const RcDesc &rc, const GRunArg &arg, bool is_umat)
|
||||
{
|
||||
switch (arg.index())
|
||||
{
|
||||
case GRunArg::index_of<cv::gapi::own::Mat>() :
|
||||
case GRunArg::index_of<cv::Mat>() :
|
||||
if (is_umat)
|
||||
{
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
auto& mag_umat = mag.template slot<cv::UMat>()[rc.id];
|
||||
mag_umat = to_ocv(util::get<cv::gapi::own::Mat>(arg)).getUMat(ACCESS_READ);
|
||||
mag_umat = util::get<cv::Mat>(arg).getUMat(ACCESS_READ);
|
||||
#else
|
||||
util::throw_error(std::logic_error("UMat is not supported in standalone build"));
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
}
|
||||
else
|
||||
{
|
||||
auto& mag_mat = mag.template slot<cv::gapi::own::Mat>()[rc.id];
|
||||
mag_mat = util::get<cv::gapi::own::Mat>(arg);
|
||||
auto& mag_mat = mag.template slot<cv::Mat>()[rc.id];
|
||||
mag_mat = util::get<cv::Mat>(arg);
|
||||
}
|
||||
break;
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArg::index_of<cv::Mat>() :
|
||||
if (is_umat)
|
||||
{
|
||||
auto& mag_umat = mag.template slot<cv::UMat>()[rc.id];
|
||||
mag_umat = util::get<cv::Mat>(arg).getUMat(ACCESS_READ);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto& mag_mat = mag.template slot<cv::gapi::own::Mat>()[rc.id];
|
||||
mag_mat = to_own(util::get<cv::Mat>(arg));
|
||||
}
|
||||
break;
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
default: util::throw_error(std::logic_error("content type of the runtime argument does not match to resource description ?"));
|
||||
}
|
||||
break;
|
||||
@@ -182,36 +167,22 @@ void bindOutArg(Mag& mag, const RcDesc &rc, const GRunArgP &arg, bool is_umat)
|
||||
{
|
||||
switch (arg.index())
|
||||
{
|
||||
case GRunArgP::index_of<cv::gapi::own::Mat*>() :
|
||||
case GRunArgP::index_of<cv::Mat*>() :
|
||||
if (is_umat)
|
||||
{
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
auto& mag_umat = mag.template slot<cv::UMat>()[rc.id];
|
||||
mag_umat = to_ocv(*(util::get<cv::gapi::own::Mat*>(arg))).getUMat(ACCESS_RW);
|
||||
mag_umat = util::get<cv::Mat*>(arg)->getUMat(ACCESS_RW);
|
||||
#else
|
||||
util::throw_error(std::logic_error("UMat is not supported in standalone build"));
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
}
|
||||
else
|
||||
{
|
||||
auto& mag_mat = mag.template slot<cv::gapi::own::Mat>()[rc.id];
|
||||
mag_mat = *util::get<cv::gapi::own::Mat*>(arg);
|
||||
auto& mag_mat = mag.template slot<cv::Mat>()[rc.id];
|
||||
mag_mat = *util::get<cv::Mat*>(arg);
|
||||
}
|
||||
break;
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::Mat*>() :
|
||||
if (is_umat)
|
||||
{
|
||||
auto& mag_umat = mag.template slot<cv::UMat>()[rc.id];
|
||||
mag_umat = util::get<cv::Mat*>(arg)->getUMat(ACCESS_RW);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto& mag_mat = mag.template slot<cv::gapi::own::Mat>()[rc.id];
|
||||
mag_mat = to_own(*util::get<cv::Mat*>(arg));
|
||||
}
|
||||
break;
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
default: util::throw_error(std::logic_error("content type of the runtime argument does not match to resource description ?"));
|
||||
}
|
||||
break;
|
||||
@@ -277,7 +248,7 @@ cv::GRunArg getArg(const Mag& mag, const RcDesc &ref)
|
||||
// Wrap associated CPU object (either host or an internal one)
|
||||
switch (ref.shape)
|
||||
{
|
||||
case GShape::GMAT: return GRunArg(mag.template slot<cv::gapi::own::Mat>().at(ref.id));
|
||||
case GShape::GMAT: return GRunArg(mag.template slot<cv::Mat>().at(ref.id));
|
||||
case GShape::GSCALAR: return GRunArg(mag.template slot<cv::Scalar>().at(ref.id));
|
||||
// Note: .at() is intentional for GArray and GOpaque as objects MUST be already there
|
||||
// (and constructed by either bindIn/Out or resetInternal)
|
||||
@@ -303,7 +274,7 @@ cv::GRunArgP getObjPtr(Mag& mag, const RcDesc &rc, bool is_umat)
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
}
|
||||
else
|
||||
return GRunArgP(&mag.template slot<cv::gapi::own::Mat>()[rc.id]);
|
||||
return GRunArgP(&mag.template slot<cv::Mat>()[rc.id]);
|
||||
case GShape::GSCALAR: return GRunArgP(&mag.template slot<cv::Scalar>()[rc.id]);
|
||||
// Note: .at() is intentional for GArray and GOpaque as objects MUST be already there
|
||||
// (and constructor by either bindIn/Out or resetInternal)
|
||||
@@ -347,10 +318,9 @@ void writeBack(const Mag& mag, const RcDesc &rc, GRunArgP &g_arg, bool is_umat)
|
||||
uchar* out_arg_data = nullptr;
|
||||
switch (g_arg.index())
|
||||
{
|
||||
case GRunArgP::index_of<cv::gapi::own::Mat*>() : out_arg_data = util::get<cv::gapi::own::Mat*>(g_arg)->data; break;
|
||||
case GRunArgP::index_of<cv::Mat*>() : out_arg_data = util::get<cv::Mat*>(g_arg)->data; break;
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::Mat*>() : out_arg_data = util::get<cv::Mat*>(g_arg)->data; break;
|
||||
case GRunArgP::index_of<cv::UMat*>() : out_arg_data = (util::get<cv::UMat*>(g_arg))->getMat(ACCESS_RW).data; break;
|
||||
case GRunArgP::index_of<cv::UMat*>() : out_arg_data = (util::get<cv::UMat*>(g_arg))->getMat(ACCESS_RW).data; break;
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
default: util::throw_error(std::logic_error("content type of the runtime argument does not match to resource description ?"));
|
||||
}
|
||||
@@ -365,7 +335,7 @@ void writeBack(const Mag& mag, const RcDesc &rc, GRunArgP &g_arg, bool is_umat)
|
||||
}
|
||||
else
|
||||
{
|
||||
auto& in_mag = mag.template slot<cv::gapi::own::Mat>().at(rc.id);
|
||||
auto& in_mag = mag.template slot<cv::Mat>().at(rc.id);
|
||||
GAPI_Assert((out_arg_data == in_mag.data) && " data for output parameters was reallocated ?");
|
||||
}
|
||||
break;
|
||||
@@ -389,24 +359,6 @@ void writeBack(const Mag& mag, const RcDesc &rc, GRunArgP &g_arg, bool is_umat)
|
||||
|
||||
} // namespace magazine
|
||||
|
||||
void createMat(const cv::GMatDesc &desc, cv::gapi::own::Mat& mat)
|
||||
{
|
||||
// FIXME: Refactor (probably start supporting N-Dimensional blobs natively
|
||||
if (desc.dims.empty())
|
||||
{
|
||||
const auto type = desc.planar ? desc.depth : CV_MAKETYPE(desc.depth, desc.chan);
|
||||
const auto size = desc.planar ? cv::Size{desc.size.width, desc.size.height*desc.chan}
|
||||
: desc.size;
|
||||
mat.create(size, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
GAPI_Assert(!desc.planar);
|
||||
mat.create(desc.dims, desc.depth);
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
void createMat(const cv::GMatDesc &desc, cv::Mat& mat)
|
||||
{
|
||||
// FIXME: Refactor (probably start supporting N-Dimensional blobs natively
|
||||
@@ -423,7 +375,6 @@ void createMat(const cv::GMatDesc &desc, cv::Mat& mat)
|
||||
mat.create(desc.dims, desc.depth);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace gimpl
|
||||
} // namespace cv
|
||||
|
||||
@@ -132,16 +132,16 @@ void cv::GComputation::apply(GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&ar
|
||||
m_priv->m_lastCompiled(std::move(ins), std::move(outs));
|
||||
}
|
||||
|
||||
void cv::GComputation::apply(const std::vector<cv::gapi::own::Mat> &ins,
|
||||
const std::vector<cv::gapi::own::Mat> &outs,
|
||||
void cv::GComputation::apply(const std::vector<cv::Mat> &ins,
|
||||
const std::vector<cv::Mat> &outs,
|
||||
GCompileArgs &&args)
|
||||
{
|
||||
GRunArgs call_ins;
|
||||
GRunArgsP call_outs;
|
||||
|
||||
auto tmp = outs;
|
||||
for (const cv::gapi::own::Mat &m : ins) { call_ins.emplace_back(m); }
|
||||
for ( cv::gapi::own::Mat &m : tmp) { call_outs.emplace_back(&m); }
|
||||
for (const cv::Mat &m : ins) { call_ins.emplace_back(m); }
|
||||
for ( cv::Mat &m : tmp) { call_outs.emplace_back(&m); }
|
||||
|
||||
apply(std::move(call_ins), std::move(call_outs), std::move(args));
|
||||
}
|
||||
|
||||
@@ -48,10 +48,9 @@ namespace{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
cv::GMatDesc cv::descr_of(const cv::Mat &mat)
|
||||
{
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
const auto mat_dims = mat.size.dims();
|
||||
|
||||
if (mat_dims == 2)
|
||||
@@ -63,33 +62,39 @@ cv::GMatDesc cv::descr_of(const cv::Mat &mat)
|
||||
dims[i] = mat.size[i];
|
||||
}
|
||||
return GMatDesc{mat.depth(), std::move(dims)};
|
||||
#else
|
||||
return (mat.dims.empty())
|
||||
? GMatDesc{mat.depth(), mat.channels(), {mat.cols, mat.rows}}
|
||||
: GMatDesc{mat.depth(), mat.dims};
|
||||
#endif
|
||||
}
|
||||
|
||||
cv::GMatDesc cv::gapi::own::descr_of(const Mat &mat)
|
||||
{
|
||||
return (mat.dims.empty())
|
||||
? GMatDesc{mat.depth(), mat.channels(), {mat.cols, mat.rows}}
|
||||
: GMatDesc{mat.depth(), mat.dims};
|
||||
}
|
||||
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
cv::GMatDesc cv::descr_of(const cv::UMat &mat)
|
||||
{
|
||||
GAPI_Assert(mat.size.dims() == 2);
|
||||
return GMatDesc{ mat.depth(), mat.channels(),{ mat.cols, mat.rows } };
|
||||
}
|
||||
|
||||
cv::GMetaArgs cv::descrs_of(const std::vector<cv::Mat> &vec)
|
||||
{
|
||||
return vec_descr_of(vec);
|
||||
}
|
||||
|
||||
cv::GMetaArgs cv::descrs_of(const std::vector<cv::UMat> &vec)
|
||||
{
|
||||
return vec_descr_of(vec);
|
||||
}
|
||||
#endif
|
||||
|
||||
cv::GMatDesc cv::gapi::own::descr_of(const cv::gapi::own::Mat &mat)
|
||||
cv::GMetaArgs cv::descrs_of(const std::vector<cv::Mat> &vec)
|
||||
{
|
||||
return (mat.dims.empty())
|
||||
? GMatDesc{mat.depth(), mat.channels(), {mat.cols, mat.rows}}
|
||||
: GMatDesc{mat.depth(), mat.dims};
|
||||
return vec_descr_of(vec);
|
||||
}
|
||||
|
||||
cv::GMetaArgs cv::gapi::own::descrs_of(const std::vector<cv::gapi::own::Mat> &vec)
|
||||
cv::GMetaArgs cv::gapi::own::descrs_of(const std::vector<Mat> &vec)
|
||||
{
|
||||
return vec_descr_of(vec);
|
||||
}
|
||||
@@ -126,21 +131,14 @@ std::ostream& operator<<(std::ostream& os, const cv::GMatDesc &desc)
|
||||
namespace {
|
||||
template<typename M> inline bool canDescribeHelper(const GMatDesc& desc, const M& mat)
|
||||
{
|
||||
const auto mat_desc = desc.planar ? descr_of(mat).asPlanar(desc.chan) : descr_of(mat);
|
||||
const auto mat_desc = desc.planar ? cv::descr_of(mat).asPlanar(desc.chan) : cv::descr_of(mat);
|
||||
return desc == mat_desc;
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
bool GMatDesc::canDescribe(const cv::gapi::own::Mat& mat) const
|
||||
{
|
||||
return canDescribeHelper(*this, mat);
|
||||
}
|
||||
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
bool GMatDesc::canDescribe(const cv::Mat& mat) const
|
||||
{
|
||||
return canDescribeHelper(*this, mat);
|
||||
}
|
||||
#endif
|
||||
|
||||
}// namespace cv
|
||||
|
||||
@@ -103,14 +103,8 @@ cv::GMetaArg cv::descr_of(const cv::GRunArg &arg)
|
||||
{
|
||||
switch (arg.index())
|
||||
{
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArg::index_of<cv::Mat>():
|
||||
return cv::GMetaArg(descr_of(util::get<cv::Mat>(arg)));
|
||||
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
case GRunArg::index_of<cv::gapi::own::Mat>():
|
||||
return cv::GMetaArg(descr_of(util::get<cv::gapi::own::Mat>(arg)));
|
||||
return cv::GMetaArg(cv::descr_of(util::get<cv::Mat>(arg)));
|
||||
|
||||
case GRunArg::index_of<cv::Scalar>():
|
||||
return cv::GMetaArg(descr_of(util::get<cv::Scalar>(arg)));
|
||||
@@ -140,10 +134,9 @@ cv::GMetaArg cv::descr_of(const cv::GRunArgP &argp)
|
||||
switch (argp.index())
|
||||
{
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::Mat*>(): return GMetaArg(descr_of(*util::get<cv::Mat*>(argp)));
|
||||
case GRunArgP::index_of<cv::UMat*>(): return GMetaArg(descr_of(*util::get<cv::UMat*>(argp)));
|
||||
case GRunArgP::index_of<cv::UMat*>(): return GMetaArg(cv::descr_of(*util::get<cv::UMat*>(argp)));
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::gapi::own::Mat*>(): return GMetaArg(descr_of(*util::get<cv::gapi::own::Mat*>(argp)));
|
||||
case GRunArgP::index_of<cv::Mat*>(): return GMetaArg(cv::descr_of(*util::get<cv::Mat*>(argp)));
|
||||
case GRunArgP::index_of<cv::Scalar*>(): return GMetaArg(descr_of(*util::get<cv::Scalar*>(argp)));
|
||||
case GRunArgP::index_of<cv::detail::VectorRef>(): return GMetaArg(util::get<cv::detail::VectorRef>(argp).descr_of());
|
||||
case GRunArgP::index_of<cv::detail::OpaqueRef>(): return GMetaArg(util::get<cv::detail::OpaqueRef>(argp).descr_of());
|
||||
@@ -156,13 +149,11 @@ bool cv::can_describe(const GMetaArg& meta, const GRunArgP& argp)
|
||||
switch (argp.index())
|
||||
{
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::UMat*>(): return meta == GMetaArg(cv::descr_of(*util::get<cv::UMat*>(argp)));
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::Mat*>(): return util::holds_alternative<GMatDesc>(meta) &&
|
||||
util::get<GMatDesc>(meta).canDescribe(*util::get<cv::Mat*>(argp));
|
||||
case GRunArgP::index_of<cv::UMat*>(): return meta == GMetaArg(descr_of(*util::get<cv::UMat*>(argp)));
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::gapi::own::Mat*>(): return util::holds_alternative<GMatDesc>(meta) &&
|
||||
util::get<GMatDesc>(meta).canDescribe(*util::get<cv::gapi::own::Mat*>(argp));
|
||||
case GRunArgP::index_of<cv::Scalar*>(): return meta == GMetaArg(descr_of(*util::get<cv::Scalar*>(argp)));
|
||||
case GRunArgP::index_of<cv::Scalar*>(): return meta == GMetaArg(cv::descr_of(*util::get<cv::Scalar*>(argp)));
|
||||
case GRunArgP::index_of<cv::detail::VectorRef>(): return meta == GMetaArg(util::get<cv::detail::VectorRef>(argp).descr_of());
|
||||
case GRunArgP::index_of<cv::detail::OpaqueRef>(): return meta == GMetaArg(util::get<cv::detail::OpaqueRef>(argp).descr_of());
|
||||
default: util::throw_error(std::logic_error("Unsupported GRunArgP type"));
|
||||
@@ -174,12 +165,10 @@ bool cv::can_describe(const GMetaArg& meta, const GRunArg& arg)
|
||||
switch (arg.index())
|
||||
{
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArg::index_of<cv::Mat>(): return util::holds_alternative<GMatDesc>(meta) &&
|
||||
util::get<GMatDesc>(meta).canDescribe(util::get<cv::Mat>(arg));
|
||||
case GRunArg::index_of<cv::UMat>(): return meta == cv::GMetaArg(descr_of(util::get<cv::UMat>(arg)));
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
case GRunArg::index_of<cv::gapi::own::Mat>(): return util::holds_alternative<GMatDesc>(meta) &&
|
||||
util::get<GMatDesc>(meta).canDescribe(util::get<cv::gapi::own::Mat>(arg));
|
||||
case GRunArg::index_of<cv::Mat>(): return util::holds_alternative<GMatDesc>(meta) &&
|
||||
util::get<GMatDesc>(meta).canDescribe(util::get<cv::Mat>(arg));
|
||||
case GRunArg::index_of<cv::Scalar>(): return meta == cv::GMetaArg(descr_of(util::get<cv::Scalar>(arg)));
|
||||
case GRunArg::index_of<cv::detail::VectorRef>(): return meta == cv::GMetaArg(util::get<cv::detail::VectorRef>(arg).descr_of());
|
||||
case GRunArg::index_of<cv::detail::OpaqueRef>(): return meta == cv::GMetaArg(util::get<cv::detail::OpaqueRef>(arg).descr_of());
|
||||
@@ -203,21 +192,16 @@ void cv::validate_input_arg(const GRunArg& arg)
|
||||
switch (arg.index())
|
||||
{
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArg::index_of<cv::Mat>():
|
||||
{
|
||||
const auto desc = descr_of(util::get<cv::Mat>(arg));
|
||||
GAPI_Assert(desc.size.height != 0 && desc.size.width != 0 && "incorrect dimensions of cv::Mat!"); break;
|
||||
}
|
||||
case GRunArg::index_of<cv::UMat>():
|
||||
{
|
||||
const auto desc = descr_of(util::get<cv::UMat>(arg));
|
||||
const auto desc = cv::descr_of(util::get<cv::UMat>(arg));
|
||||
GAPI_Assert(desc.size.height != 0 && desc.size.width != 0 && "incorrect dimensions of cv::UMat!"); break;
|
||||
}
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
case GRunArg::index_of<cv::gapi::own::Mat>():
|
||||
case GRunArg::index_of<cv::Mat>():
|
||||
{
|
||||
const auto desc = descr_of(util::get<cv::gapi::own::Mat>(arg));
|
||||
GAPI_Assert(desc.size.height != 0 && desc.size.width != 0 && "incorrect dimensions of own::Mat!"); break;
|
||||
const auto desc = cv::descr_of(util::get<cv::Mat>(arg));
|
||||
GAPI_Assert(desc.size.height != 0 && desc.size.width != 0 && "incorrect dimensions of Mat!"); break;
|
||||
}
|
||||
default:
|
||||
// No extra handling
|
||||
@@ -271,15 +255,13 @@ const void* cv::gimpl::proto::ptr(const GRunArgP &arg)
|
||||
switch (arg.index())
|
||||
{
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::UMat*>():
|
||||
return static_cast<const void*>(cv::util::get<cv::UMat*>(arg));
|
||||
#endif
|
||||
case GRunArgP::index_of<cv::Mat*>():
|
||||
return static_cast<const void*>(cv::util::get<cv::Mat*>(arg));
|
||||
case GRunArgP::index_of<cv::Scalar*>():
|
||||
return static_cast<const void*>(cv::util::get<cv::Scalar*>(arg));
|
||||
case GRunArgP::index_of<cv::UMat*>():
|
||||
return static_cast<const void*>(cv::util::get<cv::UMat*>(arg));
|
||||
#endif
|
||||
case GRunArgP::index_of<cv::gapi::own::Mat*>():
|
||||
return static_cast<const void*>(cv::util::get<cv::gapi::own::Mat*>(arg));
|
||||
case GRunArgP::index_of<cv::detail::VectorRef>():
|
||||
return cv::util::get<cv::detail::VectorRef>(arg).ptr();
|
||||
case GRunArgP::index_of<cv::detail::OpaqueRef>():
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <opencv2/gapi/gscalar.hpp>
|
||||
#include <opencv2/gapi/own/convert.hpp>
|
||||
#include "api/gorigin.hpp"
|
||||
|
||||
// cv::GScalar public implementation ///////////////////////////////////////////
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <ade/node.hpp>
|
||||
|
||||
#include "opencv2/gapi/garg.hpp"
|
||||
#include "opencv2/gapi/own/mat.hpp"
|
||||
|
||||
#include "opencv2/gapi/util/optional.hpp"
|
||||
|
||||
@@ -45,9 +44,9 @@ namespace magazine {
|
||||
|
||||
} // namespace magazine
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
using Mag = magazine::Class<cv::gapi::own::Mat, cv::UMat, cv::Scalar, cv::detail::VectorRef, cv::detail::OpaqueRef>;
|
||||
using Mag = magazine::Class<cv::Mat, cv::UMat, cv::Scalar, cv::detail::VectorRef, cv::detail::OpaqueRef>;
|
||||
#else
|
||||
using Mag = magazine::Class<cv::gapi::own::Mat, cv::Scalar, cv::detail::VectorRef, cv::detail::OpaqueRef>;
|
||||
using Mag = magazine::Class<cv::Mat, cv::Scalar, cv::detail::VectorRef, cv::detail::OpaqueRef>;
|
||||
#endif
|
||||
|
||||
namespace magazine
|
||||
@@ -98,10 +97,7 @@ inline cv::util::optional<T> getCompileArg(const cv::GCompileArgs &args)
|
||||
return cv::util::optional<T>();
|
||||
}
|
||||
|
||||
void createMat(const cv::GMatDesc& desc, cv::gapi::own::Mat& mat);
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
void createMat(const cv::GMatDesc& desc, cv::Mat& mat);
|
||||
#endif
|
||||
|
||||
}} // cv::gimpl
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ cv::gimpl::GCPUExecutable::GCPUExecutable(const ade::Graph &g,
|
||||
if (desc.storage == Data::Storage::INTERNAL && desc.shape == GShape::GMAT)
|
||||
{
|
||||
const auto mat_desc = util::get<cv::GMatDesc>(desc.meta);
|
||||
auto& mat = m_res.slot<cv::gapi::own::Mat>()[desc.rc];
|
||||
auto& mat = m_res.slot<cv::Mat>()[desc.rc];
|
||||
createMat(mat_desc, mat);
|
||||
}
|
||||
break;
|
||||
@@ -128,7 +128,7 @@ cv::GArg cv::gimpl::GCPUExecutable::packArg(const GArg &arg)
|
||||
const cv::gimpl::RcDesc &ref = arg.get<cv::gimpl::RcDesc>();
|
||||
switch (ref.shape)
|
||||
{
|
||||
case GShape::GMAT: return GArg(m_res.slot<cv::gapi::own::Mat>() [ref.id]);
|
||||
case GShape::GMAT: return GArg(m_res.slot<cv::Mat>() [ref.id]);
|
||||
case GShape::GSCALAR: return GArg(m_res.slot<cv::Scalar>()[ref.id]);
|
||||
// Note: .at() is intentional for GArray and GOpaque as objects MUST be already there
|
||||
// (and constructed by either bindIn/Out or resetInternal)
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
|
||||
#include <opencv2/gapi/cpu/gcpukernel.hpp>
|
||||
|
||||
const cv::gapi::own::Mat& cv::GCPUContext::inMat(int input)
|
||||
const cv::Mat& cv::GCPUContext::inMat(int input)
|
||||
{
|
||||
return inArg<cv::gapi::own::Mat>(input);
|
||||
return inArg<cv::Mat>(input);
|
||||
}
|
||||
|
||||
cv::gapi::own::Mat& cv::GCPUContext::outMatR(int output)
|
||||
cv::Mat& cv::GCPUContext::outMatR(int output)
|
||||
{
|
||||
return *util::get<cv::gapi::own::Mat*>(m_results.at(output));
|
||||
return *util::get<cv::Mat*>(m_results.at(output));
|
||||
}
|
||||
|
||||
const cv::Scalar& cv::GCPUContext::inVal(int input)
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <opencv2/gapi/gcommon.hpp>
|
||||
#include "logger.hpp"
|
||||
|
||||
#include <opencv2/gapi/own/convert.hpp>
|
||||
#include <opencv2/gapi/gmat.hpp> //for version of descr_of
|
||||
// PRIVATE STUFF!
|
||||
#include "compiler/gobjref.hpp"
|
||||
@@ -1246,7 +1245,7 @@ void cv::gimpl::GFluidExecutable::bindInArg(const cv::gimpl::RcDesc &rc, const G
|
||||
{
|
||||
switch (rc.shape)
|
||||
{
|
||||
case GShape::GMAT: m_buffers[m_id_map.at(rc.id)].priv().bindTo(util::get<cv::gapi::own::Mat>(arg), true); break;
|
||||
case GShape::GMAT: m_buffers[m_id_map.at(rc.id)].priv().bindTo(util::get<cv::Mat>(arg), true); break;
|
||||
case GShape::GSCALAR: m_res.slot<cv::Scalar>()[rc.id] = util::get<cv::Scalar>(arg); break;
|
||||
case GShape::GARRAY: m_res.slot<cv::detail::VectorRef>()[rc.id] = util::get<cv::detail::VectorRef>(arg); break;
|
||||
case GShape::GOPAQUE: m_res.slot<cv::detail::OpaqueRef>()[rc.id] = util::get<cv::detail::OpaqueRef>(arg); break;
|
||||
@@ -1266,20 +1265,12 @@ void cv::gimpl::GFluidExecutable::bindOutArg(const cv::gimpl::RcDesc &rc, const
|
||||
|
||||
switch (arg.index()) {
|
||||
// FIXME: See the bindInArg comment on Streaming-related changes
|
||||
case T::index_of<cv::gapi::own::Mat*>(): {
|
||||
auto &outMat = *util::get<cv::gapi::own::Mat*>(arg);
|
||||
GAPI_Assert(outMat.data != nullptr);
|
||||
GAPI_Assert(descr_of(outMat) == desc && "Output argument was not preallocated as it should be ?");
|
||||
bref.bindTo(outMat, false);
|
||||
} break;
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case T::index_of<cv::Mat*>(): {
|
||||
auto &outMat = *util::get<cv::Mat*>(arg);
|
||||
GAPI_Assert(outMat.data != nullptr);
|
||||
GAPI_Assert(descr_of(outMat) == desc && "Output argument was not preallocated as it should be ?");
|
||||
bref.bindTo(cv::to_own(outMat), false);
|
||||
GAPI_Assert(cv::descr_of(outMat) == desc && "Output argument was not preallocated as it should be ?");
|
||||
bref.bindTo(outMat, false);
|
||||
} break;
|
||||
#endif // GAPI_STANDALONE
|
||||
default: GAPI_Assert(false);
|
||||
} // switch(arg.index())
|
||||
break;
|
||||
|
||||
@@ -78,7 +78,7 @@ void fillConstBorderRow(uint8_t* row, int length, int chan, int borderSize, cv::
|
||||
}
|
||||
|
||||
// Fills const border pixels in the whole mat
|
||||
void fillBorderConstant(int borderSize, cv::Scalar borderValue, cv::gapi::own::Mat& mat)
|
||||
void fillBorderConstant(int borderSize, cv::Scalar borderValue, cv::Mat& mat)
|
||||
{
|
||||
// cv::Scalar can contain maximum 4 chan
|
||||
GAPI_Assert(mat.channels() > 0 && mat.channels() <= 4);
|
||||
@@ -178,9 +178,7 @@ const uint8_t* fluid::BorderHandlerT<cv::BORDER_CONSTANT>::inLineB(int /*log_idx
|
||||
void fluid::BorderHandlerT<cv::BORDER_CONSTANT>::fillCompileTimeBorder(BufferStorageWithBorder& data)
|
||||
{
|
||||
m_const_border.create(1, data.cols(), data.data().type());
|
||||
// FIXME: remove this crutch in deowned Mat
|
||||
m_const_border = {m_border_value[0], m_border_value[1],
|
||||
m_border_value[2], m_border_value[3]};
|
||||
m_const_border = m_border_value;
|
||||
|
||||
cv::gapi::fillBorderConstant(m_border_size, m_border_value, data.data());
|
||||
}
|
||||
@@ -266,7 +264,7 @@ const uint8_t* fluid::BufferStorageWithBorder::inLineB(int log_idx, int desc_hei
|
||||
}
|
||||
}
|
||||
|
||||
static void copyWithoutBorder(const cv::gapi::own::Mat& src, int src_border_size, cv::gapi::own::Mat& dst, int dst_border_size, int startSrcLine, int startDstLine, int lpi)
|
||||
static void copyWithoutBorder(const cv::Mat& src, int src_border_size, cv::Mat& dst, int dst_border_size, int startSrcLine, int startDstLine, int lpi)
|
||||
{
|
||||
auto subSrc = src(cv::Rect{src_border_size, startSrcLine, src.cols - 2*src_border_size, lpi});
|
||||
auto subDst = dst(cv::Rect{dst_border_size, startDstLine, dst.cols - 2*dst_border_size, lpi});
|
||||
@@ -362,8 +360,8 @@ std::unique_ptr<fluid::BufferStorage> createStorage(int capacity, int desc_width
|
||||
#endif
|
||||
}
|
||||
|
||||
std::unique_ptr<BufferStorage> createStorage(const cv::gapi::own::Mat& data, cv::Rect roi);
|
||||
std::unique_ptr<BufferStorage> createStorage(const cv::gapi::own::Mat& data, cv::Rect roi)
|
||||
std::unique_ptr<BufferStorage> createStorage(const cv::Mat& data, cv::Rect roi);
|
||||
std::unique_ptr<BufferStorage> createStorage(const cv::Mat& data, cv::Rect roi)
|
||||
{
|
||||
std::unique_ptr<BufferStorageWithoutBorder> storage(new BufferStorageWithoutBorder);
|
||||
storage->attach(data, roi);
|
||||
@@ -547,10 +545,10 @@ void fluid::Buffer::Priv::allocate(BorderOpt border,
|
||||
m_storage->updateOutCache(m_cache, m_write_caret, m_writer_lpi);
|
||||
}
|
||||
|
||||
void fluid::Buffer::Priv::bindTo(const cv::gapi::own::Mat &data, bool is_input)
|
||||
void fluid::Buffer::Priv::bindTo(const cv::Mat &data, bool is_input)
|
||||
{
|
||||
// FIXME: move all these fields into a separate structure
|
||||
GAPI_Assert(m_desc == descr_of(data));
|
||||
GAPI_Assert(m_desc == cv::descr_of(data));
|
||||
|
||||
// Currently m_writer_lpi is obtained from metadata which is shared between islands
|
||||
// and this assert can trigger for slot which connects two fluid islands.
|
||||
@@ -669,13 +667,13 @@ fluid::Buffer::Buffer(const cv::GMatDesc &desc,
|
||||
m_priv->allocate(border, border_size, max_line_consumption, skew);
|
||||
}
|
||||
|
||||
fluid::Buffer::Buffer(const cv::gapi::own::Mat &data, bool is_input)
|
||||
fluid::Buffer::Buffer(const cv::Mat &data, bool is_input)
|
||||
: m_priv(new Priv())
|
||||
, m_cache(&m_priv->cache())
|
||||
{
|
||||
int wlpi = 1, readStart = 0;
|
||||
cv::Rect roi{0, 0, data.cols, data.rows};
|
||||
m_priv->init(descr_of(data), wlpi, readStart, roi);
|
||||
m_priv->init(cv::descr_of(data), wlpi, readStart, roi);
|
||||
m_priv->bindTo(data, is_input);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ template<>
|
||||
class BorderHandlerT<cv::BORDER_CONSTANT> : public BorderHandler
|
||||
{
|
||||
cv::Scalar m_border_value;
|
||||
cv::gapi::own::Mat m_const_border;
|
||||
cv::Mat m_const_border;
|
||||
|
||||
public:
|
||||
BorderHandlerT(int border_size, cv::Scalar border_value);
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
class BufferStorage
|
||||
{
|
||||
protected:
|
||||
cv::gapi::own::Mat m_data;
|
||||
cv::Mat m_data;
|
||||
|
||||
public:
|
||||
void updateInCache(View::Cache& cache, int start_log_idx, int nLines) const;
|
||||
@@ -80,8 +80,8 @@ public:
|
||||
|
||||
inline bool empty() const { return m_data.empty(); }
|
||||
|
||||
inline const cv::gapi::own::Mat& data() const { return m_data; }
|
||||
inline cv::gapi::own::Mat& data() { return m_data; }
|
||||
inline const cv::Mat& data() const { return m_data; }
|
||||
inline cv::Mat& data() { return m_data; }
|
||||
|
||||
inline int rows() const { return m_data.rows; }
|
||||
inline int cols() const { return m_data.cols; }
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
return m_data.ptr(physIdx(idx), 0);
|
||||
}
|
||||
|
||||
inline void attach(const cv::gapi::own::Mat& _data, cv::Rect _roi)
|
||||
inline void attach(const cv::Mat& _data, cv::Rect _roi)
|
||||
{
|
||||
m_data = _data(_roi);
|
||||
m_roi = _roi;
|
||||
@@ -263,7 +263,7 @@ public:
|
||||
cv::Rect roi);
|
||||
|
||||
void allocate(BorderOpt border, int border_size, int line_consumption, int skew);
|
||||
void bindTo(const cv::gapi::own::Mat &data, bool is_input);
|
||||
void bindTo(const cv::Mat &data, bool is_input);
|
||||
|
||||
inline void addView(const View* view) { m_views.emplace_back(view); }
|
||||
|
||||
|
||||
@@ -285,11 +285,11 @@ struct IECallContext
|
||||
const T& inArg(std::size_t input) { return args.at(input).get<T>(); }
|
||||
|
||||
// Syntax sugar
|
||||
const cv::gapi::own::Mat& inMat(std::size_t input) {
|
||||
return inArg<cv::gapi::own::Mat>(input);
|
||||
const cv::Mat& inMat(std::size_t input) {
|
||||
return inArg<cv::Mat>(input);
|
||||
}
|
||||
cv::gapi::own::Mat& outMatR(std::size_t output) {
|
||||
return *cv::util::get<cv::gapi::own::Mat*>(results.at(output));
|
||||
cv::Mat& outMatR(std::size_t output) {
|
||||
return *cv::util::get<cv::Mat*>(results.at(output));
|
||||
}
|
||||
|
||||
template<typename T> std::vector<T>& outVecR(std::size_t output) { // FIXME: the same issue
|
||||
@@ -391,7 +391,7 @@ cv::GArg cv::gimpl::ie::GIEExecutable::packArg(const cv::GArg &arg) {
|
||||
const cv::gimpl::RcDesc &ref = arg.get<cv::gimpl::RcDesc>();
|
||||
switch (ref.shape)
|
||||
{
|
||||
case GShape::GMAT: return GArg(m_res.slot<cv::gapi::own::Mat>()[ref.id]);
|
||||
case GShape::GMAT: return GArg(m_res.slot<cv::Mat>()[ref.id]);
|
||||
|
||||
// Note: .at() is intentional for GArray as object MUST be already there
|
||||
// (and constructed by either bindIn/Out or resetInternal)
|
||||
@@ -528,7 +528,7 @@ struct Infer: public cv::detail::KernelTag {
|
||||
// Not a <very> big deal for classifiers and detectors,
|
||||
// but may be critical to segmentation.
|
||||
|
||||
cv::gapi::own::Mat& out_mat = ctx.outMatR(i);
|
||||
cv::Mat& out_mat = ctx.outMatR(i);
|
||||
IE::Blob::Ptr this_blob = iec.this_request.GetBlob(uu.params.output_names[i]);
|
||||
copyFromIE(this_blob, out_mat);
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ cv::gimpl::GOCLExecutable::GOCLExecutable(const ade::Graph &g,
|
||||
if (desc.storage == Data::Storage::INTERNAL && desc.shape == GShape::GMAT)
|
||||
{
|
||||
const auto mat_desc = util::get<cv::GMatDesc>(desc.meta);
|
||||
auto& mat = m_res.slot<cv::gapi::own::Mat>()[desc.rc];
|
||||
auto& mat = m_res.slot<cv::Mat>()[desc.rc];
|
||||
createMat(mat_desc, mat);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -212,20 +212,12 @@ void cv::gimpl::GPlaidMLExecutable::bindInArg(const RcDesc &rc, const GRunArg &
|
||||
|
||||
switch (arg.index())
|
||||
{
|
||||
case GRunArg::index_of<cv::gapi::own::Mat>():
|
||||
{
|
||||
auto& arg_mat = util::get<cv::gapi::own::Mat>(arg);
|
||||
binder_->input(it->second).copy_from(arg_mat.data);
|
||||
}
|
||||
break;
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArg::index_of<cv::Mat>() :
|
||||
{
|
||||
auto& arg_mat = util::get<cv::Mat>(arg);
|
||||
binder_->input(it->second).copy_from(arg_mat.data);
|
||||
}
|
||||
break;
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
default: util::throw_error(std::logic_error("content type of the runtime argument does not match to resource description ?"));
|
||||
}
|
||||
}
|
||||
@@ -248,20 +240,12 @@ void cv::gimpl::GPlaidMLExecutable::bindOutArg(const RcDesc &rc, const GRunArgP
|
||||
|
||||
switch (arg.index())
|
||||
{
|
||||
case GRunArgP::index_of<cv::gapi::own::Mat*>():
|
||||
{
|
||||
auto& arg_mat = *util::get<cv::gapi::own::Mat*>(arg);
|
||||
binder_->output(it->second).copy_into(arg_mat.data);
|
||||
}
|
||||
break;
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::Mat*>() :
|
||||
{
|
||||
auto& arg_mat = *util::get<cv::Mat*>(arg);
|
||||
binder_->output(it->second).copy_into(arg_mat.data);
|
||||
}
|
||||
break;
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
default: util::throw_error(std::logic_error("content type of the runtime argument does not match to resource description ?"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ cv::GArg cv::gimpl::render::ocv::GRenderExecutable::packArg(const cv::GArg &arg)
|
||||
const cv::gimpl::RcDesc &ref = arg.get<cv::gimpl::RcDesc>();
|
||||
switch (ref.shape)
|
||||
{
|
||||
case GShape::GMAT: return GArg(m_res.slot<cv::gapi::own::Mat>()[ref.id]);
|
||||
case GShape::GMAT: return GArg(m_res.slot<cv::Mat>()[ref.id]);
|
||||
case GShape::GARRAY: return GArg(m_res.slot<cv::detail::VectorRef>().at(ref.id));
|
||||
default:
|
||||
util::throw_error(std::logic_error("Unsupported GShape type"));
|
||||
|
||||
@@ -348,7 +348,7 @@ void GIslandExecutable::run(GIslandExecutable::IInput &in, GIslandExecutable::IO
|
||||
switch (in_data_orig.index())
|
||||
{
|
||||
case cv::GRunArg::index_of<cv::Mat>():
|
||||
in_data = cv::GRunArg{cv::to_own(cv::util::get<cv::Mat>(in_data_orig))};
|
||||
in_data = cv::GRunArg{cv::util::get<cv::Mat>(in_data_orig)};
|
||||
break;
|
||||
case cv::GRunArg::index_of<cv::Scalar>():
|
||||
in_data = cv::GRunArg{(cv::util::get<cv::Scalar>(in_data_orig))};
|
||||
|
||||
@@ -100,7 +100,7 @@ void cv::gimpl::GExecutor::initResource(const ade::NodeHandle &orig_nh)
|
||||
case GShape::GMAT:
|
||||
{
|
||||
const auto desc = util::get<cv::GMatDesc>(d.meta);
|
||||
auto& mat = m_res.slot<cv::gapi::own::Mat>()[d.rc];
|
||||
auto& mat = m_res.slot<cv::Mat>()[d.rc];
|
||||
createMat(desc, mat);
|
||||
}
|
||||
break;
|
||||
@@ -182,7 +182,7 @@ void cv::gimpl::GExecutor::run(cv::gimpl::GRuntimeArgs &&args)
|
||||
|
||||
auto check_own_mat = [&desc, &args, &index]()
|
||||
{
|
||||
auto& out_mat = *get<cv::gapi::own::Mat*>(args.outObjs.at(index));
|
||||
auto& out_mat = *get<cv::Mat*>(args.outObjs.at(index));
|
||||
GAPI_Assert(out_mat.data != nullptr &&
|
||||
desc.canDescribe(out_mat));
|
||||
};
|
||||
|
||||
@@ -98,8 +98,6 @@ std::vector<cv::gimpl::stream::Q*> input_queues( ade::Graph &g,
|
||||
|
||||
void sync_data(cv::GRunArgs &results, cv::GRunArgsP &outputs)
|
||||
{
|
||||
namespace own = cv::gapi::own;
|
||||
|
||||
for (auto && it : ade::util::zip(ade::util::toRange(outputs),
|
||||
ade::util::toRange(results)))
|
||||
{
|
||||
@@ -110,14 +108,9 @@ void sync_data(cv::GRunArgs &results, cv::GRunArgsP &outputs)
|
||||
using T = cv::GRunArgP;
|
||||
switch (out_obj.index())
|
||||
{
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case T::index_of<cv::Mat*>():
|
||||
*cv::util::get<cv::Mat*>(out_obj) = std::move(cv::util::get<cv::Mat>(res_obj));
|
||||
break;
|
||||
#endif // !GAPI_STANDALONE
|
||||
case T::index_of<own::Mat*>():
|
||||
*cv::util::get<own::Mat*>(out_obj) = std::move(cv::util::get<own::Mat>(res_obj));
|
||||
break;
|
||||
case T::index_of<cv::Scalar*>():
|
||||
*cv::util::get<cv::Scalar*>(out_obj) = std::move(cv::util::get<cv::Scalar>(res_obj));
|
||||
break;
|
||||
@@ -420,13 +413,8 @@ 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{});
|
||||
|
||||
Reference in New Issue
Block a user