mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 11:10:21 +08:00
Merge pull request #16745 from Volskig:mp/ocv-gapi-standalone-size
G-API: Unification of own:: structures with cv:: (Size, Point, Rect) * deowned Size Rect Point * Deownded Size Rect Point * With Scalar
This commit is contained in:
parent
557ac3dbaf
commit
277f0d270f
@ -17,7 +17,6 @@
|
||||
#include <opencv2/gapi/gcommon.hpp>
|
||||
#include <opencv2/gapi/gkernel.hpp>
|
||||
#include <opencv2/gapi/garg.hpp>
|
||||
#include <opencv2/gapi/own/types.hpp>
|
||||
|
||||
#include <opencv2/gapi/fluid/gfluidbuffer.hpp>
|
||||
|
||||
@ -109,7 +108,7 @@ public:
|
||||
*/
|
||||
struct GFluidOutputRois
|
||||
{
|
||||
std::vector<cv::gapi::own::Rect> rois;
|
||||
std::vector<cv::Rect> rois;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -14,8 +14,6 @@
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
#include <opencv2/gapi/gcommon.hpp> // GShape
|
||||
|
||||
#include <opencv2/gapi/own/types.hpp> // cv::gapi::own::Size
|
||||
#include <opencv2/gapi/own/convert.hpp> // to_own
|
||||
#include <opencv2/gapi/own/assert.hpp>
|
||||
|
||||
// TODO GAPI_EXPORTS or so
|
||||
@ -82,11 +80,11 @@ struct GAPI_EXPORTS GMatDesc
|
||||
// FIXME: Default initializers in C++14
|
||||
int depth;
|
||||
int chan;
|
||||
cv::gapi::own::Size size; // NB.: no multi-dimensional cases covered yet
|
||||
cv::Size size; // NB.: no multi-dimensional cases covered yet
|
||||
bool planar;
|
||||
std::vector<int> dims; // FIXME: Maybe it's real questionable to have it here
|
||||
|
||||
GMatDesc(int d, int c, cv::gapi::own::Size s, bool p = false)
|
||||
GMatDesc(int d, int c, cv::Size s, bool p = false)
|
||||
: depth(d), chan(c), size(s), planar(p) {}
|
||||
|
||||
GMatDesc(int d, const std::vector<int> &dd)
|
||||
@ -122,23 +120,13 @@ struct GAPI_EXPORTS GMatDesc
|
||||
// Meta combinator: return a new GMatDesc which differs in size by delta
|
||||
// (all other fields are taken unchanged from this GMatDesc)
|
||||
// FIXME: a better name?
|
||||
GMatDesc withSizeDelta(cv::gapi::own::Size delta) const
|
||||
GMatDesc withSizeDelta(cv::Size delta) const
|
||||
{
|
||||
GMatDesc desc(*this);
|
||||
desc.size += delta;
|
||||
return desc;
|
||||
}
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
GMatDesc withSizeDelta(cv::Size delta) const
|
||||
{
|
||||
return withSizeDelta(to_own(delta));
|
||||
}
|
||||
|
||||
GMatDesc withSize(cv::Size sz) const
|
||||
{
|
||||
return withSize(to_own(sz));
|
||||
}
|
||||
|
||||
bool canDescribe(const cv::Mat& mat) const;
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
// Meta combinator: return a new GMatDesc which differs in size by delta
|
||||
@ -147,10 +135,10 @@ struct GAPI_EXPORTS GMatDesc
|
||||
// This is an overload.
|
||||
GMatDesc withSizeDelta(int dx, int dy) const
|
||||
{
|
||||
return withSizeDelta(cv::gapi::own::Size{dx,dy});
|
||||
return withSizeDelta(cv::Size{dx,dy});
|
||||
}
|
||||
|
||||
GMatDesc withSize(cv::gapi::own::Size sz) const
|
||||
GMatDesc withSize(cv::Size sz) const
|
||||
{
|
||||
GMatDesc desc(*this);
|
||||
desc.size = sz;
|
||||
|
@ -11,7 +11,6 @@
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
#include <opencv2/gapi/own/types.hpp>
|
||||
#include <opencv2/gapi/own/mat.hpp>
|
||||
|
||||
namespace cv
|
||||
@ -33,12 +32,6 @@ namespace cv
|
||||
? cv::gapi::own::Mat{m.rows, m.cols, m.type(), m.data, m.step}
|
||||
: cv::gapi::own::Mat{to_own<int>(m.size), m.type(), m.data};
|
||||
};
|
||||
|
||||
inline cv::gapi::own::Size to_own (const Size& s) { return {s.width, s.height}; };
|
||||
|
||||
inline cv::gapi::own::Rect to_own (const Rect& r) { return {r.x, r.y, r.width, r.height}; };
|
||||
|
||||
|
||||
namespace gapi
|
||||
{
|
||||
namespace own
|
||||
@ -49,10 +42,6 @@ namespace own
|
||||
: cv::Mat{m.dims, m.type(), m.data};
|
||||
}
|
||||
cv::Mat to_ocv(Mat&&) = delete;
|
||||
inline cv::Size to_ocv (const Size& s) { return cv::Size(s.width, s.height); };
|
||||
|
||||
inline cv::Rect to_ocv (const Rect& r) { return cv::Rect(r.x, r.y, r.width, r.height); };
|
||||
|
||||
} // namespace own
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define OPENCV_GAPI_CV_DEFS_HPP
|
||||
|
||||
#if defined(GAPI_STANDALONE)
|
||||
#include <opencv2/gapi/own/types.hpp> // cv::gapi::own::Rect/Size/Point
|
||||
#include <opencv2/gapi/own/scalar.hpp> // cv::gapi::own::Scalar
|
||||
|
||||
// Simulate OpenCV definitions taken from various
|
||||
@ -139,6 +140,9 @@ enum InterpolationFlags{
|
||||
INTER_MAX = 7,
|
||||
};
|
||||
// replacement of cv's structures:
|
||||
using Rect = gapi::own::Rect;
|
||||
using Size = gapi::own::Size;
|
||||
using Point = gapi::own::Point;
|
||||
using Scalar = gapi::own::Scalar;
|
||||
} // namespace cv
|
||||
|
||||
|
@ -395,7 +395,7 @@ void createMat(const cv::GMatDesc &desc, cv::gapi::own::Mat& mat)
|
||||
if (desc.dims.empty())
|
||||
{
|
||||
const auto type = desc.planar ? desc.depth : CV_MAKETYPE(desc.depth, desc.chan);
|
||||
const auto size = desc.planar ? cv::gapi::own::Size{desc.size.width, desc.size.height*desc.chan}
|
||||
const auto size = desc.planar ? cv::Size{desc.size.width, desc.size.height*desc.chan}
|
||||
: desc.size;
|
||||
mat.create(size, type);
|
||||
}
|
||||
@ -414,7 +414,7 @@ void createMat(const cv::GMatDesc &desc, cv::Mat& mat)
|
||||
{
|
||||
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}
|
||||
: cv::gapi::own::to_ocv(desc.size);
|
||||
: desc.size;
|
||||
mat.create(size, type);
|
||||
}
|
||||
else
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <ade/util/iota_range.hpp>
|
||||
#include <ade/util/algorithm.hpp>
|
||||
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
#include <opencv2/gapi/own/mat.hpp> //gapi::own::Mat
|
||||
#include <opencv2/gapi/gmat.hpp>
|
||||
|
||||
|
@ -353,7 +353,7 @@ G_TYPED_KERNEL(GYUV2Gray, <cv::GMat(cv::GMat)>, "yuvtogray") {
|
||||
* U V U V U V U V
|
||||
*/
|
||||
|
||||
return {CV_8U, 1, cv::gapi::own::Size{in.size.width, in.size.height - (in.size.height / 3)}, false};
|
||||
return {CV_8U, 1, cv::Size{in.size.width, in.size.height - (in.size.height / 3)}, false};
|
||||
}
|
||||
};
|
||||
|
||||
@ -367,7 +367,7 @@ GAPI_OCV_KERNEL(GCPUYUV2Gray, GYUV2Gray)
|
||||
|
||||
G_TYPED_KERNEL(GConcatYUVPlanes, <cv::GMat(cv::GMat, cv::GMat)>, "concatyuvplanes") {
|
||||
static cv::GMatDesc outMeta(cv::GMatDesc y, cv::GMatDesc uv) {
|
||||
return {CV_8U, 1, cv::gapi::own::Size{y.size.width, y.size.height + uv.size.height}, false};
|
||||
return {CV_8U, 1, cv::Size{y.size.width, y.size.height + uv.size.height}, false};
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -554,8 +554,8 @@ void cv::gimpl::FluidAgent::debug(std::ostream &os)
|
||||
// GCPUExcecutable implementation //////////////////////////////////////////////
|
||||
|
||||
void cv::gimpl::GFluidExecutable::initBufferRois(std::vector<int>& readStarts,
|
||||
std::vector<cv::gapi::own::Rect>& rois,
|
||||
const std::vector<cv::gapi::own::Rect>& out_rois)
|
||||
std::vector<cv::Rect>& rois,
|
||||
const std::vector<cv::Rect>& out_rois)
|
||||
{
|
||||
GConstFluidModel fg(m_g);
|
||||
auto proto = m_gm.metadata().get<Protocol>();
|
||||
@ -592,9 +592,9 @@ void cv::gimpl::GFluidExecutable::initBufferRois(std::vector<int>& readStarts,
|
||||
readStarts[id] = 0;
|
||||
|
||||
const auto& out_roi = out_rois[idx];
|
||||
if (out_roi == gapi::own::Rect{})
|
||||
if (out_roi == cv::Rect{})
|
||||
{
|
||||
rois[id] = gapi::own::Rect{ 0, 0, desc.size.width, desc.size.height };
|
||||
rois[id] = cv::Rect{ 0, 0, desc.size.width, desc.size.height };
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -639,14 +639,14 @@ void cv::gimpl::GFluidExecutable::initBufferRois(std::vector<int>& readStarts,
|
||||
const auto& in_meta = util::get<GMatDesc>(in_data.meta);
|
||||
const auto& fd = fg.metadata(in_node).get<FluidData>();
|
||||
|
||||
auto adjFilterRoi = [](cv::gapi::own::Rect produced, int b, int max_height) {
|
||||
auto adjFilterRoi = [](cv::Rect produced, int b, int max_height) {
|
||||
// Extend with border roi which should be produced, crop to logical image size
|
||||
cv::gapi::own::Rect roi = {produced.x, produced.y - b, produced.width, produced.height + 2*b};
|
||||
cv::gapi::own::Rect fullImg{ 0, 0, produced.width, max_height };
|
||||
cv::Rect roi = {produced.x, produced.y - b, produced.width, produced.height + 2*b};
|
||||
cv::Rect fullImg{ 0, 0, produced.width, max_height };
|
||||
return roi & fullImg;
|
||||
};
|
||||
|
||||
auto adjResizeRoi = [](cv::gapi::own::Rect produced, cv::gapi::own::Size inSz, cv::gapi::own::Size outSz) {
|
||||
auto adjResizeRoi = [](cv::Rect produced, cv::Size inSz, cv::Size outSz) {
|
||||
auto map = [](int outCoord, int producedSz, int inSize, int outSize) {
|
||||
double ratio = (double)inSize / outSize;
|
||||
int w0 = 0, w1 = 0;
|
||||
@ -671,30 +671,30 @@ void cv::gimpl::GFluidExecutable::initBufferRois(std::vector<int>& readStarts,
|
||||
auto x0 = mapX.first;
|
||||
auto x1 = mapX.second;
|
||||
|
||||
cv::gapi::own::Rect roi = {x0, y0, x1 - x0, y1 - y0};
|
||||
cv::Rect roi = {x0, y0, x1 - x0, y1 - y0};
|
||||
return roi;
|
||||
};
|
||||
|
||||
auto adj420Roi = [&](cv::gapi::own::Rect produced, std::size_t port) {
|
||||
auto adj420Roi = [&](cv::Rect produced, std::size_t port) {
|
||||
GAPI_Assert(produced.x % 2 == 0);
|
||||
GAPI_Assert(produced.y % 2 == 0);
|
||||
GAPI_Assert(produced.width % 2 == 0);
|
||||
GAPI_Assert(produced.height % 2 == 0);
|
||||
|
||||
cv::gapi::own::Rect roi;
|
||||
cv::Rect roi;
|
||||
switch (port) {
|
||||
case 0: roi = produced; break;
|
||||
case 1:
|
||||
case 2: roi = cv::gapi::own::Rect{ produced.x/2, produced.y/2, produced.width/2, produced.height/2 }; break;
|
||||
case 2: roi = cv::Rect{ produced.x/2, produced.y/2, produced.width/2, produced.height/2 }; break;
|
||||
default: GAPI_Assert(false);
|
||||
}
|
||||
return roi;
|
||||
};
|
||||
|
||||
cv::gapi::own::Rect produced = rois[m_id_map.at(data.rc)];
|
||||
cv::Rect produced = rois[m_id_map.at(data.rc)];
|
||||
|
||||
// Apply resize-specific roi transformations
|
||||
cv::gapi::own::Rect resized;
|
||||
cv::Rect resized;
|
||||
switch (fg.metadata(oh).get<FluidUnit>().k.m_kind)
|
||||
{
|
||||
case GFluidKernel::Kind::Filter: resized = produced; break;
|
||||
@ -727,7 +727,7 @@ void cv::gimpl::GFluidExecutable::initBufferRois(std::vector<int>& readStarts,
|
||||
auto roi = adjFilterRoi(resized, fd.border_size, in_meta.size.height);
|
||||
|
||||
auto in_id = m_id_map.at(in_data.rc);
|
||||
if (rois[in_id] == cv::gapi::own::Rect{})
|
||||
if (rois[in_id] == cv::Rect{})
|
||||
{
|
||||
readStarts[in_id] = readStart;
|
||||
rois[in_id] = roi;
|
||||
@ -828,7 +828,7 @@ cv::gimpl::FluidGraphInputData cv::gimpl::fluidExtractInputDataFromGraph(const a
|
||||
|
||||
cv::gimpl::GFluidExecutable::GFluidExecutable(const ade::Graph &g,
|
||||
const cv::gimpl::FluidGraphInputData &traverse_res,
|
||||
const std::vector<cv::gapi::own::Rect> &outputRois)
|
||||
const std::vector<cv::Rect> &outputRois)
|
||||
: m_g(g), m_gm(m_g),
|
||||
m_num_int_buffers (traverse_res.m_mat_count),
|
||||
m_scratch_users (traverse_res.m_scratch_users),
|
||||
@ -1146,13 +1146,13 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void cv::gimpl::GFluidExecutable::makeReshape(const std::vector<gapi::own::Rect> &out_rois)
|
||||
void cv::gimpl::GFluidExecutable::makeReshape(const std::vector<cv::Rect> &out_rois)
|
||||
{
|
||||
GConstFluidModel fg(m_g);
|
||||
|
||||
// Calculate rois for each fluid buffer
|
||||
std::vector<int> readStarts(m_num_int_buffers);
|
||||
std::vector<cv::gapi::own::Rect> rois(m_num_int_buffers);
|
||||
std::vector<cv::Rect> rois(m_num_int_buffers);
|
||||
initBufferRois(readStarts, rois, out_rois);
|
||||
|
||||
// NB: Allocate ALL buffer object at once, and avoid any further reallocations
|
||||
|
@ -142,8 +142,8 @@ class GFluidExecutable final: public GIslandExecutable
|
||||
void bindOutArg(const RcDesc &rc, const GRunArgP &arg);
|
||||
void packArg (GArg &in_arg, const GArg &op_arg);
|
||||
|
||||
void initBufferRois(std::vector<int>& readStarts, std::vector<cv::gapi::own::Rect>& rois, const std::vector<gapi::own::Rect> &out_rois);
|
||||
void makeReshape(const std::vector<cv::gapi::own::Rect>& out_rois);
|
||||
void initBufferRois(std::vector<int>& readStarts, std::vector<cv::Rect>& rois, const std::vector<cv::Rect> &out_rois);
|
||||
void makeReshape(const std::vector<cv::Rect>& out_rois);
|
||||
std::size_t total_buffers_size() const;
|
||||
|
||||
public:
|
||||
@ -159,7 +159,7 @@ public:
|
||||
|
||||
GFluidExecutable(const ade::Graph &g,
|
||||
const FluidGraphInputData &graph_data,
|
||||
const std::vector<cv::gapi::own::Rect> &outputRois);
|
||||
const std::vector<cv::Rect> &outputRois);
|
||||
};
|
||||
|
||||
|
||||
|
@ -9,9 +9,6 @@
|
||||
|
||||
#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"
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
@ -271,8 +268,8 @@ 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)
|
||||
{
|
||||
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});
|
||||
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});
|
||||
|
||||
subSrc.copyTo(subDst);
|
||||
}
|
||||
@ -365,8 +362,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::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::Rect roi);
|
||||
std::unique_ptr<BufferStorage> createStorage(const cv::gapi::own::Mat& data, cv::Rect roi)
|
||||
{
|
||||
std::unique_ptr<BufferStorageWithoutBorder> storage(new BufferStorageWithoutBorder);
|
||||
storage->attach(data, roi);
|
||||
@ -504,7 +501,7 @@ void fluid::View::Priv::initCache(int lineConsumption)
|
||||
|
||||
// Fluid Buffer implementation /////////////////////////////////////////////////
|
||||
|
||||
fluid::Buffer::Priv::Priv(int read_start, cv::gapi::own::Rect roi)
|
||||
fluid::Buffer::Priv::Priv(int read_start, cv::Rect roi)
|
||||
: m_readStart(read_start)
|
||||
, m_roi(roi)
|
||||
{}
|
||||
@ -512,12 +509,12 @@ fluid::Buffer::Priv::Priv(int read_start, cv::gapi::own::Rect roi)
|
||||
void fluid::Buffer::Priv::init(const cv::GMatDesc &desc,
|
||||
int writer_lpi,
|
||||
int readStartPos,
|
||||
cv::gapi::own::Rect roi)
|
||||
cv::Rect roi)
|
||||
{
|
||||
m_writer_lpi = writer_lpi;
|
||||
m_desc = desc;
|
||||
m_readStart = readStartPos;
|
||||
m_roi = roi == own::Rect{} ? own::Rect{ 0, 0, desc.size.width, desc.size.height }
|
||||
m_roi = roi == cv::Rect{} ? cv::Rect{ 0, 0, desc.size.width, desc.size.height }
|
||||
: roi;
|
||||
m_cache.m_linePtrs.resize(writer_lpi);
|
||||
m_cache.m_desc = desc;
|
||||
@ -652,7 +649,7 @@ fluid::Buffer::Buffer(const cv::GMatDesc &desc)
|
||||
{
|
||||
int lineConsumption = 1;
|
||||
int border = 0, skew = 0, wlpi = 1, readStart = 0;
|
||||
cv::gapi::own::Rect roi = {0, 0, desc.size.width, desc.size.height};
|
||||
cv::Rect roi = {0, 0, desc.size.width, desc.size.height};
|
||||
m_priv->init(desc, wlpi, readStart, roi);
|
||||
m_priv->allocate({}, border, lineConsumption, skew);
|
||||
}
|
||||
@ -667,7 +664,7 @@ fluid::Buffer::Buffer(const cv::GMatDesc &desc,
|
||||
, m_cache(&m_priv->cache())
|
||||
{
|
||||
int readStart = 0;
|
||||
cv::gapi::own::Rect roi = {0, 0, desc.size.width, desc.size.height};
|
||||
cv::Rect roi = {0, 0, desc.size.width, desc.size.height};
|
||||
m_priv->init(desc, wlpi, readStart, roi);
|
||||
m_priv->allocate(border, border_size, max_line_consumption, skew);
|
||||
}
|
||||
@ -677,7 +674,7 @@ fluid::Buffer::Buffer(const cv::gapi::own::Mat &data, bool is_input)
|
||||
, m_cache(&m_priv->cache())
|
||||
{
|
||||
int wlpi = 1, readStart = 0;
|
||||
cv::gapi::own::Rect roi{0, 0, data.cols, data.rows};
|
||||
cv::Rect roi{0, 0, data.cols, data.rows};
|
||||
m_priv->init(descr_of(data), wlpi, readStart, roi);
|
||||
m_priv->bindTo(data, is_input);
|
||||
}
|
||||
|
@ -101,23 +101,23 @@ public:
|
||||
class BufferStorageWithoutBorder final : public BufferStorage
|
||||
{
|
||||
bool m_is_virtual = true;
|
||||
cv::gapi::own::Rect m_roi;
|
||||
cv::Rect m_roi;
|
||||
|
||||
public:
|
||||
virtual void copyTo(BufferStorageWithBorder &dst, int startLine, int nLines) const override;
|
||||
|
||||
inline virtual const uint8_t* ptr(int idx) const override
|
||||
{
|
||||
GAPI_DbgAssert((m_is_virtual && m_roi == cv::gapi::own::Rect{}) || (!m_is_virtual && m_roi != cv::gapi::own::Rect{}));
|
||||
GAPI_DbgAssert((m_is_virtual && m_roi == cv::Rect{}) || (!m_is_virtual && m_roi != cv::Rect{}));
|
||||
return m_data.ptr(physIdx(idx), 0);
|
||||
}
|
||||
inline virtual uint8_t* ptr(int idx) override
|
||||
{
|
||||
GAPI_DbgAssert((m_is_virtual && m_roi == cv::gapi::own::Rect{}) || (!m_is_virtual && m_roi != cv::gapi::own::Rect{}));
|
||||
GAPI_DbgAssert((m_is_virtual && m_roi == cv::Rect{}) || (!m_is_virtual && m_roi != cv::Rect{}));
|
||||
return m_data.ptr(physIdx(idx), 0);
|
||||
}
|
||||
|
||||
inline void attach(const cv::gapi::own::Mat& _data, cv::gapi::own::Rect _roi)
|
||||
inline void attach(const cv::gapi::own::Mat& _data, cv::Rect _roi)
|
||||
{
|
||||
m_data = _data(_roi);
|
||||
m_roi = _roi;
|
||||
@ -246,13 +246,13 @@ class GAPI_EXPORTS Buffer::Priv
|
||||
// Coordinate starting from which this buffer is assumed
|
||||
// to be read (with border not being taken into account)
|
||||
int m_readStart;
|
||||
cv::gapi::own::Rect m_roi;
|
||||
cv::Rect m_roi;
|
||||
|
||||
friend void debugBufferPriv(const Buffer& p, std::ostream &os);
|
||||
|
||||
public:
|
||||
Priv() = default;
|
||||
Priv(int read_start, cv::gapi::own::Rect roi);
|
||||
Priv(int read_start, cv::Rect roi);
|
||||
|
||||
inline const BufferStorage& storage() const { return *m_storage.get(); }
|
||||
|
||||
@ -260,7 +260,7 @@ public:
|
||||
void init(const cv::GMatDesc &desc,
|
||||
int writer_lpi,
|
||||
int readStart,
|
||||
cv::gapi::own::Rect roi);
|
||||
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);
|
||||
|
@ -2040,7 +2040,7 @@ GAPI_FLUID_KERNEL(GFluidResize, cv::gapi::core::GResize, true)
|
||||
cv::GMatDesc desc;
|
||||
desc.chan = 1;
|
||||
desc.depth = CV_8UC1;
|
||||
desc.size = to_own(scratch_size);
|
||||
desc.size = scratch_size;
|
||||
|
||||
cv::gapi::fluid::Buffer buffer(desc);
|
||||
scratch = std::move(buffer);
|
||||
|
@ -15,8 +15,6 @@
|
||||
#include <opencv2/gapi/core.hpp>
|
||||
#include <opencv2/gapi/imgproc.hpp>
|
||||
|
||||
#include <opencv2/gapi/own/types.hpp>
|
||||
|
||||
#include <opencv2/gapi/fluid/gfluidbuffer.hpp>
|
||||
#include <opencv2/gapi/fluid/gfluidkernel.hpp>
|
||||
#include <opencv2/gapi/fluid/imgproc.hpp>
|
||||
@ -451,7 +449,7 @@ GAPI_FLUID_KERNEL(GFluidBlur, cv::gapi::imgproc::GBlur, true)
|
||||
|
||||
int buflen = width * chan * Window; // work buffers
|
||||
|
||||
cv::gapi::own::Size bufsize(buflen, 1);
|
||||
cv::Size bufsize(buflen, 1);
|
||||
GMatDesc bufdesc = {CV_32F, 1, bufsize};
|
||||
Buffer buffer(bufdesc);
|
||||
scratch = std::move(buffer);
|
||||
@ -526,7 +524,7 @@ GAPI_FLUID_KERNEL(GFluidBoxFilter, cv::gapi::imgproc::GBoxFilter, true)
|
||||
|
||||
int buflen = width * chan * Window; // work buffers
|
||||
|
||||
cv::gapi::own::Size bufsize(buflen, 1);
|
||||
cv::Size bufsize(buflen, 1);
|
||||
GMatDesc bufdesc = {CV_32F, 1, bufsize};
|
||||
Buffer buffer(bufdesc);
|
||||
scratch = std::move(buffer);
|
||||
@ -748,7 +746,7 @@ GAPI_FLUID_KERNEL(GFluidSepFilter, cv::gapi::imgproc::GSepFilter, true)
|
||||
int buflen = kxLen + kyLen + // x, y kernels
|
||||
width * chan * Window; // work buffers
|
||||
|
||||
cv::gapi::own::Size bufsize(buflen, 1);
|
||||
cv::Size bufsize(buflen, 1);
|
||||
GMatDesc bufdesc = {CV_32F, 1, bufsize};
|
||||
Buffer buffer(bufdesc);
|
||||
scratch = std::move(buffer);
|
||||
@ -851,7 +849,7 @@ GAPI_FLUID_KERNEL(GFluidGaussBlur, cv::gapi::imgproc::GGaussBlur, true)
|
||||
int buflen = kxsize + kysize + // x, y kernels
|
||||
width * chan * ksize.height; // work buffers
|
||||
|
||||
cv::gapi::own::Size bufsize(buflen, 1);
|
||||
cv::Size bufsize(buflen, 1);
|
||||
GMatDesc bufdesc = {CV_32F, 1, bufsize};
|
||||
Buffer buffer(bufdesc);
|
||||
scratch = std::move(buffer);
|
||||
@ -1016,7 +1014,7 @@ GAPI_FLUID_KERNEL(GFluidSobel, cv::gapi::imgproc::GSobel, true)
|
||||
int buflen = ksz + ksz // kernels: kx, ky
|
||||
+ ksz * width * chan; // working buffers
|
||||
|
||||
cv::gapi::own::Size bufsize(buflen, 1);
|
||||
cv::Size bufsize(buflen, 1);
|
||||
GMatDesc bufdesc = {CV_32F, 1, bufsize};
|
||||
Buffer buffer(bufdesc);
|
||||
scratch = std::move(buffer);
|
||||
@ -1171,7 +1169,7 @@ GAPI_FLUID_KERNEL(GFluidSobelXY, cv::gapi::imgproc::GSobelXY, true)
|
||||
int chan = in.chan;
|
||||
int buflen = BufHelper::length(ksz, width, chan);
|
||||
|
||||
cv::gapi::own::Size bufsize(buflen, 1);
|
||||
cv::Size bufsize(buflen, 1);
|
||||
GMatDesc bufdesc = {CV_32F, 1, bufsize};
|
||||
Buffer buffer(bufdesc);
|
||||
scratch = std::move(buffer);
|
||||
@ -1319,7 +1317,7 @@ GAPI_FLUID_KERNEL(GFluidFilter2D, cv::gapi::imgproc::GFilter2D, true)
|
||||
|
||||
int buflen = krows * kcols; // kernel size
|
||||
|
||||
cv::gapi::own::Size bufsize(buflen, 1);
|
||||
cv::Size bufsize(buflen, 1);
|
||||
GMatDesc bufdesc = {CV_32F, 1, bufsize};
|
||||
Buffer buffer(bufdesc);
|
||||
scratch = std::move(buffer);
|
||||
@ -1496,7 +1494,7 @@ GAPI_FLUID_KERNEL(GFluidErode, cv::gapi::imgproc::GErode, true)
|
||||
int k_cols = kernel.cols;
|
||||
int k_size = k_rows * k_cols;
|
||||
|
||||
cv::gapi::own::Size bufsize(k_size + 1, 1);
|
||||
cv::Size bufsize(k_size + 1, 1);
|
||||
GMatDesc bufdesc = {CV_8U, 1, bufsize};
|
||||
Buffer buffer(bufdesc);
|
||||
scratch = std::move(buffer);
|
||||
@ -1582,7 +1580,7 @@ GAPI_FLUID_KERNEL(GFluidDilate, cv::gapi::imgproc::GDilate, true)
|
||||
int k_cols = kernel.cols;
|
||||
int k_size = k_rows * k_cols;
|
||||
|
||||
cv::gapi::own::Size bufsize(k_size + 1, 1);
|
||||
cv::Size bufsize(k_size + 1, 1);
|
||||
GMatDesc bufdesc = {CV_8U, 1, bufsize};
|
||||
Buffer buffer(bufdesc);
|
||||
scratch = std::move(buffer);
|
||||
@ -1749,7 +1747,7 @@ GAPI_FLUID_KERNEL(GFluidRGB2HSV, cv::gapi::imgproc::GRGB2HSV, true)
|
||||
cv::GMatDesc desc;
|
||||
desc.chan = 1;
|
||||
desc.depth = CV_32S;
|
||||
desc.size = cv::gapi::own::Size(512, 1);
|
||||
desc.size = cv::Size(512, 1);
|
||||
|
||||
cv::gapi::fluid::Buffer buffer(desc);
|
||||
scratch = std::move(buffer);
|
||||
|
@ -22,7 +22,7 @@ namespace {
|
||||
cv::GFluidParallelOutputRois asGFluidParallelOutputRois(const std::vector<cv::Rect>& rois){
|
||||
cv::GFluidParallelOutputRois parallel_rois;
|
||||
for (auto const& roi : rois) {
|
||||
parallel_rois.parallel_rois.emplace_back(GFluidOutputRois{{to_own(roi)}});
|
||||
parallel_rois.parallel_rois.emplace_back(GFluidOutputRois{{roi}});
|
||||
}
|
||||
return parallel_rois;
|
||||
}
|
||||
|
@ -744,7 +744,7 @@ TEST_P(NV12PlusResizeTest, Test)
|
||||
auto pkg = cv::gapi::combine(fluidTestPackage, cv::gapi::core::fluid::kernels());
|
||||
|
||||
c.apply(cv::gin(y_mat, uv_mat), cv::gout(out_mat)
|
||||
,cv::compile_args(pkg, cv::GFluidOutputRois{{to_own(roi)}}));
|
||||
,cv::compile_args(pkg, cv::GFluidOutputRois{{roi}}));
|
||||
|
||||
cv::Mat rgb_mat;
|
||||
cv::cvtColor(in_mat, rgb_mat, cv::COLOR_YUV2RGB_NV12);
|
||||
@ -823,7 +823,7 @@ TEST_P(Preproc4lpiTest, Test)
|
||||
fluidResizeTestPackage(interp, in_sz, out_sz, 4));
|
||||
|
||||
c.apply(cv::gin(y_mat, uv_mat), cv::gout(out_mat)
|
||||
,cv::compile_args(pkg, cv::GFluidOutputRois{{to_own(roi)}}));
|
||||
,cv::compile_args(pkg, cv::GFluidOutputRois{{roi}}));
|
||||
|
||||
cv::Mat rgb_mat;
|
||||
cv::cvtColor(in_mat, rgb_mat, cv::COLOR_YUV2RGB_NV12);
|
||||
|
@ -38,7 +38,7 @@ TEST_P(PartialComputation, Test)
|
||||
cv::Mat out_mat_ocv = cv::Mat::zeros(sz, CV_8UC1);
|
||||
|
||||
// Run G-API
|
||||
auto cc = c.compile(cv::descr_of(in_mat), cv::compile_args(fluidTestPackage, GFluidOutputRois{{to_own(roi)}}));
|
||||
auto cc = c.compile(cv::descr_of(in_mat), cv::compile_args(fluidTestPackage, GFluidOutputRois{{roi}}));
|
||||
cc(cv::gin(in_mat), cv::gout(out_mat_gapi));
|
||||
|
||||
// Check with OpenCV
|
||||
@ -72,7 +72,7 @@ TEST_P(PartialComputationAddC, Test)
|
||||
cv::Mat out_mat_ocv = cv::Mat::zeros(sz, CV_8UC1);
|
||||
|
||||
// Run G-API
|
||||
auto cc = c.compile(cv::descr_of(in_mat), cv::compile_args(fluidTestPackage, GFluidOutputRois{{to_own(roi)}}));
|
||||
auto cc = c.compile(cv::descr_of(in_mat), cv::compile_args(fluidTestPackage, GFluidOutputRois{{roi}}));
|
||||
cc(cv::gin(in_mat), cv::gout(out_mat_gapi));
|
||||
|
||||
// Check with OpenCV
|
||||
@ -110,7 +110,7 @@ TEST_P(SequenceOfBlursRoiTest, Test)
|
||||
Mat out_mat_gapi = Mat::zeros(sz_in, CV_8UC1);
|
||||
|
||||
GComputation c(GIn(in), GOut(out));
|
||||
auto cc = c.compile(descr_of(in_mat), cv::compile_args(fluidTestPackage, GFluidOutputRois{{to_own(roi)}}));
|
||||
auto cc = c.compile(descr_of(in_mat), cv::compile_args(fluidTestPackage, GFluidOutputRois{{roi}}));
|
||||
cc(gin(in_mat), gout(out_mat_gapi));
|
||||
|
||||
cv::Mat mid_mat_ocv = Mat::zeros(sz_in, CV_8UC1);
|
||||
|
@ -754,7 +754,7 @@ TEST_P(NV12RoiTest, Test)
|
||||
auto rgb = cv::gapi::NV12toRGB(y, uv);
|
||||
cv::GComputation c(cv::GIn(y, uv), cv::GOut(rgb));
|
||||
|
||||
c.apply(cv::gin(y_mat, uv_mat), cv::gout(out_mat), cv::compile_args(fluidTestPackage, cv::GFluidOutputRois{{to_own(roi)}}));
|
||||
c.apply(cv::gin(y_mat, uv_mat), cv::gout(out_mat), cv::compile_args(fluidTestPackage, cv::GFluidOutputRois{{roi}}));
|
||||
|
||||
cv::cvtColor(in_mat, out_mat_ocv, cv::COLOR_YUV2RGB_NV12);
|
||||
|
||||
@ -835,7 +835,7 @@ TEST(Fluid, InvalidROIs)
|
||||
};
|
||||
|
||||
const auto compile_args = [] (cv::Rect roi) {
|
||||
return cv::compile_args(cv::gapi::core::fluid::kernels(), GFluidOutputRois{{to_own(roi)}});
|
||||
return cv::compile_args(cv::gapi::core::fluid::kernels(), GFluidOutputRois{{roi}});
|
||||
};
|
||||
|
||||
for (const auto& roi : invalid_rois)
|
||||
|
@ -61,7 +61,7 @@ TEST_F(GCompiledValidateMetaTyped, ValidMeta)
|
||||
|
||||
TEST_F(GCompiledValidateMetaTyped, InvalidMeta)
|
||||
{
|
||||
auto f = m_cc.compile(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(64,32)},
|
||||
auto f = m_cc.compile(cv::GMatDesc{CV_8U,1,cv::Size(64,32)},
|
||||
cv::empty_scalar_desc());
|
||||
|
||||
cv::Scalar sc(33);
|
||||
@ -106,7 +106,7 @@ TEST_F(GCompiledValidateMetaUntyped, ValidMeta)
|
||||
|
||||
TEST_F(GCompiledValidateMetaUntyped, InvalidMetaValues)
|
||||
{
|
||||
auto f = m_ucc.compile(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(64,32)},
|
||||
auto f = m_ucc.compile(cv::GMatDesc{CV_8U,1,cv::Size(64,32)},
|
||||
cv::empty_scalar_desc());
|
||||
|
||||
cv::Scalar sc(33);
|
||||
@ -131,7 +131,7 @@ TEST_F(GCompiledValidateMetaUntyped, InvalidMetaValues)
|
||||
|
||||
TEST_F(GCompiledValidateMetaUntyped, InvalidMetaShape)
|
||||
{
|
||||
auto f = m_ucc.compile(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(64,32)},
|
||||
auto f = m_ucc.compile(cv::GMatDesc{CV_8U,1,cv::Size(64,32)},
|
||||
cv::empty_scalar_desc());
|
||||
|
||||
cv::Mat in1 = cv::Mat::eye(cv::Size(64,32), CV_8UC1);
|
||||
|
@ -19,13 +19,13 @@ namespace opencv_test
|
||||
static cv::GMatDesc outMeta(cv::GMatDesc in, cv::Size sz, double fx, double fy, int) {
|
||||
if (sz.width != 0 && sz.height != 0)
|
||||
{
|
||||
return in.withSize(to_own(sz));
|
||||
return in.withSize(sz);
|
||||
}
|
||||
else
|
||||
{
|
||||
GAPI_Assert(fx != 0. && fy != 0.);
|
||||
return in.withSize
|
||||
(cv::gapi::own::Size(static_cast<int>(std::round(in.size.width * fx)),
|
||||
(cv::Size(static_cast<int>(std::round(in.size.width * fx)),
|
||||
static_cast<int>(std::round(in.size.height * fy))));
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ TEST(IslandFusion, TwoOps_OneIsland)
|
||||
cv::GComputation cc(in, out);
|
||||
|
||||
// Prepare compilation parameters manually
|
||||
const auto in_meta = cv::GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)});
|
||||
const auto in_meta = cv::GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)});
|
||||
const auto pkg = cv::gapi::kernels<J::Foo>();
|
||||
|
||||
// Directly instantiate G-API graph compiler and run partial compilation
|
||||
@ -77,7 +77,7 @@ TEST(IslandFusion, TwoOps_TwoIslands)
|
||||
cv::GComputation cc(in, out);
|
||||
|
||||
// Prepare compilation parameters manually
|
||||
const auto in_meta = cv::GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)});
|
||||
const auto in_meta = cv::GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)});
|
||||
const auto pkg = cv::gapi::kernels<J::Foo, S::Bar>();
|
||||
|
||||
// Directly instantiate G-API graph compiler and run partial compilation
|
||||
@ -142,8 +142,8 @@ TEST(IslandFusion, ConsumerHasTwoInputs)
|
||||
cv::GComputation cc(cv::GIn(in[0], in[1]), cv::GOut(out));
|
||||
|
||||
// Prepare compilation parameters manually
|
||||
cv::GMetaArgs in_metas = {GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)}),
|
||||
GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)})};
|
||||
cv::GMetaArgs in_metas = {GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)}),
|
||||
GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)})};
|
||||
const auto pkg = cv::gapi::kernels<J::Foo, J::Bar>();
|
||||
|
||||
// Directly instantiate G-API graph compiler and run partial compilation
|
||||
@ -211,7 +211,7 @@ TEST(IslandFusion, DataNodeUsedDifferentBackend)
|
||||
cv::GComputation cc(cv::GIn(in), cv::GOut(out0, out1));
|
||||
|
||||
// Prepare compilation parameters manually
|
||||
const auto in_meta = cv::GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)});
|
||||
const auto in_meta = cv::GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)});
|
||||
const auto pkg = cv::gapi::kernels<J::Foo, S::Baz>();
|
||||
|
||||
// Directly instantiate G-API graph compiler and run partial compilation
|
||||
@ -272,7 +272,7 @@ TEST(IslandFusion, LoopBetweenDifferentBackends)
|
||||
cv::GComputation cc(cv::GIn(in), cv::GOut(out1, out0));
|
||||
|
||||
// Prepare compilation parameters manually
|
||||
const auto in_meta = cv::GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)});
|
||||
const auto in_meta = cv::GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)});
|
||||
const auto pkg = cv::gapi::kernels<J::Baz, J::Quux, S::Foo, S::Qux>();
|
||||
|
||||
// Directly instantiate G-API graph compiler and run partial compilation
|
||||
@ -334,8 +334,8 @@ TEST(IslandsFusion, PartionOverlapUserIsland)
|
||||
cv::GComputation cc(cv::GIn(in[0], in[1]), cv::GOut(out));
|
||||
|
||||
// Prepare compilation parameters manually
|
||||
cv::GMetaArgs in_metas = {GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)}),
|
||||
GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)})};
|
||||
cv::GMetaArgs in_metas = {GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)}),
|
||||
GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)})};
|
||||
const auto pkg = cv::gapi::kernels<J::Foo, J::Bar>();
|
||||
|
||||
// Directly instantiate G-API graph compiler and run partial compilation
|
||||
@ -391,8 +391,8 @@ TEST(IslandsFusion, DISABLED_IslandContainsDifferentBackends)
|
||||
cv::GComputation cc(cv::GIn(in[0], in[1]), cv::GOut(out));
|
||||
|
||||
// Prepare compilation parameters manually
|
||||
cv::GMetaArgs in_metas = {GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)}),
|
||||
GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)})};
|
||||
cv::GMetaArgs in_metas = {GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)}),
|
||||
GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)})};
|
||||
const auto pkg = cv::gapi::kernels<J::Foo, S::Bar>();
|
||||
|
||||
// Directly instantiate G-API graph compiler and run partial compilation
|
||||
@ -424,7 +424,7 @@ TEST(IslandFusion, WithLoop)
|
||||
cv::GComputation cc(in, out);
|
||||
|
||||
// Prepare compilation parameters manually
|
||||
const auto in_meta = cv::GMetaArg(cv::GMatDesc{CV_8U,1,cv::gapi::own::Size(32,32)});
|
||||
const auto in_meta = cv::GMetaArg(cv::GMatDesc{CV_8U,1,cv::Size(32,32)});
|
||||
const auto pkg = cv::gapi::kernels<J::Foo, J::Baz, J::Qux>();
|
||||
|
||||
// Directly instantiate G-API graph compiler and run partial compilation
|
||||
|
@ -216,7 +216,7 @@ TEST(GComputationCompile, ReshapeRois)
|
||||
int roiH = szOut.height / niter;
|
||||
cv::Rect roi{x, y, roiW, roiH};
|
||||
|
||||
cc.apply(in_mat, out_mat, cv::compile_args(cv::GFluidOutputRois{{to_own(roi)}}));
|
||||
cc.apply(in_mat, out_mat, cv::compile_args(cv::GFluidOutputRois{{roi}}));
|
||||
auto comp = cc.priv().m_lastCompiled;
|
||||
|
||||
EXPECT_EQ(&first_comp.priv(), &comp.priv());
|
||||
|
Loading…
Reference in New Issue
Block a user