mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 14:36:36 +08: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:
parent
66fdddc339
commit
2c6ab65476
@ -14,10 +14,12 @@
|
||||
#include <cstdint> // uint8_t
|
||||
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
#include <opencv2/gapi/own/mat.hpp>
|
||||
#include <opencv2/gapi/gmat.hpp>
|
||||
|
||||
#include "opencv2/gapi/util/optional.hpp"
|
||||
#include "opencv2/gapi/own/scalar.hpp"
|
||||
#include "opencv2/gapi/own/mat.hpp"
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
@ -25,9 +27,10 @@ namespace fluid {
|
||||
|
||||
struct Border
|
||||
{
|
||||
#if 1
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
// This constructor is required to support existing kernels which are part of G-API
|
||||
Border(int _type, cv::Scalar _val) : type(_type), value(to_own(_val)) {};
|
||||
#endif
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
Border(int _type, cv::gapi::own::Scalar _val) : type(_type), value(_val) {};
|
||||
int type;
|
||||
cv::gapi::own::Scalar value;
|
||||
@ -45,7 +48,7 @@ public:
|
||||
View() = default;
|
||||
|
||||
const uint8_t* InLineB(int index) const; // -(w-1)/2...0...+(w-1)/2 for Filters
|
||||
template<typename T> const T* InLine(int i) const
|
||||
template<typename T> const inline T* InLine(int i) const
|
||||
{
|
||||
const uint8_t* ptr = this->InLineB(i);
|
||||
return reinterpret_cast<const T*>(ptr);
|
||||
@ -56,7 +59,7 @@ public:
|
||||
int length() const;
|
||||
int y() const;
|
||||
|
||||
GMatDesc meta() const;
|
||||
const GMatDesc& meta() const;
|
||||
|
||||
class GAPI_EXPORTS Priv; // internal use only
|
||||
Priv& priv(); // internal use only
|
||||
@ -84,10 +87,10 @@ public:
|
||||
int wlpi,
|
||||
BorderOpt border);
|
||||
// Constructor for in/out buffers (for tests)
|
||||
Buffer(const cv::Mat &data, bool is_input);
|
||||
Buffer(const cv::gapi::own::Mat &data, bool is_input);
|
||||
|
||||
uint8_t* OutLineB(int index = 0);
|
||||
template<typename T> T* OutLine(int index = 0)
|
||||
template<typename T> inline T* OutLine(int index = 0)
|
||||
{
|
||||
uint8_t* ptr = this->OutLineB(index);
|
||||
return reinterpret_cast<T*>(ptr);
|
||||
@ -100,7 +103,7 @@ public:
|
||||
int length() const;
|
||||
int lpi() const; // LPI for WRITER
|
||||
|
||||
GMatDesc meta() const;
|
||||
const GMatDesc& meta() const;
|
||||
|
||||
View mkView(int lineConsumption, int borderSize, BorderOpt border, bool ownStorage);
|
||||
|
||||
|
@ -102,22 +102,30 @@ template<> struct fluid_get_in<cv::GMat>
|
||||
{
|
||||
static const cv::gapi::fluid::View& get(const cv::GArgs &in_args, int idx)
|
||||
{
|
||||
return in_args[idx].get<cv::gapi::fluid::View>();
|
||||
return in_args[idx].unsafe_get<cv::gapi::fluid::View>();
|
||||
}
|
||||
};
|
||||
|
||||
template<> struct fluid_get_in<cv::GScalar>
|
||||
{
|
||||
// FIXME: change to return by reference when moved to own::Scalar
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
static const cv::Scalar get(const cv::GArgs &in_args, int idx)
|
||||
{
|
||||
return cv::gapi::own::to_ocv(in_args[idx].get<cv::gapi::own::Scalar>());
|
||||
return cv::gapi::own::to_ocv(in_args[idx].unsafe_get<cv::gapi::own::Scalar>());
|
||||
}
|
||||
#else
|
||||
static const cv::gapi::own::Scalar get(const cv::GArgs &in_args, int idx)
|
||||
{
|
||||
return in_args[idx].get<cv::gapi::own::Scalar>();
|
||||
}
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
};
|
||||
template<class T> struct fluid_get_in
|
||||
{
|
||||
static T get(const cv::GArgs &in_args, int idx)
|
||||
static const T& get(const cv::GArgs &in_args, int idx)
|
||||
{
|
||||
return in_args[idx].get<T>();
|
||||
return in_args[idx].unsafe_get<T>();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -56,16 +56,26 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T> T& get()
|
||||
template<typename T> inline T& get()
|
||||
{
|
||||
return util::any_cast<typename std::remove_reference<T>::type>(value);
|
||||
}
|
||||
|
||||
template<typename T> const T& get() const
|
||||
template<typename T> inline const T& get() const
|
||||
{
|
||||
return util::any_cast<typename std::remove_reference<T>::type>(value);
|
||||
}
|
||||
|
||||
template<typename T> inline T& unsafe_get()
|
||||
{
|
||||
return util::unsafe_any_cast<typename std::remove_reference<T>::type>(value);
|
||||
}
|
||||
|
||||
template<typename T> inline const T& unsafe_get() const
|
||||
{
|
||||
return util::unsafe_any_cast<typename std::remove_reference<T>::type>(value);
|
||||
}
|
||||
|
||||
detail::ArgKind kind = detail::ArgKind::OPAQUE;
|
||||
|
||||
protected:
|
||||
@ -76,10 +86,26 @@ using GArgs = std::vector<GArg>;
|
||||
|
||||
// FIXME: Express as M<GProtoArg...>::type
|
||||
// FIXME: Move to a separate file!
|
||||
using GRunArg = util::variant<cv::Mat, cv::gapi::own::Mat, cv::Scalar, cv::gapi::own::Scalar, cv::detail::VectorRef>;
|
||||
using GRunArg = util::variant<
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
cv::Mat,
|
||||
cv::Scalar,
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
cv::gapi::own::Mat,
|
||||
cv::gapi::own::Scalar,
|
||||
cv::detail::VectorRef
|
||||
>;
|
||||
using GRunArgs = std::vector<GRunArg>;
|
||||
|
||||
using GRunArgP = util::variant<cv::Mat*, cv::gapi::own::Mat*, cv::Scalar*, cv::gapi::own::Scalar*, cv::detail::VectorRef>;
|
||||
using GRunArgP = util::variant<
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
cv::Mat*,
|
||||
cv::Scalar*,
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
cv::gapi::own::Mat*,
|
||||
cv::gapi::own::Scalar*,
|
||||
cv::detail::VectorRef
|
||||
>;
|
||||
using GRunArgsP = std::vector<GRunArgP>;
|
||||
|
||||
|
||||
|
@ -10,9 +10,8 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "opencv2/gapi/opencv_includes.hpp"
|
||||
#include "opencv2/gapi/own/assert.hpp"
|
||||
#include "opencv2/core/mat.hpp"
|
||||
|
||||
#include "opencv2/gapi/garg.hpp"
|
||||
|
||||
namespace cv {
|
||||
@ -36,13 +35,14 @@ public:
|
||||
GCompiled();
|
||||
|
||||
void operator() (GRunArgs &&ins, GRunArgsP &&outs); // Generic arg-to-arg
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
void operator() (cv::Mat in, cv::Mat &out); // Unary overload
|
||||
void operator() (cv::Mat in, cv::Scalar &out); // Unary overload (scalar)
|
||||
void operator() (cv::Mat in1, cv::Mat in2, cv::Mat &out); // Binary overload
|
||||
void operator() (cv::Mat in1, cv::Mat in2, cv::Scalar &out); // Binary overload (scalar)
|
||||
void operator() (const std::vector<cv::Mat> &ins, // Compatibility overload
|
||||
const std::vector<cv::Mat> &outs);
|
||||
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
Priv& priv();
|
||||
|
||||
explicit operator bool () const; // Check if GCompiled is runnable or empty
|
||||
|
@ -58,8 +58,12 @@ public:
|
||||
// Various versions of apply(): ////////////////////////////////////////////
|
||||
// 1. Generic apply()
|
||||
void apply(GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args = {}); // Arg-to-arg overload
|
||||
void apply(const std::vector<cv::gapi::own::Mat>& ins, // Compatibility overload
|
||||
const std::vector<cv::gapi::own::Mat>& outs,
|
||||
GCompileArgs &&args = {});
|
||||
|
||||
// 2. Syntax sugar and compatibility overloads
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
void apply(cv::Mat in, cv::Mat &out, GCompileArgs &&args = {}); // Unary overload
|
||||
void apply(cv::Mat in, cv::Scalar &out, GCompileArgs &&args = {}); // Unary overload (scalar)
|
||||
void apply(cv::Mat in1, cv::Mat in2, cv::Mat &out, GCompileArgs &&args = {}); // Binary overload
|
||||
@ -67,7 +71,7 @@ public:
|
||||
void apply(const std::vector<cv::Mat>& ins, // Compatibility overload
|
||||
const std::vector<cv::Mat>& outs,
|
||||
GCompileArgs &&args = {});
|
||||
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
// Various versions of compile(): //////////////////////////////////////////
|
||||
// 1. Generic compile() - requires metas to be passed as vector
|
||||
GCompiled compile(GMetaArgs &&in_metas, GCompileArgs &&args = {});
|
||||
|
@ -65,12 +65,17 @@ struct GAPI_EXPORTS GMatDesc
|
||||
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));
|
||||
}
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
// Meta combinator: return a new GMatDesc which differs in size by delta
|
||||
// (all other fields are taken unchanged from this GMatDesc)
|
||||
//
|
||||
@ -87,11 +92,6 @@ struct GAPI_EXPORTS GMatDesc
|
||||
return desc;
|
||||
}
|
||||
|
||||
GMatDesc withSize(cv::Size sz) const
|
||||
{
|
||||
return withSize(to_own(sz));
|
||||
}
|
||||
|
||||
// Meta combinator: return a new GMatDesc with specified data depth.
|
||||
// (all other fields are taken unchanged from this GMatDesc)
|
||||
GMatDesc withDepth(int ddepth) const
|
||||
@ -116,12 +116,14 @@ struct GAPI_EXPORTS GMatDesc
|
||||
|
||||
static inline GMatDesc empty_gmat_desc() { return GMatDesc{-1,-1,{-1,-1}}; }
|
||||
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
class Mat;
|
||||
GAPI_EXPORTS GMatDesc descr_of(const cv::Mat &mat);
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
namespace gapi { namespace own {
|
||||
class Mat;
|
||||
CV_EXPORTS GMatDesc descr_of(const Mat &mat);
|
||||
GAPI_EXPORTS GMatDesc descr_of(const Mat &mat);
|
||||
}}//gapi::own
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const cv::GMatDesc &desc);
|
||||
|
@ -14,9 +14,7 @@
|
||||
#include <opencv2/gapi/gcommon.hpp> // GShape
|
||||
#include <opencv2/gapi/util/optional.hpp>
|
||||
#include "opencv2/gapi/own/scalar.hpp"
|
||||
#include <opencv2/core/types.hpp>
|
||||
|
||||
// TODO GAPI_EXPORTS or so
|
||||
namespace cv
|
||||
{
|
||||
// Forward declaration; GNode and GOrigin are an internal
|
||||
@ -30,7 +28,9 @@ public:
|
||||
GScalar(); // Empty constructor
|
||||
explicit GScalar(const cv::gapi::own::Scalar& s); // Constant value constructor from cv::gapi::own::Scalar
|
||||
explicit GScalar(cv::gapi::own::Scalar&& s); // Constant value move-constructor from cv::gapi::own::Scalar
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
explicit GScalar(const cv::Scalar& s); // Constant value constructor from cv::Scalar
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
GScalar(double v0); // Constant value constructor from double
|
||||
GScalar(const GNode &n, std::size_t out); // Operation result constructor
|
||||
|
||||
@ -59,7 +59,10 @@ struct GScalarDesc
|
||||
static inline GScalarDesc empty_scalar_desc() { return GScalarDesc(); }
|
||||
|
||||
GAPI_EXPORTS GScalarDesc descr_of(const cv::gapi::own::Scalar &scalar);
|
||||
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
GAPI_EXPORTS GScalarDesc descr_of(const cv::Scalar &scalar);
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const cv::GScalarDesc &desc);
|
||||
|
||||
|
@ -77,9 +77,11 @@ namespace detail
|
||||
// Resolve a Host type back to its associated G-Type.
|
||||
// FIXME: Probably it can be avoided
|
||||
template<typename T> struct GTypeOf;
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
template<> struct GTypeOf<cv::Mat> { using type = cv::GMat; };
|
||||
template<> struct GTypeOf<cv::gapi::own::Mat> { using type = cv::GMat; };
|
||||
template<> struct GTypeOf<cv::Scalar> { using type = cv::GScalar; };
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
template<> struct GTypeOf<cv::gapi::own::Mat> { using type = cv::GMat; };
|
||||
template<> struct GTypeOf<cv::gapi::own::Scalar> { using type = cv::GScalar; };
|
||||
template<typename U> struct GTypeOf<std::vector<U> > { using type = cv::GArray<U>; };
|
||||
template<class T> using g_type_of_t = typename GTypeOf<T>::type;
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#ifndef OPENCV_GAPI_GTYPED_HPP
|
||||
#define OPENCV_GAPI_GTYPED_HPP
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
|
||||
#include <vector>
|
||||
|
||||
@ -182,5 +183,5 @@ public:
|
||||
};
|
||||
|
||||
} // namespace cv
|
||||
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
#endif // OPENCV_GAPI_GTYPED_HPP
|
||||
|
@ -1,4 +1,5 @@
|
||||
// This file is part of OpenCV project.
|
||||
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
@ -8,9 +9,13 @@
|
||||
#ifndef OPENCV_GAPI_OPENCV_INCLUDES_HPP
|
||||
#define OPENCV_GAPI_OPENCV_INCLUDES_HPP
|
||||
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
# include <opencv2/core/mat.hpp>
|
||||
# include <opencv2/core/cvdef.h>
|
||||
# include <opencv2/core/types.hpp>
|
||||
# include <opencv2/core/base.hpp>
|
||||
#else // Without OpenCV
|
||||
# include <opencv2/gapi/own/cvdefs.hpp>
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
#endif // OPENCV_GAPI_OPENCV_INCLUDES_HPP
|
||||
|
@ -8,8 +8,9 @@
|
||||
#ifndef OPENCV_GAPI_OWN_CONVERT_HPP
|
||||
#define OPENCV_GAPI_OWN_CONVERT_HPP
|
||||
|
||||
#include <opencv2/core/types.hpp>
|
||||
#include <opencv2/core/mat.hpp>
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
#include <opencv2/gapi/own/types.hpp>
|
||||
#include <opencv2/gapi/own/mat.hpp>
|
||||
#include "opencv2/gapi/own/scalar.hpp"
|
||||
@ -44,4 +45,6 @@ namespace own
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
#endif // OPENCV_GAPI_OWN_CONVERT_HPP
|
||||
|
146
modules/gapi/include/opencv2/gapi/own/cvdefs.hpp
Normal file
146
modules/gapi/include/opencv2/gapi/own/cvdefs.hpp
Normal file
@ -0,0 +1,146 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#ifndef OPENCV_GAPI_CV_DEFS_HPP
|
||||
#define OPENCV_GAPI_CV_DEFS_HPP
|
||||
|
||||
#if defined(GAPI_STANDALONE)
|
||||
|
||||
// Simulate OpenCV definitions taken from various
|
||||
// OpenCV interface headers if G-API is built in a
|
||||
// standalone mode.
|
||||
|
||||
// interface.h:
|
||||
|
||||
typedef unsigned char uchar;
|
||||
typedef char schar;
|
||||
|
||||
typedef unsigned short ushort;
|
||||
|
||||
#define CV_CN_MAX 512
|
||||
#define CV_CN_SHIFT 3
|
||||
#define CV_DEPTH_MAX (1 << CV_CN_SHIFT)
|
||||
|
||||
|
||||
#define CV_8U 0
|
||||
#define CV_8S 1
|
||||
#define CV_16U 2
|
||||
#define CV_16S 3
|
||||
#define CV_32S 4
|
||||
#define CV_32F 5
|
||||
#define CV_64F 6
|
||||
#define CV_USRTYPE1 7
|
||||
|
||||
#define CV_MAT_DEPTH_MASK (CV_DEPTH_MAX - 1)
|
||||
#define CV_MAT_DEPTH(flags) ((flags) & CV_MAT_DEPTH_MASK)
|
||||
|
||||
#define CV_MAKETYPE(depth,cn) (CV_MAT_DEPTH(depth) + (((cn)-1) << CV_CN_SHIFT))
|
||||
#define CV_MAKE_TYPE CV_MAKETYPE
|
||||
|
||||
#define CV_8UC1 CV_MAKETYPE(CV_8U,1)
|
||||
#define CV_8UC2 CV_MAKETYPE(CV_8U,2)
|
||||
#define CV_8UC3 CV_MAKETYPE(CV_8U,3)
|
||||
#define CV_8UC4 CV_MAKETYPE(CV_8U,4)
|
||||
#define CV_8UC(n) CV_MAKETYPE(CV_8U,(n))
|
||||
|
||||
#define CV_8SC1 CV_MAKETYPE(CV_8S,1)
|
||||
#define CV_8SC2 CV_MAKETYPE(CV_8S,2)
|
||||
#define CV_8SC3 CV_MAKETYPE(CV_8S,3)
|
||||
#define CV_8SC4 CV_MAKETYPE(CV_8S,4)
|
||||
#define CV_8SC(n) CV_MAKETYPE(CV_8S,(n))
|
||||
|
||||
#define CV_16UC1 CV_MAKETYPE(CV_16U,1)
|
||||
#define CV_16UC2 CV_MAKETYPE(CV_16U,2)
|
||||
#define CV_16UC3 CV_MAKETYPE(CV_16U,3)
|
||||
#define CV_16UC4 CV_MAKETYPE(CV_16U,4)
|
||||
#define CV_16UC(n) CV_MAKETYPE(CV_16U,(n))
|
||||
|
||||
#define CV_16SC1 CV_MAKETYPE(CV_16S,1)
|
||||
#define CV_16SC2 CV_MAKETYPE(CV_16S,2)
|
||||
#define CV_16SC3 CV_MAKETYPE(CV_16S,3)
|
||||
#define CV_16SC4 CV_MAKETYPE(CV_16S,4)
|
||||
#define CV_16SC(n) CV_MAKETYPE(CV_16S,(n))
|
||||
|
||||
#define CV_32SC1 CV_MAKETYPE(CV_32S,1)
|
||||
#define CV_32SC2 CV_MAKETYPE(CV_32S,2)
|
||||
#define CV_32SC3 CV_MAKETYPE(CV_32S,3)
|
||||
#define CV_32SC4 CV_MAKETYPE(CV_32S,4)
|
||||
#define CV_32SC(n) CV_MAKETYPE(CV_32S,(n))
|
||||
|
||||
#define CV_32FC1 CV_MAKETYPE(CV_32F,1)
|
||||
#define CV_32FC2 CV_MAKETYPE(CV_32F,2)
|
||||
#define CV_32FC3 CV_MAKETYPE(CV_32F,3)
|
||||
#define CV_32FC4 CV_MAKETYPE(CV_32F,4)
|
||||
#define CV_32FC(n) CV_MAKETYPE(CV_32F,(n))
|
||||
|
||||
#define CV_64FC1 CV_MAKETYPE(CV_64F,1)
|
||||
#define CV_64FC2 CV_MAKETYPE(CV_64F,2)
|
||||
#define CV_64FC3 CV_MAKETYPE(CV_64F,3)
|
||||
#define CV_64FC4 CV_MAKETYPE(CV_64F,4)
|
||||
#define CV_64FC(n) CV_MAKETYPE(CV_64F,(n))
|
||||
|
||||
// cvdef.h:
|
||||
|
||||
#define CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT)
|
||||
#define CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1)
|
||||
#define CV_MAT_TYPE_MASK (CV_DEPTH_MAX*CV_CN_MAX - 1)
|
||||
#define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK)
|
||||
#define CV_MAT_CONT_FLAG_SHIFT 14
|
||||
#define CV_MAT_CONT_FLAG (1 << CV_MAT_CONT_FLAG_SHIFT)
|
||||
#define CV_IS_MAT_CONT(flags) ((flags) & CV_MAT_CONT_FLAG)
|
||||
#define CV_IS_CONT_MAT CV_IS_MAT_CONT
|
||||
#define CV_SUBMAT_FLAG_SHIFT 15
|
||||
#define CV_SUBMAT_FLAG (1 << CV_SUBMAT_FLAG_SHIFT)
|
||||
#define CV_IS_SUBMAT(flags) ((flags) & CV_MAT_SUBMAT_FLAG)
|
||||
|
||||
///** Size of each channel item,
|
||||
// 0x8442211 = 1000 0100 0100 0010 0010 0001 0001 ~ array of sizeof(arr_type_elem) */
|
||||
//#define CV_ELEM_SIZE1(type) \
|
||||
// ((((sizeof(size_t)<<28)|0x8442211) >> CV_MAT_DEPTH(type)*4) & 15)
|
||||
|
||||
#define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK)
|
||||
|
||||
/** 0x3a50 = 11 10 10 01 01 00 00 ~ array of log2(sizeof(arr_type_elem)) */
|
||||
#define CV_ELEM_SIZE(type) \
|
||||
(CV_MAT_CN(type) << ((((sizeof(size_t)/4+1)*16384|0x3a50) >> CV_MAT_DEPTH(type)*2) & 3))
|
||||
|
||||
// base.h:
|
||||
namespace cv
|
||||
{
|
||||
enum BorderTypes {
|
||||
BORDER_CONSTANT = 0, //!< `iiiiii|abcdefgh|iiiiiii` with some specified `i`
|
||||
BORDER_REPLICATE = 1, //!< `aaaaaa|abcdefgh|hhhhhhh`
|
||||
BORDER_REFLECT = 2, //!< `fedcba|abcdefgh|hgfedcb`
|
||||
BORDER_WRAP = 3, //!< `cdefgh|abcdefgh|abcdefg`
|
||||
BORDER_REFLECT_101 = 4, //!< `gfedcb|abcdefgh|gfedcba`
|
||||
BORDER_TRANSPARENT = 5, //!< `uvwxyz|abcdefgh|ijklmno`
|
||||
|
||||
BORDER_REFLECT101 = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101
|
||||
BORDER_DEFAULT = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101
|
||||
BORDER_ISOLATED = 16 //!< do not look outside of ROI
|
||||
};
|
||||
// imgproc.hpp:
|
||||
enum InterpolationFlags{
|
||||
INTER_NEAREST = 0,
|
||||
INTER_LINEAR = 1,
|
||||
INTER_CUBIC = 2,
|
||||
INTER_AREA = 3,
|
||||
INTER_LANCZOS4 = 4,
|
||||
INTER_LINEAR_EXACT = 5,
|
||||
INTER_MAX = 7,
|
||||
};
|
||||
} // namespace cv
|
||||
|
||||
static inline int cvFloor( double value )
|
||||
{
|
||||
int i = (int)value;
|
||||
return i - (i > value);
|
||||
}
|
||||
|
||||
#endif // defined(GAPI_STANDALONE)
|
||||
|
||||
#endif // OPENCV_GAPI_CV_DEFS_HPP
|
@ -5,15 +5,34 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#ifndef INCLUDE_OPENCV2_GAPI_OWN_MAT_HPP
|
||||
#define INCLUDE_OPENCV2_GAPI_OWN_MAT_HPP
|
||||
#ifndef OPENCV_GAPI_OWN_MAT_HPP
|
||||
#define OPENCV_GAPI_OWN_MAT_HPP
|
||||
|
||||
#include "opencv2/core/cvdef.h"
|
||||
#include "opencv2/gapi/opencv_includes.hpp"
|
||||
#include "opencv2/gapi/own/types.hpp"
|
||||
#include "opencv2/gapi/own/scalar.hpp"
|
||||
#include "opencv2/gapi/own/saturate.hpp"
|
||||
#include "opencv2/gapi/own/assert.hpp"
|
||||
|
||||
#include <memory> //std::shared_ptr
|
||||
#include <cstring> //std::memcpy
|
||||
#include "opencv2/gapi/util/throw.hpp"
|
||||
|
||||
namespace cv { namespace gapi { namespace own {
|
||||
namespace detail {
|
||||
template <typename T, unsigned char channels>
|
||||
void assign_row(void* ptr, int cols, Scalar const& s)
|
||||
{
|
||||
auto p = static_cast<T*>(ptr);
|
||||
for (int c = 0; c < cols; c++)
|
||||
{
|
||||
for (int ch = 0; ch < channels; ch++)
|
||||
{
|
||||
p[c * channels + ch] = saturate<T>(s[ch], roundd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline size_t default_step(int type, int cols)
|
||||
{
|
||||
return CV_ELEM_SIZE(type) * cols;
|
||||
@ -81,12 +100,66 @@ namespace cv { namespace gapi { namespace own {
|
||||
: MatHeader (_rows, _cols, _type, _data, _step)
|
||||
{}
|
||||
|
||||
Mat(Mat const& src, const Rect& roi )
|
||||
: Mat(src)
|
||||
{
|
||||
rows = roi.height;
|
||||
cols = roi.width;
|
||||
data = ptr(roi.y, roi.x);
|
||||
}
|
||||
|
||||
Mat(Mat const& src) = default;
|
||||
Mat(Mat&& src) = default;
|
||||
|
||||
Mat& operator=(Mat const& src) = default;
|
||||
Mat& operator=(Mat&& src) = default;
|
||||
|
||||
/** @brief Sets all or some of the array elements to the specified value.
|
||||
@param s Assigned scalar converted to the actual array type.
|
||||
*/
|
||||
Mat& operator = (const Scalar& s)
|
||||
{
|
||||
static constexpr unsigned max_channels = 4; //Scalar can't fit more than 4
|
||||
GAPI_Assert(static_cast<unsigned int>(channels()) <= max_channels);
|
||||
|
||||
using func_p_t = void (*)(void*, int, Scalar const&);
|
||||
using detail::assign_row;
|
||||
#define TABLE_ENTRY(type) {assign_row<type, 1>, assign_row<type, 2>, assign_row<type, 3>, assign_row<type, 4>}
|
||||
static constexpr func_p_t func_tbl[][max_channels] = {
|
||||
TABLE_ENTRY(uchar),
|
||||
TABLE_ENTRY(schar),
|
||||
TABLE_ENTRY(ushort),
|
||||
TABLE_ENTRY(short),
|
||||
TABLE_ENTRY(int),
|
||||
TABLE_ENTRY(float),
|
||||
TABLE_ENTRY(double)
|
||||
};
|
||||
#undef TABLE_ENTRY
|
||||
|
||||
static_assert(CV_8U == 0 && CV_8S == 1 && CV_16U == 2 && CV_16S == 3
|
||||
&& CV_32S == 4 && CV_32F == 5 && CV_64F == 6,
|
||||
"OCV type ids used as indexes to array, thus exact numbers are important!"
|
||||
);
|
||||
|
||||
GAPI_Assert(static_cast<unsigned int>(depth()) < sizeof(func_tbl)/sizeof(func_tbl[0]));
|
||||
|
||||
for (int r = 0; r < rows; ++r)
|
||||
{
|
||||
auto* f = func_tbl[depth()][channels() -1];
|
||||
(*f)(static_cast<void *>(ptr(r)), cols, s );
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Returns the matrix element size in bytes.
|
||||
|
||||
The method returns the matrix element size in bytes. For example, if the matrix type is CV_16SC3 ,
|
||||
the method returns 3\*sizeof(short) or 6.
|
||||
*/
|
||||
size_t elemSize() const
|
||||
{
|
||||
return CV_ELEM_SIZE(type());
|
||||
}
|
||||
/** @brief Returns the type of a matrix element.
|
||||
|
||||
The method returns a matrix element type. This is an identifier compatible with the CvMat type
|
||||
@ -115,13 +188,22 @@ namespace cv { namespace gapi { namespace own {
|
||||
*/
|
||||
int channels() const {return CV_MAT_CN(flags);}
|
||||
|
||||
/**
|
||||
@param _rows New number of rows.
|
||||
@param _cols New number of columns.
|
||||
@param _type New matrix type.
|
||||
*/
|
||||
void create(int _rows, int _cols, int _type)
|
||||
{
|
||||
create({_cols, _rows}, _type);
|
||||
}
|
||||
/** @overload
|
||||
@param _size Alternative new matrix size specification: Size(cols, rows)
|
||||
@param _type New matrix type.
|
||||
*/
|
||||
void create(cv::gapi::own::Size _size, int _type)
|
||||
void create(Size _size, int _type)
|
||||
{
|
||||
if (_size != cv::gapi::own::Size{cols, rows} )
|
||||
if (_size != Size{cols, rows} )
|
||||
{
|
||||
Mat tmp{_size.height, _size.width, _type, nullptr};
|
||||
tmp.memory.reset(new uchar[ tmp.step * tmp.rows], [](uchar * p){delete[] p;});
|
||||
@ -130,6 +212,71 @@ namespace cv { namespace gapi { namespace own {
|
||||
*this = std::move(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
/** @brief Copies the matrix to another one.
|
||||
|
||||
The method copies the matrix data to another matrix. Before copying the data, the method invokes :
|
||||
@code
|
||||
m.create(this->size(), this->type());
|
||||
@endcode
|
||||
so that the destination matrix is reallocated if needed. While m.copyTo(m); works flawlessly, the
|
||||
function does not handle the case of a partial overlap between the source and the destination
|
||||
matrices.
|
||||
*/
|
||||
void copyTo(Mat& dst) const
|
||||
{
|
||||
dst.create(rows, cols, type());
|
||||
for (int r = 0; r < rows; ++r)
|
||||
{
|
||||
std::memcpy(dst.ptr(r), ptr(r), detail::default_step(type(),cols));
|
||||
}
|
||||
}
|
||||
|
||||
/** @brief Returns true if the array has no elements.
|
||||
|
||||
The method returns true if Mat::total() is 0 or if Mat::data is NULL. Because of pop_back() and
|
||||
resize() methods `M.total() == 0` does not imply that `M.data == NULL`.
|
||||
*/
|
||||
bool empty() const;
|
||||
|
||||
/** @brief Returns the total number of array elements.
|
||||
|
||||
The method returns the number of array elements (a number of pixels if the array represents an
|
||||
image).
|
||||
*/
|
||||
size_t total() const
|
||||
{
|
||||
return static_cast<size_t>(rows * cols);
|
||||
}
|
||||
|
||||
|
||||
/** @overload
|
||||
@param roi Extracted submatrix specified as a rectangle.
|
||||
*/
|
||||
Mat operator()( const Rect& roi ) const
|
||||
{
|
||||
return Mat{*this, roi};
|
||||
}
|
||||
|
||||
|
||||
/** @brief Returns a pointer to the specified matrix row.
|
||||
|
||||
The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in
|
||||
Mat::isContinuous to know how to use these methods.
|
||||
@param row Index along the dimension 0
|
||||
@param col Index along the dimension 1
|
||||
*/
|
||||
uchar* ptr(int row, int col = 0)
|
||||
{
|
||||
return const_cast<uchar*>(const_cast<const Mat*>(this)->ptr(row,col));
|
||||
}
|
||||
/** @overload */
|
||||
const uchar* ptr(int row, int col = 0) const
|
||||
{
|
||||
return data + step * row + CV_ELEM_SIZE(type()) * col;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
//actual memory allocated for storage, or nullptr if object is non owning view to over memory
|
||||
std::shared_ptr<uchar> memory;
|
||||
@ -139,4 +286,4 @@ namespace cv { namespace gapi { namespace own {
|
||||
} //namespace gapi
|
||||
} //namespace cv
|
||||
|
||||
#endif /* INCLUDE_OPENCV2_GAPI_OWN_MAT_HPP */
|
||||
#endif /* OPENCV_GAPI_OWN_MAT_HPP */
|
||||
|
88
modules/gapi/include/opencv2/gapi/own/saturate.hpp
Normal file
88
modules/gapi/include/opencv2/gapi/own/saturate.hpp
Normal file
@ -0,0 +1,88 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#ifndef OPENCV_GAPI_OWN_SATURATE_HPP
|
||||
#define OPENCV_GAPI_OWN_SATURATE_HPP
|
||||
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
#include <opencv2/gapi/own/assert.hpp>
|
||||
|
||||
namespace cv { namespace gapi { namespace own {
|
||||
//-----------------------------
|
||||
//
|
||||
// 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
|
||||
inline double ceild(double x) { return std::ceil(x); }
|
||||
inline double floord(double x) { return std::floor(x); }
|
||||
inline double roundd(double x) { return std::round(x); }
|
||||
inline double rintd(double x) { return std::rint(x); }
|
||||
|
||||
} //namespace own
|
||||
} //namespace gapi
|
||||
} //namespace cv
|
||||
#endif /* OPENCV_GAPI_OWN_SATURATE_HPP */
|
@ -8,6 +8,8 @@
|
||||
#ifndef OPENCV_GAPI_GAPI_OWN_SCALAR_HPP
|
||||
#define OPENCV_GAPI_GAPI_OWN_SCALAR_HPP
|
||||
|
||||
#include <opencv2/gapi/own/exports.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace gapi
|
||||
@ -15,7 +17,7 @@ namespace gapi
|
||||
namespace own
|
||||
{
|
||||
|
||||
class CV_EXPORTS Scalar
|
||||
class GAPI_EXPORTS Scalar
|
||||
{
|
||||
public:
|
||||
Scalar() = default;
|
||||
|
@ -9,9 +9,7 @@
|
||||
#define OPENCV_GAPI_TYPES_HPP
|
||||
|
||||
#include <algorithm> // std::max, std::min
|
||||
|
||||
#include "opencv2/core/base.hpp" //for CV_DbgAssert
|
||||
#include "opencv2/gapi/own/assert.hpp"
|
||||
#include <ostream>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
@ -35,7 +33,7 @@ class Rect
|
||||
public:
|
||||
Rect() = default;
|
||||
Rect(int _x, int _y, int _width, int _height) : x(_x), y(_y), width(_width), height(_height) {};
|
||||
#if 1
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
Rect(const cv::Rect& other) : x(other.x), y(other.y), width(other.width), height(other.height) {};
|
||||
inline Rect& operator=(const cv::Rect& other)
|
||||
{
|
||||
@ -45,7 +43,7 @@ public:
|
||||
height = other.height;
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
int x = 0; //!< x coordinate of the top-left corner
|
||||
int y = 0; //!< y coordinate of the top-left corner
|
||||
@ -92,7 +90,7 @@ class Size
|
||||
public:
|
||||
Size() = default;
|
||||
Size(int _width, int _height) : width(_width), height(_height) {};
|
||||
#if 1
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
Size(const cv::Size& other) : width(other.width), height(other.height) {};
|
||||
inline Size& operator=(const cv::Size& rhs)
|
||||
{
|
||||
@ -100,7 +98,7 @@ public:
|
||||
height = rhs.height;
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
|
@ -97,6 +97,12 @@ namespace util
|
||||
template<class value_t>
|
||||
friend const value_t* any_cast(const any* operand);
|
||||
|
||||
template<class value_t>
|
||||
friend value_t& unsafe_any_cast(any& operand);
|
||||
|
||||
template<class value_t>
|
||||
friend const value_t& unsafe_any_cast(const any& operand);
|
||||
|
||||
friend void swap(any & lhs, any& rhs)
|
||||
{
|
||||
swap(lhs.hldr, rhs.hldr);
|
||||
@ -148,6 +154,27 @@ namespace util
|
||||
|
||||
throw_error(bad_any_cast());
|
||||
}
|
||||
|
||||
template<class value_t>
|
||||
inline value_t& unsafe_any_cast(any& operand)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
return any_cast<value_t>(operand);
|
||||
#else
|
||||
return static_cast<any::holder_impl<typename std::decay<value_t>::type> *>(operand.hldr.get())->v;
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class value_t>
|
||||
inline const value_t& unsafe_any_cast(const any& operand)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
return any_cast<value_t>(operand);
|
||||
#else
|
||||
return static_cast<any::holder_impl<typename std::decay<value_t>::type> *>(operand.hldr.get())->v;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace cv
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "../common/gapi_core_perf_tests.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
|
@ -5,6 +5,7 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "../common/gapi_imgproc_perf_tests.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
|
@ -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,7 +398,7 @@ const uint8_t* fluid::ViewPrivWithoutOwnBorder::InLineB(int index) const
|
||||
|
||||
const auto &p_priv = m_p->priv();
|
||||
|
||||
CV_Assert( index >= -m_border_size
|
||||
GAPI_DbgAssert(index >= -m_border_size
|
||||
&& index < -m_border_size + m_lines_next_iter);
|
||||
|
||||
const int log_idx = m_read_caret + index;
|
||||
@ -439,8 +446,7 @@ 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
|
||||
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(),
|
||||
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
|
||||
#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
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
|
||||
#endif // __OPENCV_GAPI_LOGGER_HPP__
|
||||
|
@ -8,12 +8,14 @@
|
||||
#ifndef __OPENCV_GAPI_PRECOMP_HPP__
|
||||
#define __OPENCV_GAPI_PRECOMP_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__
|
||||
|
@ -5,4 +5,5 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "gapi_core_tests_inl.hpp"
|
||||
|
@ -5,4 +5,5 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "gapi_imgproc_tests_inl.hpp"
|
||||
|
@ -5,4 +5,5 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "gapi_operators_tests_inl.hpp"
|
||||
|
@ -5,6 +5,7 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "../common/gapi_operators_tests.hpp"
|
||||
#include "opencv2/gapi/cpu/core.hpp"
|
||||
|
||||
|
@ -50,7 +50,7 @@ TEST(FluidBuffer, InputTest)
|
||||
const cv::Size buffer_size = {8,8};
|
||||
cv::Mat in_mat = cv::Mat::eye(buffer_size, CV_8U);
|
||||
|
||||
cv::gapi::fluid::Buffer buffer(in_mat, true);
|
||||
cv::gapi::fluid::Buffer buffer(to_own(in_mat), true);
|
||||
cv::gapi::fluid::View view = buffer.mkView(1, 0, {}, false);
|
||||
view.priv().reset(1);
|
||||
int this_y = 0;
|
||||
@ -152,7 +152,7 @@ TEST(FluidBuffer, OutputTest)
|
||||
const cv::Size buffer_size = {8,16};
|
||||
cv::Mat out_mat = cv::Mat(buffer_size, CV_8U);
|
||||
|
||||
cv::gapi::fluid::Buffer buffer(out_mat, false);
|
||||
cv::gapi::fluid::Buffer buffer(to_own(out_mat), false);
|
||||
int num_writes = 0;
|
||||
while (num_writes < buffer_size.height)
|
||||
{
|
||||
@ -417,7 +417,7 @@ TEST(Fluid, MultipleReaders_DifferentLatency)
|
||||
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
|
||||
}
|
||||
|
||||
TEST(Fluid, DISABLED_MultipleOutputs)
|
||||
TEST(Fluid, MultipleOutputs)
|
||||
{
|
||||
// in -> AddC -> a -> AddC ------------------> out1
|
||||
// `--> Id7x7 --> b --> AddC -> out2
|
||||
@ -464,7 +464,7 @@ TEST(Fluid, EmptyOutputMatTest)
|
||||
}
|
||||
|
||||
struct LPISequenceTest : public TestWithParam<int>{};
|
||||
TEST_P(LPISequenceTest, DISABLED_LPISequenceTest)
|
||||
TEST_P(LPISequenceTest, LPISequenceTest)
|
||||
{
|
||||
// in -> AddC -> a -> Blur (2lpi) -> out
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
//
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
#include <iomanip>
|
||||
#include "gapi_fluid_test_kernels.hpp"
|
||||
#include <opencv2/gapi/core.hpp>
|
||||
|
@ -33,12 +33,46 @@ TEST(OwnMat, Create)
|
||||
ASSERT_NE(m.data, nullptr);
|
||||
ASSERT_EQ((cv::gapi::own::Size{m.cols, m.rows}), size);
|
||||
|
||||
ASSERT_EQ(m.total(), static_cast<size_t>(size.height*size.width));
|
||||
ASSERT_EQ(m.type(), CV_8UC1);
|
||||
ASSERT_EQ(m.depth(), CV_8U);
|
||||
ASSERT_EQ(m.channels(), 1);
|
||||
ASSERT_EQ(m.elemSize(), sizeof(uint8_t));
|
||||
ASSERT_EQ(m.step, sizeof(uint8_t) * m.cols);
|
||||
}
|
||||
|
||||
TEST(OwnMat, CreateOverload)
|
||||
{
|
||||
auto size = cv::gapi::own::Size{32,16};
|
||||
Mat m;
|
||||
m.create(size.height,size.width, CV_8UC1);
|
||||
|
||||
ASSERT_NE(m.data, nullptr);
|
||||
ASSERT_EQ((cv::Size{m.cols, m.rows}), size);
|
||||
|
||||
ASSERT_EQ(m.total(), static_cast<size_t>(size.height*size.width));
|
||||
ASSERT_EQ(m.type(), CV_8UC1);
|
||||
ASSERT_EQ(m.depth(), CV_8U);
|
||||
ASSERT_EQ(m.channels(), 1);
|
||||
ASSERT_EQ(m.elemSize(), sizeof(uint8_t));
|
||||
ASSERT_EQ(m.step, sizeof(uint8_t) * m.cols);
|
||||
}
|
||||
TEST(OwnMat, Create3chan)
|
||||
{
|
||||
auto size = cv::Size{32,16};
|
||||
Mat m;
|
||||
m.create(size, CV_8UC3);
|
||||
|
||||
ASSERT_NE(m.data, nullptr);
|
||||
ASSERT_EQ((cv::Size{m.cols, m.rows}), size);
|
||||
|
||||
ASSERT_EQ(m.type(), CV_8UC3);
|
||||
ASSERT_EQ(m.depth(), CV_8U);
|
||||
ASSERT_EQ(m.channels(), 3);
|
||||
ASSERT_EQ(m.elemSize(), 3 * sizeof(uint8_t));
|
||||
ASSERT_EQ(m.step, 3* sizeof(uint8_t) * m.cols);
|
||||
}
|
||||
|
||||
struct NonEmptyMat {
|
||||
cv::gapi::own::Size size{32,16};
|
||||
Mat m;
|
||||
@ -160,5 +194,194 @@ TEST(OwnMatConversion, WithStep)
|
||||
<< (cvMat != cvMatFromOwn);
|
||||
}
|
||||
|
||||
TEST(OwnMat, PtrWithStep)
|
||||
{
|
||||
constexpr int width = 8;
|
||||
constexpr int height = 8;
|
||||
constexpr int stepInPixels = 16;
|
||||
|
||||
std::array<int, height * stepInPixels> data;
|
||||
for (size_t i = 0; i < data.size(); i++)
|
||||
{
|
||||
data[i] = static_cast<int>(i);
|
||||
}
|
||||
Mat mat(height, width, CV_32S, data.data(), stepInPixels * sizeof(int));
|
||||
|
||||
EXPECT_EQ(& data[0], reinterpret_cast<int*>(mat.ptr(0)));
|
||||
EXPECT_EQ(& data[1], reinterpret_cast<int*>(mat.ptr(0, 1)));
|
||||
EXPECT_EQ(& data[stepInPixels], reinterpret_cast<int*>(mat.ptr(1)));
|
||||
EXPECT_EQ(& data[stepInPixels +1], reinterpret_cast<int*>(mat.ptr(1,1)));
|
||||
|
||||
auto const& cmat = mat;
|
||||
|
||||
EXPECT_EQ(& data[0], reinterpret_cast<const int*>(cmat.ptr(0)));
|
||||
EXPECT_EQ(& data[1], reinterpret_cast<const int*>(cmat.ptr(0, 1)));
|
||||
EXPECT_EQ(& data[stepInPixels], reinterpret_cast<const int*>(cmat.ptr(1)));
|
||||
EXPECT_EQ(& data[stepInPixels +1], reinterpret_cast<const int*>(cmat.ptr(1,1)));
|
||||
}
|
||||
|
||||
TEST(OwnMat, CopyToWithStep)
|
||||
{
|
||||
constexpr int width = 8;
|
||||
constexpr int height = 8;
|
||||
constexpr int stepInPixels = 16;
|
||||
|
||||
std::array<int, height * stepInPixels> data;
|
||||
for (size_t i = 0; i < data.size(); i++)
|
||||
{
|
||||
data[i] = static_cast<int>(i);
|
||||
}
|
||||
Mat mat(height, width, CV_32S, data.data(), stepInPixels * sizeof(int));
|
||||
|
||||
Mat dst;
|
||||
mat.copyTo(dst);
|
||||
|
||||
EXPECT_NE(mat.data, dst.data);
|
||||
EXPECT_EQ(0, cv::countNonZero(to_ocv(mat) != to_ocv(dst)))
|
||||
<< to_ocv(mat) << std::endl
|
||||
<< (to_ocv(mat) != to_ocv(dst));
|
||||
}
|
||||
|
||||
TEST(OwnMat, ScalarAssign32SC1)
|
||||
{
|
||||
constexpr int width = 8;
|
||||
constexpr int height = 8;
|
||||
constexpr int stepInPixels = 16;
|
||||
|
||||
std::array<int, height * stepInPixels> data;
|
||||
for (size_t i = 0; i < data.size(); i++)
|
||||
{
|
||||
data[i] = static_cast<int>(i);
|
||||
}
|
||||
Mat mat(height, width, CV_32S, data.data(), stepInPixels * sizeof(data[0]));
|
||||
|
||||
mat = cv::gapi::own::Scalar{-1};
|
||||
|
||||
std::array<int, height * stepInPixels> expected;
|
||||
|
||||
for (size_t row = 0; row < height; row++)
|
||||
{
|
||||
for (size_t col = 0; col < stepInPixels; col++)
|
||||
{
|
||||
auto index = row*stepInPixels + col;
|
||||
expected[index] = col < width ? -1 : static_cast<int>(index);
|
||||
}
|
||||
}
|
||||
|
||||
auto cmp_result_mat = (cv::Mat{height, stepInPixels, CV_32S, data.data()} != cv::Mat{height, stepInPixels, CV_32S, expected.data()});
|
||||
EXPECT_EQ(0, cv::countNonZero(cmp_result_mat))
|
||||
<< cmp_result_mat << std::endl;
|
||||
}
|
||||
|
||||
TEST(OwnMat, ScalarAssign8UC1)
|
||||
{
|
||||
constexpr int width = 8;
|
||||
constexpr int height = 8;
|
||||
constexpr int stepInPixels = 16;
|
||||
|
||||
std::array<uchar, height * stepInPixels> data;
|
||||
for (size_t i = 0; i < data.size(); i++)
|
||||
{
|
||||
data[i] = static_cast<uchar>(i);
|
||||
}
|
||||
Mat mat(height, width, CV_8U, data.data(), stepInPixels * sizeof(data[0]));
|
||||
|
||||
mat = cv::gapi::own::Scalar{-1};
|
||||
|
||||
std::array<uchar, height * stepInPixels> expected;
|
||||
|
||||
for (size_t row = 0; row < height; row++)
|
||||
{
|
||||
for (size_t col = 0; col < stepInPixels; col++)
|
||||
{
|
||||
auto index = row*stepInPixels + col;
|
||||
expected[index] = col < width ? cv::saturate_cast<uchar>(-1) : static_cast<uchar>(index);
|
||||
}
|
||||
}
|
||||
|
||||
auto cmp_result_mat = (cv::Mat{height, stepInPixels, CV_8U, data.data()} != cv::Mat{height, stepInPixels, CV_8U, expected.data()});
|
||||
EXPECT_EQ(0, cv::countNonZero(cmp_result_mat))
|
||||
<< cmp_result_mat << std::endl;
|
||||
}
|
||||
|
||||
TEST(OwnMat, ScalarAssign8UC3)
|
||||
{
|
||||
constexpr auto cv_type = CV_8SC3;
|
||||
constexpr int channels = 3;
|
||||
constexpr int width = 8;
|
||||
constexpr int height = 8;
|
||||
constexpr int stepInPixels = 16;
|
||||
|
||||
std::array<schar, height * stepInPixels * channels> data;
|
||||
for (size_t i = 0; i < data.size(); i+= channels)
|
||||
{
|
||||
data[i + 0] = static_cast<schar>(10 * i + 0);
|
||||
data[i + 1] = static_cast<schar>(10 * i + 1);
|
||||
data[i + 2] = static_cast<schar>(10 * i + 2);
|
||||
}
|
||||
|
||||
Mat mat(height, width, cv_type, data.data(), channels * stepInPixels * sizeof(data[0]));
|
||||
|
||||
mat = cv::gapi::own::Scalar{-10, -11, -12};
|
||||
|
||||
std::array<schar, data.size()> expected;
|
||||
|
||||
for (size_t row = 0; row < height; row++)
|
||||
{
|
||||
for (size_t col = 0; col < stepInPixels; col++)
|
||||
{
|
||||
int index = static_cast<int>(channels * (row*stepInPixels + col));
|
||||
expected[index + 0] = static_cast<schar>(col < width ? -10 : 10 * index + 0);
|
||||
expected[index + 1] = static_cast<schar>(col < width ? -11 : 10 * index + 1);
|
||||
expected[index + 2] = static_cast<schar>(col < width ? -12 : 10 * index + 2);
|
||||
}
|
||||
}
|
||||
|
||||
auto cmp_result_mat = (cv::Mat{height, stepInPixels, cv_type, data.data()} != cv::Mat{height, stepInPixels, cv_type, expected.data()});
|
||||
EXPECT_EQ(0, cv::countNonZero(cmp_result_mat))
|
||||
<< cmp_result_mat << std::endl
|
||||
<< "data : " << std::endl
|
||||
<< cv::Mat{height, stepInPixels, cv_type, data.data()} << std::endl
|
||||
<< "expected : " << std::endl
|
||||
<< cv::Mat{height, stepInPixels, cv_type, expected.data()} << std::endl;
|
||||
}
|
||||
|
||||
TEST(OwnMat, ROIView)
|
||||
{
|
||||
constexpr int width = 8;
|
||||
constexpr int height = 8;
|
||||
constexpr int stepInPixels = 16;
|
||||
|
||||
std::array<uchar, height * stepInPixels> data;
|
||||
for (size_t i = 0; i < data.size(); i++)
|
||||
{
|
||||
data[i] = static_cast<uchar>(i);
|
||||
}
|
||||
|
||||
|
||||
// std::cout<<cv::Mat{height, stepInPixels, CV_8U, data.data()}<<std::endl;
|
||||
|
||||
std::array<uchar, 4 * 4> expected;
|
||||
|
||||
for (size_t row = 0; row < 4; row++)
|
||||
{
|
||||
for (size_t col = 0; col < 4; col++)
|
||||
{
|
||||
expected[row*4 +col] = static_cast<uchar>(stepInPixels * (2 + row) + 2 + col);
|
||||
}
|
||||
}
|
||||
|
||||
Mat mat(height, width, CV_8U, data.data(), stepInPixels * sizeof(data[0]));
|
||||
Mat roi_view (mat, cv::gapi::own::Rect{2,2,4,4});
|
||||
|
||||
// std::cout<<cv::Mat{4, 4, CV_8U, expected.data()}<<std::endl;
|
||||
//
|
||||
auto expected_cv_mat = cv::Mat{4, 4, CV_8U, expected.data()};
|
||||
|
||||
auto cmp_result_mat = (to_ocv(roi_view) != expected_cv_mat);
|
||||
EXPECT_EQ(0, cv::countNonZero(cmp_result_mat))
|
||||
<< cmp_result_mat << std::endl
|
||||
<< to_ocv(roi_view) << std::endl
|
||||
<< expected_cv_mat << std::endl;
|
||||
}
|
||||
} // namespace opencv_test
|
||||
|
Loading…
Reference in New Issue
Block a user