mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +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,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;
|
||||
|
||||
//--------------------------------
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user