mirror of
https://github.com/opencv/opencv.git
synced 2026-12-05 22:45:01 -06: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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user