1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

Added planar flag to GMatDesc, intergated into framework, added tests

This commit is contained in:
Ruslan Garnov
2019-04-22 17:36:10 +03:00
parent 1f517b8a02
commit f81886d17c
14 changed files with 519 additions and 27 deletions
@@ -99,7 +99,10 @@ 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
@@ -101,8 +101,8 @@ 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);
const auto type = CV_MAKETYPE(mat_desc.depth, mat_desc.chan);
m_res.slot<cv::gapi::own::Mat>()[desc.rc].create(mat_desc.size, type);
auto& mat = m_res.slot<cv::gapi::own::Mat>()[desc.rc];
createMat(mat_desc, mat);
}
break;
}
@@ -207,14 +207,16 @@ void cv::gimpl::GCPUExecutable::run(std::vector<InObj> &&input_objs,
//As Kernels are forbidden to allocate memory for (Mat) outputs,
//this code seems redundant, at least for Mats
//FIXME: unify with cv::detail::ensure_out_mats_not_reallocated
//FIXME: when it's done, remove can_describe(const GMetaArg&, const GRunArgP&)
//and descr_of(const cv::GRunArgP &argp)
for (const auto &out_it : ade::util::indexed(op_info.expected_out_metas))
{
const auto out_index = ade::util::index(out_it);
const auto expected_meta = ade::util::value(out_it);
const auto out_meta = descr_of(context.m_results[out_index]);
if (expected_meta != out_meta)
if (!can_describe(expected_meta, context.m_results[out_index]))
{
const auto out_meta = descr_of(context.m_results[out_index]);
util::throw_error
(std::logic_error
("Output meta doesn't "
@@ -101,8 +101,8 @@ 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);
const auto type = CV_MAKETYPE(mat_desc.depth, mat_desc.chan);
m_res.slot<cv::UMat>()[desc.rc].create(mat_desc.size.height, mat_desc.size.width, type);
auto& mat = m_res.slot<cv::gapi::own::Mat>()[desc.rc];
createMat(mat_desc, mat);
}
break;
}
@@ -208,10 +208,10 @@ void cv::gimpl::GOCLExecutable::run(std::vector<InObj> &&input_objs,
{
const auto out_index = ade::util::index(out_it);
const auto expected_meta = ade::util::value(out_it);
const auto out_meta = descr_of(context.m_results[out_index]);
if (expected_meta != out_meta)
if (!can_describe(expected_meta, context.m_results[out_index]))
{
const auto out_meta = descr_of(context.m_results[out_index]);
util::throw_error
(std::logic_error
("Output meta doesn't "