mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
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
@@ -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"));
|
||||
|
||||
Reference in New Issue
Block a user