mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
Merge pull request #12674 from dmatveev:gapi_upd270918
* Update G-API code base to 27-Sep-18 Changes mostly improve standalone build support * G-API code base update 28-09-2018 * Windows/Documentation warnings should be fixed * Fixed stability issues in Fluid backend * Fixed precompiled headers issues in G-API source files * G-API code base update 28-09-18 EOD * Fixed several static analysis issues * Fixed issues found when G-API is built in a standalone mode
This commit is contained in:
committed by
Alexander Alekhin
parent
66fdddc339
commit
2c6ab65476
@@ -5,6 +5,7 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include <ade/util/assert.hpp>
|
||||
|
||||
#include "api/gapi_priv.hpp"
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencv2/gapi/garray.hpp"
|
||||
#include "api/gapi_priv.hpp" // GOrigin
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include <memory> // unique_ptr
|
||||
|
||||
#include "opencv2/gapi/gkernel.hpp"
|
||||
@@ -15,8 +16,6 @@
|
||||
#include "compiler/gobjref.hpp"
|
||||
#include "compiler/gislandmodel.hpp"
|
||||
|
||||
|
||||
|
||||
// GBackend private implementation /////////////////////////////////////////////
|
||||
void cv::gapi::GBackend::Priv::unpackKernel(ade::Graph & /*graph */ ,
|
||||
const ade::NodeHandle & /*op_node*/ ,
|
||||
@@ -94,19 +93,24 @@ void bindInArg(Mag& mag, const RcDesc &rc, const GRunArg &arg)
|
||||
switch (arg.index())
|
||||
{
|
||||
case GRunArg::index_of<cv::gapi::own::Mat>() : mag_mat = util::get<cv::gapi::own::Mat>(arg); break;
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArg::index_of<cv::Mat>() : 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;
|
||||
}
|
||||
|
||||
|
||||
case GShape::GSCALAR:
|
||||
{
|
||||
auto& mag_scalar = mag.template slot<cv::gapi::own::Scalar>()[rc.id];
|
||||
switch (arg.index())
|
||||
{
|
||||
case GRunArg::index_of<cv::gapi::own::Scalar>() : mag_scalar = util::get<cv::gapi::own::Scalar>(arg); break;
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArg::index_of<cv::Scalar>() : mag_scalar = to_own(util::get<cv::Scalar>(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;
|
||||
@@ -131,7 +135,9 @@ void bindOutArg(Mag& mag, const RcDesc &rc, const GRunArgP &arg)
|
||||
switch (arg.index())
|
||||
{
|
||||
case GRunArgP::index_of<cv::gapi::own::Mat*>() : mag_mat = * util::get<cv::gapi::own::Mat*>(arg); break;
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::Mat*>() : 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;
|
||||
@@ -143,7 +149,9 @@ void bindOutArg(Mag& mag, const RcDesc &rc, const GRunArgP &arg)
|
||||
switch (arg.index())
|
||||
{
|
||||
case GRunArgP::index_of<cv::gapi::own::Scalar*>() : mag_scalar = *util::get<cv::gapi::own::Scalar*>(arg); break;
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::Scalar*>() : mag_scalar = to_own(*util::get<cv::Scalar*>(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;
|
||||
@@ -238,7 +246,9 @@ void writeBack(const Mag& mag, const RcDesc &rc, GRunArgP &g_arg)
|
||||
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;
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::Mat*>() : out_arg_data = util::get<cv::Mat*>(g_arg)->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 ?"));
|
||||
}
|
||||
|
||||
@@ -252,7 +262,9 @@ void writeBack(const Mag& mag, const RcDesc &rc, GRunArgP &g_arg)
|
||||
switch (g_arg.index())
|
||||
{
|
||||
case GRunArgP::index_of<cv::gapi::own::Scalar*>() : *util::get<cv::gapi::own::Scalar*>(g_arg) = mag.template slot<cv::gapi::own::Scalar>().at(rc.id); break;
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
case GRunArgP::index_of<cv::Scalar*>() : *util::get<cv::Scalar*>(g_arg) = cv::gapi::own::to_ocv(mag.template slot<cv::gapi::own::Scalar>().at(rc.id)); 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;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include <cassert>
|
||||
#include "opencv2/gapi/gcall.hpp"
|
||||
#include "api/gcall_priv.hpp"
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include <algorithm> // remove_if
|
||||
#include <cctype> // isspace (non-locale version)
|
||||
#include <ade/util/algorithm.hpp>
|
||||
|
||||
#include "opencv2/core/cvdef.h"
|
||||
#include "logger.hpp" // GAPI_LOG
|
||||
|
||||
#include "opencv2/gapi/gcomputation.hpp"
|
||||
@@ -89,6 +89,21 @@ 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,
|
||||
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); }
|
||||
|
||||
apply(std::move(call_ins), std::move(call_outs), std::move(args));
|
||||
}
|
||||
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
void cv::GComputation::apply(cv::Mat in, cv::Mat &out, GCompileArgs &&args)
|
||||
{
|
||||
apply(cv::gin(in), cv::gout(out), std::move(args));
|
||||
@@ -126,6 +141,7 @@ void cv::GComputation::apply(const std::vector<cv::Mat> &ins,
|
||||
|
||||
apply(std::move(call_ins), std::move(call_outs), std::move(args));
|
||||
}
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
cv::GComputation::Priv& cv::GComputation::priv()
|
||||
{
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include <iostream> // cerr
|
||||
#include <functional> // hash
|
||||
#include <numeric> // accumulate
|
||||
|
||||
#include <ade/util/algorithm.hpp>
|
||||
|
||||
#include "opencv2/core/cvdef.h"
|
||||
#include "logger.hpp"
|
||||
#include "opencv2/gapi/gkernel.hpp"
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
#include <opencv2/gapi/own/mat.hpp> //gapi::own::Mat
|
||||
|
||||
@@ -32,10 +33,12 @@ const cv::GOrigin& cv::GMat::priv() const
|
||||
return *m_priv;
|
||||
}
|
||||
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
cv::GMatDesc cv::descr_of(const cv::Mat &mat)
|
||||
{
|
||||
return GMatDesc{mat.depth(), mat.channels(), {mat.cols, mat.rows}};
|
||||
}
|
||||
#endif
|
||||
|
||||
cv::GMatDesc cv::gapi::own::descr_of(const cv::gapi::own::Mat &mat)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include <cassert>
|
||||
|
||||
#include "api/gnode.hpp"
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <ade/util/algorithm.hpp>
|
||||
#include "opencv2/gapi/util/throw.hpp"
|
||||
#include "opencv2/gapi/garg.hpp"
|
||||
@@ -86,11 +88,16 @@ 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)));
|
||||
|
||||
case GRunArg::index_of<cv::Scalar>():
|
||||
return cv::GMetaArg(descr_of(util::get<cv::Scalar>(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)));
|
||||
|
||||
case GRunArg::index_of<cv::gapi::own::Scalar>():
|
||||
return cv::GMetaArg(descr_of(util::get<cv::gapi::own::Scalar>(arg)));
|
||||
@@ -113,9 +120,11 @@ 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::gapi::own::Mat*>(): return GMetaArg(descr_of(*util::get<cv::gapi::own::Mat*>(argp)));
|
||||
case GRunArgP::index_of<cv::Scalar*>(): return GMetaArg(descr_of(*util::get<cv::Scalar*>(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::gapi::own::Scalar*>(): return GMetaArg(descr_of(*util::get<cv::gapi::own::Scalar*>(argp)));
|
||||
case GRunArgP::index_of<cv::detail::VectorRef>(): return GMetaArg(util::get<cv::detail::VectorRef>(argp).descr_of());
|
||||
default: util::throw_error(std::logic_error("Unsupported GRunArgP type"));
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include "opencv2/gapi/gscalar.hpp"
|
||||
#include "opencv2/gapi/own/convert.hpp"
|
||||
#include "api/gapi_priv.hpp" // GOrigin
|
||||
@@ -30,11 +32,6 @@ cv::GScalar::GScalar(cv::gapi::own::Scalar&& s)
|
||||
{
|
||||
}
|
||||
|
||||
cv::GScalar::GScalar(const cv::Scalar& s)
|
||||
: m_priv(new GOrigin(GShape::GSCALAR, cv::gimpl::ConstVal(to_own(s))))
|
||||
{
|
||||
}
|
||||
|
||||
cv::GScalar::GScalar(double v0)
|
||||
: m_priv(new GOrigin(GShape::GSCALAR, cv::gimpl::ConstVal(cv::gapi::own::Scalar(v0))))
|
||||
{
|
||||
@@ -55,10 +52,17 @@ cv::GScalarDesc cv::descr_of(const cv::gapi::own::Scalar &)
|
||||
return empty_scalar_desc();
|
||||
}
|
||||
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
cv::GScalar::GScalar(const cv::Scalar& s)
|
||||
: m_priv(new GOrigin(GShape::GSCALAR, cv::gimpl::ConstVal(to_own(s))))
|
||||
{
|
||||
}
|
||||
|
||||
cv::GScalarDesc cv::descr_of(const cv::Scalar& s)
|
||||
{
|
||||
return cv::descr_of(to_own(s));
|
||||
}
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
namespace cv {
|
||||
std::ostream& operator<<(std::ostream& os, const cv::GScalarDesc &)
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include "opencv2/gapi/gcall.hpp"
|
||||
#include "opencv2/gapi/gscalar.hpp"
|
||||
#include "opencv2/gapi/gkernel.hpp"
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include "opencv2/gapi/gscalar.hpp"
|
||||
#include "opencv2/gapi/gcall.hpp"
|
||||
#include "opencv2/gapi/gkernel.hpp"
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include "opencv2/gapi/imgproc.hpp"
|
||||
#include "opencv2/gapi/core.hpp"
|
||||
#include "opencv2/gapi/gscalar.hpp"
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include "opencv2/gapi/gcompoundkernel.hpp" // compound::backend()
|
||||
|
||||
#include "api/gbackend_priv.hpp"
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <ade/util/zip_range.hpp> // util::indexed
|
||||
#include "opencv2/gapi/gcompoundkernel.hpp"
|
||||
#include "compiler/gobjref.hpp"
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <functional>
|
||||
#include <unordered_set>
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "opencv2/gapi/cpu/gcpukernel.hpp"
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <iomanip> // std::fixed, std::setprecision
|
||||
@@ -191,7 +193,7 @@ static int calcGcd (int n1, int n2)
|
||||
|
||||
static int calcResizeWindow(int inH, int outH)
|
||||
{
|
||||
CV_Assert(inH >= outH);
|
||||
GAPI_Assert(inH >= outH);
|
||||
auto gcd = calcGcd(inH, outH);
|
||||
int inPeriodH = inH/gcd;
|
||||
int outPeriodH = outH/gcd;
|
||||
@@ -222,7 +224,7 @@ static int maxReadWindow(const cv::GFluidKernel& k, int inH, int outH)
|
||||
return (inH == 1) ? 1 : 2;
|
||||
}
|
||||
} break;
|
||||
default: CV_Assert(false); return 0;
|
||||
default: GAPI_Assert(false); return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,7 +235,7 @@ static int borderSize(const cv::GFluidKernel& k)
|
||||
case cv::GFluidKernel::Kind::Filter: return (k.m_window - 1) / 2; break;
|
||||
// Resize never reads from border pixels
|
||||
case cv::GFluidKernel::Kind::Resize: return 0; break;
|
||||
default: CV_Assert(false); return 0;
|
||||
default: GAPI_Assert(false); return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,7 +263,7 @@ double inCoordUpscale(int outCoord, double ratio)
|
||||
int upscaleWindowStart(int outCoord, double ratio)
|
||||
{
|
||||
int start = static_cast<int>(inCoordUpscale(outCoord, ratio));
|
||||
CV_Assert(start >= 0);
|
||||
GAPI_DbgAssert(start >= 0);
|
||||
return start;
|
||||
}
|
||||
|
||||
@@ -331,7 +333,7 @@ int cv::gimpl::FluidUpscaleAgent::linesRead() const
|
||||
bool cv::gimpl::FluidAgent::canRead() const
|
||||
{
|
||||
// An agent can work if every input buffer have enough data to start
|
||||
for (auto in_view : in_views)
|
||||
for (const auto& in_view : in_views)
|
||||
{
|
||||
if (in_view)
|
||||
{
|
||||
@@ -346,7 +348,7 @@ bool cv::gimpl::FluidAgent::canWrite() const
|
||||
{
|
||||
// An agent can work if there is space to write in its output
|
||||
// allocated buffers
|
||||
CV_Assert(!out_buffers.empty());
|
||||
GAPI_DbgAssert(!out_buffers.empty());
|
||||
auto out_begin = out_buffers.begin();
|
||||
auto out_end = out_buffers.end();
|
||||
if (k.m_scratch) out_end--;
|
||||
@@ -367,15 +369,15 @@ bool cv::gimpl::FluidAgent::canWork() const
|
||||
|
||||
void cv::gimpl::FluidAgent::doWork()
|
||||
{
|
||||
GAPI_Assert(m_outputLines > m_producedLines);
|
||||
for (auto in_view : in_views)
|
||||
GAPI_DbgAssert(m_outputLines > m_producedLines);
|
||||
for (auto& in_view : in_views)
|
||||
{
|
||||
if (in_view) in_view.priv().prepareToRead();
|
||||
}
|
||||
|
||||
k.m_f(in_args, out_buffers);
|
||||
|
||||
for (auto in_view : in_views)
|
||||
for (auto& in_view : in_views)
|
||||
{
|
||||
if (in_view) in_view.priv().readDone(linesRead(), nextWindow());
|
||||
}
|
||||
@@ -462,7 +464,7 @@ cv::gimpl::GFluidExecutable::GFluidExecutable(const ade::Graph &g,
|
||||
m_agents.emplace_back(new FluidUpscaleAgent(m_g, nh));
|
||||
}
|
||||
} break;
|
||||
default: CV_Assert(false);
|
||||
default: GAPI_Assert(false);
|
||||
}
|
||||
// NB.: in_buffer_ids size is equal to Arguments size, not Edges size!!!
|
||||
m_agents.back()->in_buffer_ids.resize(m_gm.metadata(nh).get<Op>().args.size(), -1);
|
||||
@@ -517,7 +519,7 @@ cv::gimpl::GFluidExecutable::GFluidExecutable(const ade::Graph &g,
|
||||
|
||||
if (proto.outputs.size() != m_outputRois.size())
|
||||
{
|
||||
CV_Assert(m_outputRois.size() == 0);
|
||||
GAPI_Assert(m_outputRois.size() == 0);
|
||||
m_outputRois.resize(proto.outputs.size());
|
||||
}
|
||||
|
||||
@@ -623,7 +625,7 @@ cv::gimpl::GFluidExecutable::GFluidExecutable(const ade::Graph &g,
|
||||
{
|
||||
case GFluidKernel::Kind::Filter: resized = produced; break;
|
||||
case GFluidKernel::Kind::Resize: resized = adjResizeRoi(produced, in_meta.size, meta.size); break;
|
||||
default: CV_Assert(false);
|
||||
default: GAPI_Assert(false);
|
||||
}
|
||||
|
||||
int readStart = resized.y;
|
||||
@@ -773,7 +775,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(to_ocv(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::gapi::own::Mat>(arg), true); break;
|
||||
case GShape::GSCALAR: m_res.slot<cv::gapi::own::Scalar>()[rc.id] = util::get<cv::gapi::own::Scalar>(arg); break;
|
||||
default: util::throw_error(std::logic_error("Unsupported GShape type"));
|
||||
}
|
||||
@@ -790,7 +792,7 @@ void cv::gimpl::GFluidExecutable::bindOutArg(const cv::gimpl::RcDesc &rc, const
|
||||
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 ?");
|
||||
m_buffers[m_id_map.at(rc.id)].priv().bindTo(to_ocv(outMat), false);
|
||||
m_buffers[m_id_map.at(rc.id)].priv().bindTo(outMat, false);
|
||||
break;
|
||||
}
|
||||
default: util::throw_error(std::logic_error("Unsupported return GShape type"));
|
||||
@@ -839,7 +841,7 @@ void cv::gimpl::GFluidExecutable::run(std::vector<InObj> &&input_objs,
|
||||
for (auto scratch_i : m_scratch_users)
|
||||
{
|
||||
auto &agent = m_agents[scratch_i];
|
||||
GAPI_Assert(agent->k.m_scratch);
|
||||
GAPI_DbgAssert(agent->k.m_scratch);
|
||||
agent->k.m_rs(*agent->out_buffers.back());
|
||||
}
|
||||
|
||||
@@ -983,7 +985,7 @@ void GFluidBackendImpl::addBackendPasses(ade::ExecutionEngineSetupContext &ectx)
|
||||
}
|
||||
}
|
||||
|
||||
CV_Assert(in_hs.size() == 1 && out_ws.size() == 1 && out_hs.size() == 1);
|
||||
GAPI_Assert(in_hs.size() == 1 && out_ws.size() == 1 && out_hs.size() == 1);
|
||||
|
||||
auto in_h = *in_hs .cbegin();
|
||||
auto out_h = *out_hs.cbegin();
|
||||
|
||||
@@ -5,9 +5,12 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <iomanip> // hex, dec (debug)
|
||||
|
||||
#include "opencv2/gapi/own/convert.hpp"
|
||||
#include "opencv2/gapi/own/types.hpp"
|
||||
|
||||
#include "opencv2/gapi/fluid/gfluidbuffer.hpp"
|
||||
#include "backends/fluid/gfluidbuffer_priv.hpp"
|
||||
@@ -18,6 +21,11 @@
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
|
||||
//namespace own {
|
||||
// class Mat;
|
||||
// CV_EXPORTS cv::GMatDesc descr_of(const Mat &mat);
|
||||
//}//own
|
||||
|
||||
namespace fluid {
|
||||
bool operator == (const fluid::Border& b1, const fluid::Border& b2)
|
||||
{
|
||||
@@ -79,7 +87,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::gapi::own::Scalar borderValue, cv::Mat& mat)
|
||||
void fillBorderConstant(int borderSize, cv::gapi::own::Scalar borderValue, cv::gapi::own::Mat& mat)
|
||||
{
|
||||
// cv::Scalar can contain maximum 4 chan
|
||||
GAPI_Assert(mat.channels() > 0 && mat.channels() <= 4);
|
||||
@@ -91,7 +99,7 @@ void fillBorderConstant(int borderSize, cv::gapi::own::Scalar borderValue, cv::M
|
||||
case CV_16S: return &fillConstBorderRow< int16_t>; break;
|
||||
case CV_16U: return &fillConstBorderRow<uint16_t>; break;
|
||||
case CV_32F: return &fillConstBorderRow< float >; break;
|
||||
default: CV_Assert(false); return &fillConstBorderRow<uint8_t>;
|
||||
default: GAPI_Assert(false); return &fillConstBorderRow<uint8_t>;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -105,7 +113,7 @@ void fillBorderConstant(int borderSize, cv::gapi::own::Scalar borderValue, cv::M
|
||||
|
||||
fluid::BorderHandler::BorderHandler(int border_size)
|
||||
{
|
||||
CV_Assert(border_size > 0);
|
||||
GAPI_Assert(border_size > 0);
|
||||
m_border_size = border_size;
|
||||
}
|
||||
|
||||
@@ -122,7 +130,7 @@ fluid::BorderHandlerT<BorderType>::BorderHandlerT(int border_size, int data_type
|
||||
case CV_16S: return &fillBorderReplicateRow< int16_t>; break;
|
||||
case CV_16U: return &fillBorderReplicateRow<uint16_t>; break;
|
||||
case CV_32F: return &fillBorderReplicateRow< float >; break;
|
||||
default: CV_Assert(!"Unsupported data type"); return &fillBorderReplicateRow<uint8_t>;
|
||||
default: GAPI_Assert(!"Unsupported data type"); return &fillBorderReplicateRow<uint8_t>;
|
||||
}
|
||||
}
|
||||
else if (border == cv::BORDER_REFLECT_101)
|
||||
@@ -133,12 +141,12 @@ fluid::BorderHandlerT<BorderType>::BorderHandlerT(int border_size, int data_type
|
||||
case CV_16S: return &fillBorderReflectRow< int16_t>; break;
|
||||
case CV_16U: return &fillBorderReflectRow<uint16_t>; break;
|
||||
case CV_32F: return &fillBorderReflectRow< float >; break;
|
||||
default: CV_Assert(!"Unsupported data type"); return &fillBorderReflectRow<uint8_t>;
|
||||
default: GAPI_Assert(!"Unsupported data type"); return &fillBorderReflectRow<uint8_t>;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_Assert(!"Unsupported border type");
|
||||
GAPI_Assert(!"Unsupported border type");
|
||||
return &fillBorderReflectRow<uint8_t>;
|
||||
}
|
||||
};
|
||||
@@ -171,7 +179,7 @@ fluid::BorderHandlerT<cv::BORDER_CONSTANT>::BorderHandlerT(int border_size, cv::
|
||||
: BorderHandler(border_size), m_border_value(border_value)
|
||||
{
|
||||
m_const_border.create(1, desc_width + 2*m_border_size, data_type);
|
||||
m_const_border = cv::gapi::own::to_ocv(border_value);
|
||||
m_const_border = border_value;
|
||||
}
|
||||
|
||||
const uint8_t* fluid::BorderHandlerT<cv::BORDER_CONSTANT>::inLineB(int /*log_idx*/, const BufferStorageWithBorder& /*data*/, int /*desc_height*/) const
|
||||
@@ -218,7 +226,7 @@ void fluid::BufferStorageWithBorder::create(int capacity, int desc_width, int dt
|
||||
case cv::BORDER_REFLECT_101:
|
||||
m_borderHandler.reset(new BorderHandlerT<cv::BORDER_REFLECT_101>(border_size, dtype)); break;
|
||||
default:
|
||||
CV_Assert(false);
|
||||
GAPI_Assert(false);
|
||||
}
|
||||
|
||||
m_borderHandler->fillCompileTimeBorder(*this);
|
||||
@@ -249,11 +257,10 @@ const uint8_t* fluid::BufferStorageWithoutBorder::inLineB(int log_idx, int /*des
|
||||
return ptr(log_idx);
|
||||
}
|
||||
|
||||
static void copyWithoutBorder(const cv::Mat& src, int src_border_size, cv::Mat& dst, int dst_border_size, int startSrcLine, int startDstLine, int lpi)
|
||||
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)
|
||||
{
|
||||
// FIXME use cv::gapi::own::Rect when implement cv::gapi::own::Mat
|
||||
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});
|
||||
auto subSrc = src(cv::gapi::own::Rect{src_border_size, startSrcLine, src.cols - 2*src_border_size, lpi});
|
||||
auto subDst = dst(cv::gapi::own::Rect{dst_border_size, startDstLine, dst.cols - 2*dst_border_size, lpi});
|
||||
|
||||
subSrc.copyTo(subDst);
|
||||
}
|
||||
@@ -337,8 +344,8 @@ std::unique_ptr<fluid::BufferStorage> createStorage(int capacity, int desc_width
|
||||
return std::move(storage);
|
||||
}
|
||||
|
||||
std::unique_ptr<BufferStorage> createStorage(const cv::Mat& data, cv::gapi::own::Rect roi);
|
||||
std::unique_ptr<BufferStorage> createStorage(const cv::Mat& data, cv::gapi::own::Rect roi)
|
||||
std::unique_ptr<BufferStorage> createStorage(const cv::gapi::own::Mat& data, cv::gapi::own::Rect roi);
|
||||
std::unique_ptr<BufferStorage> createStorage(const cv::gapi::own::Mat& data, cv::gapi::own::Rect roi)
|
||||
{
|
||||
std::unique_ptr<BufferStorageWithoutBorder> storage(new BufferStorageWithoutBorder);
|
||||
storage->attach(data, roi);
|
||||
@@ -359,7 +366,7 @@ void fluid::View::Priv::reset(int linesForFirstIteration)
|
||||
|
||||
void fluid::View::Priv::readDone(int linesRead, int linesForNextIteration)
|
||||
{
|
||||
CV_DbgAssert(m_p);
|
||||
GAPI_DbgAssert(m_p);
|
||||
m_read_caret += linesRead;
|
||||
m_read_caret %= m_p->meta().size.height;
|
||||
m_lines_next_iter = linesForNextIteration;
|
||||
@@ -380,7 +387,7 @@ bool fluid::View::Priv::ready() const
|
||||
|
||||
fluid::ViewPrivWithoutOwnBorder::ViewPrivWithoutOwnBorder(const Buffer *parent, int borderSize)
|
||||
{
|
||||
CV_Assert(parent);
|
||||
GAPI_Assert(parent);
|
||||
m_p = parent;
|
||||
m_border_size = borderSize;
|
||||
}
|
||||
@@ -391,8 +398,8 @@ const uint8_t* fluid::ViewPrivWithoutOwnBorder::InLineB(int index) const
|
||||
|
||||
const auto &p_priv = m_p->priv();
|
||||
|
||||
CV_Assert( index >= -m_border_size
|
||||
&& index < -m_border_size + m_lines_next_iter);
|
||||
GAPI_DbgAssert(index >= -m_border_size
|
||||
&& index < -m_border_size + m_lines_next_iter);
|
||||
|
||||
const int log_idx = m_read_caret + index;
|
||||
|
||||
@@ -439,9 +446,8 @@ std::size_t fluid::ViewPrivWithOwnBorder::size() const
|
||||
const uint8_t* fluid::ViewPrivWithOwnBorder::InLineB(int index) const
|
||||
{
|
||||
GAPI_DbgAssert(m_p);
|
||||
|
||||
GAPI_Assert( index >= -m_border_size
|
||||
&& index < -m_border_size + m_lines_next_iter);
|
||||
GAPI_DbgAssert(index >= -m_border_size
|
||||
&& index < -m_border_size + m_lines_next_iter);
|
||||
|
||||
const int log_idx = m_read_caret + index;
|
||||
|
||||
@@ -473,7 +479,7 @@ int fluid::View::y() const
|
||||
return m_priv->m_read_caret - m_priv->m_border_size;
|
||||
}
|
||||
|
||||
cv::GMatDesc fluid::View::meta() const
|
||||
const GMatDesc& fluid::View::meta() const
|
||||
{
|
||||
// FIXME: cover with test!
|
||||
return m_priv->m_p->meta();
|
||||
@@ -522,16 +528,8 @@ void fluid::Buffer::Priv::allocate(BorderOpt border)
|
||||
|
||||
// Init physical buffer
|
||||
|
||||
// FIXME? combine with skew?
|
||||
auto maxRead = m_line_consumption + m_skew;
|
||||
auto maxWritten = m_writer_lpi;
|
||||
|
||||
auto max = std::max(maxRead, maxWritten);
|
||||
auto min = std::min(maxRead, maxWritten);
|
||||
|
||||
// FIXME:
|
||||
// Fix the deadlock (completely)!!!
|
||||
auto data_height = static_cast<int>(std::ceil((double)max / min) * min);
|
||||
// FIXME? combine line_consumption with skew?
|
||||
auto data_height = std::max(m_line_consumption, m_skew) + m_writer_lpi - 1;
|
||||
|
||||
m_storage = createStorage(data_height,
|
||||
m_desc.size.width,
|
||||
@@ -543,12 +541,12 @@ void fluid::Buffer::Priv::allocate(BorderOpt border)
|
||||
m_write_caret = 0;
|
||||
}
|
||||
|
||||
void fluid::Buffer::Priv::bindTo(const cv::Mat &data, bool is_input)
|
||||
void fluid::Buffer::Priv::bindTo(const cv::gapi::own::Mat &data, bool is_input)
|
||||
{
|
||||
// FIXME: move all these fields into a separate structure
|
||||
GAPI_Assert(m_skew == 0);
|
||||
GAPI_Assert(m_desc == cv::descr_of(data));
|
||||
if ( is_input) CV_Assert(m_writer_lpi == 1);
|
||||
GAPI_Assert(m_desc == descr_of(data));
|
||||
if ( is_input) GAPI_Assert(m_writer_lpi == 1);
|
||||
|
||||
m_storage = createStorage(data, m_roi);
|
||||
|
||||
@@ -617,7 +615,7 @@ int fluid::Buffer::Priv::linesReady() const
|
||||
|
||||
uint8_t* fluid::Buffer::Priv::OutLineB(int index)
|
||||
{
|
||||
GAPI_Assert(index >= 0 && index < m_writer_lpi);
|
||||
GAPI_DbgAssert(index >= 0 && index < m_writer_lpi);
|
||||
|
||||
return m_storage->ptr(m_write_caret + index);
|
||||
}
|
||||
@@ -658,7 +656,7 @@ fluid::Buffer::Buffer(const cv::GMatDesc &desc,
|
||||
m_priv->allocate(border);
|
||||
}
|
||||
|
||||
fluid::Buffer::Buffer(const cv::Mat &data, bool is_input)
|
||||
fluid::Buffer::Buffer(const cv::gapi::own::Mat &data, bool is_input)
|
||||
: m_priv(new Priv())
|
||||
{
|
||||
int lineConsumption = 1;
|
||||
@@ -688,7 +686,7 @@ int fluid::Buffer::lpi() const
|
||||
return m_priv->lpi();
|
||||
}
|
||||
|
||||
cv::GMatDesc fluid::Buffer::meta() const
|
||||
const GMatDesc& fluid::Buffer::meta() const
|
||||
{
|
||||
return m_priv->meta();
|
||||
}
|
||||
|
||||
@@ -12,6 +12,12 @@
|
||||
|
||||
#include "opencv2/gapi/fluid/gfluidbuffer.hpp"
|
||||
#include "opencv2/gapi/own/convert.hpp" // cv::gapi::own::to_ocv
|
||||
#include "opencv2/gapi/own/exports.hpp" // GAPI_EXPORTS
|
||||
|
||||
namespace gapi { namespace own {
|
||||
class Mat;
|
||||
GAPI_EXPORTS cv::GMatDesc descr_of(const Mat &mat);
|
||||
}}//gapi::own
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
@@ -30,13 +36,13 @@ public:
|
||||
virtual const uint8_t* inLineB(int log_idx, const BufferStorageWithBorder &data, int desc_height) const = 0;
|
||||
|
||||
// Fills border pixels after buffer allocation (if possible (for const border))
|
||||
virtual void fillCompileTimeBorder(BufferStorageWithBorder &) const { /* nothing */ }
|
||||
inline virtual void fillCompileTimeBorder(BufferStorageWithBorder &) const { /* nothing */ }
|
||||
|
||||
// Fills required border lines
|
||||
virtual void updateBorderPixels(BufferStorageWithBorder& /*data*/, int /*startLine*/, int /*lpi*/) const { /* nothing */ }
|
||||
inline virtual void updateBorderPixels(BufferStorageWithBorder& /*data*/, int /*startLine*/, int /*lpi*/) const { /* nothing */ }
|
||||
|
||||
inline int borderSize() const { return m_border_size; }
|
||||
virtual std::size_t size() const { return 0; }
|
||||
inline virtual std::size_t size() const { return 0; }
|
||||
};
|
||||
|
||||
template<int BorderType>
|
||||
@@ -53,7 +59,7 @@ template<>
|
||||
class BorderHandlerT<cv::BORDER_CONSTANT> : public BorderHandler
|
||||
{
|
||||
cv::gapi::own::Scalar m_border_value;
|
||||
cv::Mat m_const_border;
|
||||
cv::gapi::own::Mat m_const_border;
|
||||
|
||||
public:
|
||||
BorderHandlerT(int border_size, cv::gapi::own::Scalar border_value, int data_type, int desc_width);
|
||||
@@ -65,7 +71,7 @@ public:
|
||||
class BufferStorage
|
||||
{
|
||||
protected:
|
||||
cv::Mat m_data;
|
||||
cv::gapi::own::Mat m_data;
|
||||
|
||||
public:
|
||||
virtual void copyTo(BufferStorageWithBorder &dst, int startLine, int nLines) const = 0;
|
||||
@@ -77,8 +83,8 @@ public:
|
||||
|
||||
inline bool empty() const { return m_data.empty(); }
|
||||
|
||||
inline const cv::Mat& data() const { return m_data; }
|
||||
inline cv::Mat& data() { return m_data; }
|
||||
inline const cv::gapi::own::Mat& data() const { return m_data; }
|
||||
inline cv::gapi::own::Mat& data() { return m_data; }
|
||||
|
||||
inline int rows() const { return m_data.rows; }
|
||||
inline int cols() const { return m_data.cols; }
|
||||
@@ -114,9 +120,9 @@ public:
|
||||
return m_data.ptr(physIdx(idx), 0);
|
||||
}
|
||||
|
||||
inline void attach(const cv::Mat& _data, const cv::gapi::own::Rect& _roi)
|
||||
inline void attach(const cv::gapi::own::Mat& _data, cv::gapi::own::Rect _roi)
|
||||
{
|
||||
m_data = _data(cv::gapi::own::to_ocv(_roi));
|
||||
m_data = _data(_roi);
|
||||
m_roi = _roi;
|
||||
m_is_virtual = false;
|
||||
}
|
||||
@@ -198,9 +204,9 @@ public:
|
||||
// API used by actors/backend
|
||||
ViewPrivWithoutOwnBorder(const Buffer *p, int borderSize);
|
||||
|
||||
virtual void prepareToRead() override { /* nothing */ }
|
||||
inline virtual void prepareToRead() override { /* nothing */ }
|
||||
|
||||
virtual std::size_t size() const override { return 0; }
|
||||
inline virtual std::size_t size() const override { return 0; }
|
||||
|
||||
// API used (indirectly) by user code
|
||||
virtual const uint8_t* InLineB(int index) const override;
|
||||
@@ -264,11 +270,11 @@ public:
|
||||
cv::gapi::own::Rect roi);
|
||||
|
||||
void allocate(BorderOpt border);
|
||||
void bindTo(const cv::Mat &data, bool is_input);
|
||||
void bindTo(const cv::gapi::own::Mat &data, bool is_input);
|
||||
|
||||
void addView(const View& view) { m_views.push_back(view); }
|
||||
inline void addView(const View& view) { m_views.push_back(view); }
|
||||
|
||||
const GMatDesc meta() const { return m_desc; }
|
||||
inline const GMatDesc& meta() const { return m_desc; }
|
||||
|
||||
bool full() const;
|
||||
void writeDone();
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
//
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include "opencv2/gapi/own/assert.hpp"
|
||||
#include "opencv2/core/traits.hpp"
|
||||
@@ -2119,3 +2122,5 @@ cv::gapi::GKernelPackage cv::gapi::core::fluid::kernels()
|
||||
#endif
|
||||
>();
|
||||
}
|
||||
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
//
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include "opencv2/gapi/own/assert.hpp"
|
||||
#include "opencv2/core/traits.hpp"
|
||||
@@ -1323,3 +1326,5 @@ cv::gapi::GKernelPackage cv::gapi::imgproc::fluid::kernels()
|
||||
#endif
|
||||
>();
|
||||
}
|
||||
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
@@ -11,78 +11,17 @@
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
#include <opencv2/gapi/util/compiler_hints.hpp> //UNUSED
|
||||
#include <opencv2/gapi/own/saturate.hpp>
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
namespace fluid {
|
||||
|
||||
//-----------------------------
|
||||
//
|
||||
// Numeric cast with saturation
|
||||
//
|
||||
//-----------------------------
|
||||
|
||||
template<typename DST, typename SRC>
|
||||
static inline DST saturate(SRC x)
|
||||
{
|
||||
// only integral types please!
|
||||
GAPI_DbgAssert(std::is_integral<DST>::value &&
|
||||
std::is_integral<SRC>::value);
|
||||
|
||||
if (std::is_same<DST, SRC>::value)
|
||||
return static_cast<DST>(x);
|
||||
|
||||
if (sizeof(DST) > sizeof(SRC))
|
||||
return static_cast<DST>(x);
|
||||
|
||||
// compiler must recognize this saturation,
|
||||
// so compile saturate<s16>(a + b) with adds
|
||||
// instruction (e.g.: _mm_adds_epi16 if x86)
|
||||
return x < std::numeric_limits<DST>::min()?
|
||||
std::numeric_limits<DST>::min():
|
||||
x > std::numeric_limits<DST>::max()?
|
||||
std::numeric_limits<DST>::max():
|
||||
static_cast<DST>(x);
|
||||
}
|
||||
|
||||
// Note, that OpenCV rounds differently:
|
||||
// - like std::round() for add, subtract
|
||||
// - like std::rint() for multiply, divide
|
||||
template<typename DST, typename SRC, typename R>
|
||||
static inline DST saturate(SRC x, R round)
|
||||
{
|
||||
if (std::is_floating_point<DST>::value)
|
||||
{
|
||||
return static_cast<DST>(x);
|
||||
}
|
||||
else if (std::is_integral<SRC>::value)
|
||||
{
|
||||
GAPI_DbgAssert(std::is_integral<DST>::value &&
|
||||
std::is_integral<SRC>::value);
|
||||
return saturate<DST>(x);
|
||||
}
|
||||
else
|
||||
{
|
||||
GAPI_DbgAssert(std::is_integral<DST>::value &&
|
||||
std::is_floating_point<SRC>::value);
|
||||
#ifdef _WIN32
|
||||
// Suppress warning about convering x to floating-point
|
||||
// Note that x is already floating-point at this point
|
||||
#pragma warning(disable: 4244)
|
||||
#endif
|
||||
int ix = static_cast<int>(round(x));
|
||||
#ifdef _WIN32
|
||||
#pragma warning(default: 4244)
|
||||
#endif
|
||||
return saturate<DST>(ix);
|
||||
}
|
||||
}
|
||||
|
||||
// explicit suffix 'd' for double type
|
||||
static inline double ceild(double x) { return std::ceil(x); }
|
||||
static inline double floord(double x) { return std::floor(x); }
|
||||
static inline double roundd(double x) { return std::round(x); }
|
||||
static inline double rintd(double x) { return std::rint(x); }
|
||||
using cv::gapi::own::saturate;
|
||||
using cv::gapi::own::ceild;
|
||||
using cv::gapi::own::floord;
|
||||
using cv::gapi::own::roundd;
|
||||
using cv::gapi::own::rintd;
|
||||
|
||||
//--------------------------------
|
||||
//
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <ade/graph.hpp>
|
||||
|
||||
#include "opencv2/gapi/gproto.hpp" // descr_of
|
||||
@@ -80,6 +82,7 @@ void cv::GCompiled::operator() (GRunArgs &&ins, GRunArgsP &&outs)
|
||||
m_priv->run(cv::gimpl::GRuntimeArgs{std::move(ins),std::move(outs)});
|
||||
}
|
||||
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
void cv::GCompiled::operator ()(cv::Mat in, cv::Mat &out)
|
||||
{
|
||||
(*this)(cv::gin(in), cv::gout(out));
|
||||
@@ -113,6 +116,8 @@ void cv::GCompiled::operator ()(const std::vector<cv::Mat> &ins,
|
||||
|
||||
(*this)(std::move(call_ins), std::move(call_outs));
|
||||
}
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
|
||||
const cv::GMetaArgs& cv::GCompiled::metas() const
|
||||
{
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <stack>
|
||||
#include <unordered_map>
|
||||
@@ -32,22 +34,28 @@
|
||||
#include "backends/common/gbackend.hpp"
|
||||
|
||||
// <FIXME:>
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
#include "opencv2/gapi/cpu/core.hpp" // Also directly refer to Core
|
||||
#include "opencv2/gapi/cpu/imgproc.hpp" // ...and Imgproc kernel implementations
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
// </FIXME:>
|
||||
|
||||
#include "opencv2/gapi/gcompoundkernel.hpp" // compound::backend()
|
||||
|
||||
#include "opencv2/core/cvdef.h"
|
||||
#include "logger.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
cv::gapi::GKernelPackage getKernelPackage(cv::GCompileArgs &args)
|
||||
{
|
||||
static auto ocv_pkg = combine(cv::gapi::core::cpu::kernels(),
|
||||
cv::gapi::imgproc::cpu::kernels(),
|
||||
cv::unite_policy::KEEP);
|
||||
static auto ocv_pkg =
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
combine(cv::gapi::core::cpu::kernels(),
|
||||
cv::gapi::imgproc::cpu::kernels(),
|
||||
cv::unite_policy::KEEP);
|
||||
#else
|
||||
cv::gapi::GKernelPackage();
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
auto user_pkg = cv::gimpl::getCompileArg<cv::gapi::GKernelPackage>(args);
|
||||
return combine(ocv_pkg, user_pkg.value_or(cv::gapi::GKernelPackage{}), cv::unite_policy::REPLACE);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <sstream> // used in GModel::log
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
// - Dmitry
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <utility> // tuple
|
||||
#include <stack> // stack
|
||||
#include <vector> // vector
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <iostream> // cout
|
||||
#include <sstream> // stringstream
|
||||
#include <fstream> // ofstream
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <list> // list
|
||||
#include <iomanip> // setw, etc
|
||||
@@ -16,7 +18,6 @@
|
||||
#include <ade/util/chain_range.hpp> // chain
|
||||
|
||||
#include "opencv2/gapi/util/optional.hpp" // util::optional
|
||||
#include "opencv2/core/cvdef.h"
|
||||
#include "logger.hpp" // GAPI_LOG
|
||||
|
||||
#include "compiler/gmodel.hpp"
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <algorithm> // copy
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <stack>
|
||||
#include <ade/util/chain_range.hpp>
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <ade/util/zip_range.hpp> // util::indexed
|
||||
#include <ade/graph.hpp>
|
||||
#include <ade/passes/check_cycles.hpp>
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <ade/util/zip_range.hpp> // util::indexed
|
||||
#include <ade/graph.hpp>
|
||||
#include <ade/passes/check_cycles.hpp>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include <ade/graph.hpp>
|
||||
|
||||
#include "opencv2/core/base.hpp"
|
||||
#include "opencv2/gapi/own/assert.hpp"
|
||||
|
||||
enum class Direction: int {Invalid, In, Out};
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace Change
|
||||
{
|
||||
case Direction::In: g.link(m_sibling, m_node); break;
|
||||
case Direction::Out: g.link(m_node, m_sibling); break;
|
||||
default: CV_Assert(false);
|
||||
default: GAPI_Assert(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -104,8 +104,8 @@ namespace Change
|
||||
{
|
||||
// According to the semantic, node should be disconnected
|
||||
// manually before it is dropped
|
||||
CV_Assert(m_node->inEdges().size() == 0);
|
||||
CV_Assert(m_node->outEdges().size() == 0);
|
||||
GAPI_Assert(m_node->inEdges().size() == 0);
|
||||
GAPI_Assert(m_node->outEdges().size() == 0);
|
||||
}
|
||||
|
||||
virtual void commit(ade::Graph &g) override
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <ade/util/zip_range.hpp>
|
||||
|
||||
#include "opencv2/core/types.hpp"
|
||||
#include "opencv2/gapi/opencv_includes.hpp"
|
||||
#include "executor/gexecutor.hpp"
|
||||
|
||||
cv::gimpl::GExecutor::GExecutor(std::unique_ptr<ade::Graph> &&g_model)
|
||||
@@ -150,8 +152,21 @@ void cv::gimpl::GExecutor::run(cv::gimpl::GRuntimeArgs &&args)
|
||||
using cv::util::get;
|
||||
const auto desc = get<cv::GMatDesc>(d.meta);
|
||||
const auto type = CV_MAKETYPE(desc.depth, desc.chan);
|
||||
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
// Building as part of OpenCV - follow OpenCV behavior
|
||||
// if output buffer is not enough to hold the result, reallocate it
|
||||
auto& out_mat = *get<cv::Mat*>(args.outObjs.at(index));
|
||||
out_mat.create(cv::gapi::own::to_ocv(desc.size), type);
|
||||
#else
|
||||
// Building standalone - output buffer should always exist,
|
||||
// and _exact_ match our inferred metadata
|
||||
auto& out_mat = *get<cv::gapi::own::Mat*>(args.outObjs.at(index));
|
||||
GAPI_Assert( out_mat.type() == type
|
||||
&& out_mat.data != nullptr
|
||||
&& out_mat.rows == desc.size.height
|
||||
&& out_mat.cols == desc.size.width)
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
}
|
||||
}
|
||||
// Update storage with user-passed objects
|
||||
|
||||
@@ -8,17 +8,15 @@
|
||||
#ifndef __OPENCV_GAPI_LOGGER_HPP__
|
||||
#define __OPENCV_GAPI_LOGGER_HPP__
|
||||
|
||||
#if 1
|
||||
#include "opencv2/core/utils/logger.hpp"
|
||||
|
||||
#define GAPI_LOG_INFO(tag, ...) CV_LOG_INFO(tag, __VA_ARGS__)
|
||||
#define GAPI_LOG_WARNING(tag, ...) CV_LOG_WARNING(tag, __VA_ARGS__)
|
||||
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
# include "opencv2/core/cvdef.h"
|
||||
# include "opencv2/core/utils/logger.hpp"
|
||||
# define GAPI_LOG_INFO(tag, ...) CV_LOG_INFO(tag, __VA_ARGS__)
|
||||
# define GAPI_LOG_WARNING(tag, ...) CV_LOG_WARNING(tag, __VA_ARGS__)
|
||||
#else
|
||||
#define GAPI_LOG_INFO(tag, ...)
|
||||
#define GAPI_LOG_WARNING(tag, ...)
|
||||
|
||||
#endif
|
||||
# define GAPI_LOG_INFO(tag, ...)
|
||||
# define GAPI_LOG_WARNING(tag, ...)
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
|
||||
#endif // __OPENCV_GAPI_LOGGER_HPP__
|
||||
|
||||
@@ -8,12 +8,14 @@
|
||||
#ifndef __OPENCV_GAPI_PRECOMP_HPP__
|
||||
#define __OPENCV_GAPI_PRECOMP_HPP__
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
# include "opencv2/core.hpp"
|
||||
# include "opencv2/imgproc.hpp"
|
||||
# include "opencv2/gapi/core.hpp"
|
||||
# include "opencv2/gapi/imgproc.hpp"
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
#include "opencv2/gapi.hpp"
|
||||
#include "opencv2/gapi/gkernel.hpp"
|
||||
#include "opencv2/gapi/core.hpp"
|
||||
#include "opencv2/gapi/imgproc.hpp"
|
||||
|
||||
#endif // __OPENCV_GAPI_PRECOMP_HPP__
|
||||
|
||||
Reference in New Issue
Block a user