mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
Merge pull request #12310 from cv3d:chunks/enum_interface
* Cleanup macros and enable expansion of `__VA_ARGS__` for Visual Studio * Macros for enum-arguments backwards compatibility * Convert struct Param to enum struct * Enabled ParamType.type for enum types * Enabled `cv.read` and `cv.write` for enum types * Rename unnamed enum to AAKAZE.DescriptorType * Rename unnamed enum to AccessFlag * Rename unnamed enum to AgastFeatureDetector.DetectorType * Convert struct DrawMatchesFlags to enum struct * Rename unnamed enum to FastFeatureDetector.DetectorType * Rename unnamed enum to Formatter.FormatType * Rename unnamed enum to HOGDescriptor.HistogramNormType * Rename unnamed enum to DescriptorMatcher.MatcherType * Rename unnamed enum to KAZE.DiffusivityType * Rename unnamed enum to ORB.ScoreType * Rename unnamed enum to UMatData.MemoryFlag * Rename unnamed enum to _InputArray.KindFlag * Rename unnamed enum to _OutputArray.DepthMask * Convert normType enums to static const NormTypes * Avoid conflicts with ElemType * Rename unnamed enum to DescriptorStorageFormat
This commit is contained in:
committed by
Alexander Alekhin
parent
84ae8097b1
commit
ef5579dc86
@@ -2997,7 +2997,8 @@ public:
|
||||
class CV_EXPORTS Formatter
|
||||
{
|
||||
public:
|
||||
enum { FMT_DEFAULT = 0,
|
||||
enum FormatType {
|
||||
FMT_DEFAULT = 0,
|
||||
FMT_MATLAB = 1,
|
||||
FMT_CSV = 2,
|
||||
FMT_PYTHON = 3,
|
||||
@@ -3014,7 +3015,7 @@ public:
|
||||
virtual void set64fPrecision(int p = 16) = 0;
|
||||
virtual void setMultiline(bool ml = true) = 0;
|
||||
|
||||
static Ptr<Formatter> get(int fmt = FMT_DEFAULT);
|
||||
static Ptr<Formatter> get(Formatter::FormatType fmt = FMT_DEFAULT);
|
||||
|
||||
};
|
||||
|
||||
@@ -3037,7 +3038,7 @@ String& operator << (String& out, const Mat& mtx)
|
||||
|
||||
class CV_EXPORTS Algorithm;
|
||||
|
||||
template<typename _Tp> struct ParamType {};
|
||||
template<typename _Tp, typename _EnumTp = void> struct ParamType {};
|
||||
|
||||
|
||||
/** @brief This is a base class for all more or less complex algorithms in OpenCV
|
||||
@@ -3150,9 +3151,9 @@ protected:
|
||||
void writeFormat(FileStorage& fs) const;
|
||||
};
|
||||
|
||||
struct Param {
|
||||
enum { INT=0, BOOLEAN=1, REAL=2, STRING=3, MAT=4, MAT_VECTOR=5, ALGORITHM=6, FLOAT=7,
|
||||
UNSIGNED_INT=8, UINT64=9, UCHAR=11, SCALAR=12 };
|
||||
enum struct Param {
|
||||
INT=0, BOOLEAN=1, REAL=2, STRING=3, MAT=4, MAT_VECTOR=5, ALGORITHM=6, FLOAT=7,
|
||||
UNSIGNED_INT=8, UINT64=9, UCHAR=11, SCALAR=12
|
||||
};
|
||||
|
||||
|
||||
@@ -3162,7 +3163,7 @@ template<> struct ParamType<bool>
|
||||
typedef bool const_param_type;
|
||||
typedef bool member_type;
|
||||
|
||||
enum { type = Param::BOOLEAN };
|
||||
static const Param type = Param::BOOLEAN;
|
||||
};
|
||||
|
||||
template<> struct ParamType<int>
|
||||
@@ -3170,7 +3171,7 @@ template<> struct ParamType<int>
|
||||
typedef int const_param_type;
|
||||
typedef int member_type;
|
||||
|
||||
enum { type = Param::INT };
|
||||
static const Param type = Param::INT;
|
||||
};
|
||||
|
||||
template<> struct ParamType<double>
|
||||
@@ -3178,7 +3179,7 @@ template<> struct ParamType<double>
|
||||
typedef double const_param_type;
|
||||
typedef double member_type;
|
||||
|
||||
enum { type = Param::REAL };
|
||||
static const Param type = Param::REAL;
|
||||
};
|
||||
|
||||
template<> struct ParamType<String>
|
||||
@@ -3186,7 +3187,7 @@ template<> struct ParamType<String>
|
||||
typedef const String& const_param_type;
|
||||
typedef String member_type;
|
||||
|
||||
enum { type = Param::STRING };
|
||||
static const Param type = Param::STRING;
|
||||
};
|
||||
|
||||
template<> struct ParamType<Mat>
|
||||
@@ -3194,7 +3195,7 @@ template<> struct ParamType<Mat>
|
||||
typedef const Mat& const_param_type;
|
||||
typedef Mat member_type;
|
||||
|
||||
enum { type = Param::MAT };
|
||||
static const Param type = Param::MAT;
|
||||
};
|
||||
|
||||
template<> struct ParamType<std::vector<Mat> >
|
||||
@@ -3202,7 +3203,7 @@ template<> struct ParamType<std::vector<Mat> >
|
||||
typedef const std::vector<Mat>& const_param_type;
|
||||
typedef std::vector<Mat> member_type;
|
||||
|
||||
enum { type = Param::MAT_VECTOR };
|
||||
static const Param type = Param::MAT_VECTOR;
|
||||
};
|
||||
|
||||
template<> struct ParamType<Algorithm>
|
||||
@@ -3210,7 +3211,7 @@ template<> struct ParamType<Algorithm>
|
||||
typedef const Ptr<Algorithm>& const_param_type;
|
||||
typedef Ptr<Algorithm> member_type;
|
||||
|
||||
enum { type = Param::ALGORITHM };
|
||||
static const Param type = Param::ALGORITHM;
|
||||
};
|
||||
|
||||
template<> struct ParamType<float>
|
||||
@@ -3218,7 +3219,7 @@ template<> struct ParamType<float>
|
||||
typedef float const_param_type;
|
||||
typedef float member_type;
|
||||
|
||||
enum { type = Param::FLOAT };
|
||||
static const Param type = Param::FLOAT;
|
||||
};
|
||||
|
||||
template<> struct ParamType<unsigned>
|
||||
@@ -3226,7 +3227,7 @@ template<> struct ParamType<unsigned>
|
||||
typedef unsigned const_param_type;
|
||||
typedef unsigned member_type;
|
||||
|
||||
enum { type = Param::UNSIGNED_INT };
|
||||
static const Param type = Param::UNSIGNED_INT;
|
||||
};
|
||||
|
||||
template<> struct ParamType<uint64>
|
||||
@@ -3234,7 +3235,7 @@ template<> struct ParamType<uint64>
|
||||
typedef uint64 const_param_type;
|
||||
typedef uint64 member_type;
|
||||
|
||||
enum { type = Param::UINT64 };
|
||||
static const Param type = Param::UINT64;
|
||||
};
|
||||
|
||||
template<> struct ParamType<uchar>
|
||||
@@ -3242,7 +3243,7 @@ template<> struct ParamType<uchar>
|
||||
typedef uchar const_param_type;
|
||||
typedef uchar member_type;
|
||||
|
||||
enum { type = Param::UCHAR };
|
||||
static const Param type = Param::UCHAR;
|
||||
};
|
||||
|
||||
template<> struct ParamType<Scalar>
|
||||
@@ -3250,7 +3251,16 @@ template<> struct ParamType<Scalar>
|
||||
typedef const Scalar& const_param_type;
|
||||
typedef Scalar member_type;
|
||||
|
||||
enum { type = Param::SCALAR };
|
||||
static const Param type = Param::SCALAR;
|
||||
};
|
||||
|
||||
template<typename _Tp>
|
||||
struct ParamType<_Tp, typename std::enable_if< std::is_enum<_Tp>::value >::type>
|
||||
{
|
||||
typedef typename std::underlying_type<_Tp>::type const_param_type;
|
||||
typedef typename std::underlying_type<_Tp>::type member_type;
|
||||
|
||||
static const Param type = Param::INT;
|
||||
};
|
||||
|
||||
//! @} core_basic
|
||||
|
||||
@@ -440,17 +440,17 @@ configurations while CV_DbgAssert is only retained in the Debug configuration.
|
||||
#endif
|
||||
|
||||
#define CV_Assert_1 CV_Assert
|
||||
#define CV_Assert_2( expr1, expr2 ) CV_Assert_1(expr1); CV_Assert_1(expr2)
|
||||
#define CV_Assert_3( expr1, expr2, expr3 ) CV_Assert_2(expr1, expr2); CV_Assert_1(expr3)
|
||||
#define CV_Assert_4( expr1, expr2, expr3, expr4 ) CV_Assert_3(expr1, expr2, expr3); CV_Assert_1(expr4)
|
||||
#define CV_Assert_5( expr1, expr2, expr3, expr4, expr5 ) CV_Assert_4(expr1, expr2, expr3, expr4); CV_Assert_1(expr5)
|
||||
#define CV_Assert_6( expr1, expr2, expr3, expr4, expr5, expr6 ) CV_Assert_5(expr1, expr2, expr3, expr4, expr5); CV_Assert_1(expr6)
|
||||
#define CV_Assert_7( expr1, expr2, expr3, expr4, expr5, expr6, expr7 ) CV_Assert_6(expr1, expr2, expr3, expr4, expr5, expr6 ); CV_Assert_1(expr7)
|
||||
#define CV_Assert_8( expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8 ) CV_Assert_7(expr1, expr2, expr3, expr4, expr5, expr6, expr7 ); CV_Assert_1(expr8)
|
||||
#define CV_Assert_9( expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8, expr9 ) CV_Assert_8(expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8 ); CV_Assert_1(expr9)
|
||||
#define CV_Assert_10( expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8, expr9, expr10 ) CV_Assert_9(expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8, expr9 ); CV_Assert_1(expr10)
|
||||
#define CV_Assert_2( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_1( __VA_ARGS__ ))
|
||||
#define CV_Assert_3( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_2( __VA_ARGS__ ))
|
||||
#define CV_Assert_4( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_3( __VA_ARGS__ ))
|
||||
#define CV_Assert_5( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_4( __VA_ARGS__ ))
|
||||
#define CV_Assert_6( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_5( __VA_ARGS__ ))
|
||||
#define CV_Assert_7( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_6( __VA_ARGS__ ))
|
||||
#define CV_Assert_8( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_7( __VA_ARGS__ ))
|
||||
#define CV_Assert_9( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_8( __VA_ARGS__ ))
|
||||
#define CV_Assert_10( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_9( __VA_ARGS__ ))
|
||||
|
||||
#define CV_Assert_N(...) do { __CV_CAT(CV_Assert_, __CV_VA_NUM_ARGS(__VA_ARGS__)) (__VA_ARGS__); } while(0)
|
||||
#define CV_Assert_N(...) do { __CV_EXPAND(__CV_CAT(CV_Assert_, __CV_VA_NUM_ARGS(__VA_ARGS__)) (__VA_ARGS__)); } while(0)
|
||||
|
||||
//! @endcond
|
||||
|
||||
@@ -467,7 +467,7 @@ configurations while CV_DbgAssert is only retained in the Debug configuration.
|
||||
*/
|
||||
struct CV_EXPORTS Hamming
|
||||
{
|
||||
enum { normType = NORM_HAMMING };
|
||||
static const NormTypes normType = NORM_HAMMING;
|
||||
typedef unsigned char ValueType;
|
||||
typedef int ResultType;
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace cv { namespace debug_build_guard { } using namespace debug_build_guard
|
||||
#endif
|
||||
|
||||
#define __CV_VA_NUM_ARGS_HELPER(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
|
||||
#define __CV_VA_NUM_ARGS(...) __CV_VA_NUM_ARGS_HELPER(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
|
||||
#define __CV_VA_NUM_ARGS(...) __CV_EXPAND(__CV_VA_NUM_ARGS_HELPER(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0))
|
||||
|
||||
// undef problematic defines sometimes defined by system headers (windows.h in particular)
|
||||
#undef small
|
||||
@@ -330,6 +330,142 @@ Cv64suf;
|
||||
# define MAX(a,b) ((a) < (b) ? (b) : (a))
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////// Enum operators ///////////////////////////////////////
|
||||
|
||||
/**
|
||||
|
||||
Provides compatibility operators for both classical and C++11 enum classes,
|
||||
as well as exposing the C++11 enum class members for backwards compatibility
|
||||
|
||||
@code
|
||||
// Provides operators required for flag enums
|
||||
CV_ENUM_FLAGS(AccessFlag);
|
||||
|
||||
// Exposes the listed members of the enum class AccessFlag to the current namespace
|
||||
CV_ENUM_CLASS_EXPOSE(AccessFlag, ACCESS_READ [, ACCESS_WRITE [, ...] ]);
|
||||
@endcode
|
||||
*/
|
||||
|
||||
#define __CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST) \
|
||||
static const EnumType MEMBER_CONST = EnumType::MEMBER_CONST; \
|
||||
|
||||
#define __CV_ENUM_CLASS_EXPOSE_2(EnumType, MEMBER_CONST, ...) \
|
||||
__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
|
||||
__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_1(EnumType, __VA_ARGS__)); \
|
||||
|
||||
#define __CV_ENUM_CLASS_EXPOSE_3(EnumType, MEMBER_CONST, ...) \
|
||||
__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
|
||||
__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_2(EnumType, __VA_ARGS__)); \
|
||||
|
||||
#define __CV_ENUM_CLASS_EXPOSE_4(EnumType, MEMBER_CONST, ...) \
|
||||
__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
|
||||
__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_3(EnumType, __VA_ARGS__)); \
|
||||
|
||||
#define __CV_ENUM_CLASS_EXPOSE_5(EnumType, MEMBER_CONST, ...) \
|
||||
__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
|
||||
__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_4(EnumType, __VA_ARGS__)); \
|
||||
|
||||
#define __CV_ENUM_CLASS_EXPOSE_6(EnumType, MEMBER_CONST, ...) \
|
||||
__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
|
||||
__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_5(EnumType, __VA_ARGS__)); \
|
||||
|
||||
#define __CV_ENUM_CLASS_EXPOSE_7(EnumType, MEMBER_CONST, ...) \
|
||||
__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
|
||||
__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_6(EnumType, __VA_ARGS__)); \
|
||||
|
||||
#define __CV_ENUM_CLASS_EXPOSE_8(EnumType, MEMBER_CONST, ...) \
|
||||
__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
|
||||
__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_7(EnumType, __VA_ARGS__)); \
|
||||
|
||||
#define __CV_ENUM_CLASS_EXPOSE_9(EnumType, MEMBER_CONST, ...) \
|
||||
__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
|
||||
__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_8(EnumType, __VA_ARGS__)); \
|
||||
|
||||
#define __CV_ENUM_FLAGS_LOGICAL_NOT(EnumType) \
|
||||
static inline bool operator!(const EnumType& val) \
|
||||
{ \
|
||||
typedef std::underlying_type<EnumType>::type UnderlyingType; \
|
||||
return !static_cast<UnderlyingType>(val); \
|
||||
} \
|
||||
|
||||
#define __CV_ENUM_FLAGS_LOGICAL_NOT_EQ(Arg1Type, Arg2Type) \
|
||||
static inline bool operator!=(const Arg1Type& a, const Arg2Type& b) \
|
||||
{ \
|
||||
return static_cast<int>(a) != static_cast<int>(b); \
|
||||
} \
|
||||
|
||||
#define __CV_ENUM_FLAGS_LOGICAL_EQ(Arg1Type, Arg2Type) \
|
||||
static inline bool operator==(const Arg1Type& a, const Arg2Type& b) \
|
||||
{ \
|
||||
return static_cast<int>(a) == static_cast<int>(b); \
|
||||
} \
|
||||
|
||||
#define __CV_ENUM_FLAGS_BITWISE_NOT(EnumType) \
|
||||
static inline EnumType operator~(const EnumType& val) \
|
||||
{ \
|
||||
typedef std::underlying_type<EnumType>::type UnderlyingType; \
|
||||
return static_cast<EnumType>(~static_cast<UnderlyingType>(val)); \
|
||||
} \
|
||||
|
||||
#define __CV_ENUM_FLAGS_BITWISE_OR(EnumType, Arg1Type, Arg2Type) \
|
||||
static inline EnumType operator|(const Arg1Type& a, const Arg2Type& b) \
|
||||
{ \
|
||||
typedef std::underlying_type<EnumType>::type UnderlyingType; \
|
||||
return static_cast<EnumType>(static_cast<UnderlyingType>(a) | static_cast<UnderlyingType>(b)); \
|
||||
} \
|
||||
|
||||
#define __CV_ENUM_FLAGS_BITWISE_AND(EnumType, Arg1Type, Arg2Type) \
|
||||
static inline EnumType operator&(const Arg1Type& a, const Arg2Type& b) \
|
||||
{ \
|
||||
typedef std::underlying_type<EnumType>::type UnderlyingType; \
|
||||
return static_cast<EnumType>(static_cast<UnderlyingType>(a) & static_cast<UnderlyingType>(b)); \
|
||||
} \
|
||||
|
||||
#define __CV_ENUM_FLAGS_BITWISE_XOR(EnumType, Arg1Type, Arg2Type) \
|
||||
static inline EnumType operator^(const Arg1Type& a, const Arg2Type& b) \
|
||||
{ \
|
||||
typedef std::underlying_type<EnumType>::type UnderlyingType; \
|
||||
return static_cast<EnumType>(static_cast<UnderlyingType>(a) ^ static_cast<UnderlyingType>(b)); \
|
||||
} \
|
||||
|
||||
#define __CV_ENUM_FLAGS_BITWISE_OR_EQ(EnumType, Arg1Type) \
|
||||
static inline EnumType& operator|=(EnumType& _this, const Arg1Type& val) \
|
||||
{ \
|
||||
_this = static_cast<EnumType>(static_cast<int>(_this) | static_cast<int>(val)); \
|
||||
return _this; \
|
||||
} \
|
||||
|
||||
#define __CV_ENUM_FLAGS_BITWISE_AND_EQ(EnumType, Arg1Type) \
|
||||
static inline EnumType& operator&=(EnumType& _this, const Arg1Type& val) \
|
||||
{ \
|
||||
_this = static_cast<EnumType>(static_cast<int>(_this) & static_cast<int>(val)); \
|
||||
return _this; \
|
||||
} \
|
||||
|
||||
#define __CV_ENUM_FLAGS_BITWISE_XOR_EQ(EnumType, Arg1Type) \
|
||||
static inline EnumType& operator^=(EnumType& _this, const Arg1Type& val) \
|
||||
{ \
|
||||
_this = static_cast<EnumType>(static_cast<int>(_this) ^ static_cast<int>(val)); \
|
||||
return _this; \
|
||||
} \
|
||||
|
||||
#define CV_ENUM_CLASS_EXPOSE(EnumType, ...) \
|
||||
__CV_EXPAND(__CV_CAT(__CV_ENUM_CLASS_EXPOSE_, __CV_VA_NUM_ARGS(__VA_ARGS__))(EnumType, __VA_ARGS__)); \
|
||||
|
||||
#define CV_ENUM_FLAGS(EnumType) \
|
||||
__CV_ENUM_FLAGS_LOGICAL_NOT (EnumType); \
|
||||
__CV_ENUM_FLAGS_LOGICAL_EQ (EnumType, int); \
|
||||
__CV_ENUM_FLAGS_LOGICAL_NOT_EQ (EnumType, int); \
|
||||
\
|
||||
__CV_ENUM_FLAGS_BITWISE_NOT (EnumType); \
|
||||
__CV_ENUM_FLAGS_BITWISE_OR (EnumType, EnumType, EnumType); \
|
||||
__CV_ENUM_FLAGS_BITWISE_AND (EnumType, EnumType, EnumType); \
|
||||
__CV_ENUM_FLAGS_BITWISE_XOR (EnumType, EnumType, EnumType); \
|
||||
\
|
||||
__CV_ENUM_FLAGS_BITWISE_OR_EQ (EnumType, EnumType); \
|
||||
__CV_ENUM_FLAGS_BITWISE_AND_EQ (EnumType, EnumType); \
|
||||
__CV_ENUM_FLAGS_BITWISE_XOR_EQ (EnumType, EnumType); \
|
||||
|
||||
/****************************************************************************************\
|
||||
* static analysys *
|
||||
\****************************************************************************************/
|
||||
|
||||
@@ -61,8 +61,10 @@ namespace cv
|
||||
//! @addtogroup core_basic
|
||||
//! @{
|
||||
|
||||
enum { ACCESS_READ=1<<24, ACCESS_WRITE=1<<25,
|
||||
enum AccessFlag { ACCESS_READ=1<<24, ACCESS_WRITE=1<<25,
|
||||
ACCESS_RW=3<<24, ACCESS_MASK=ACCESS_RW, ACCESS_FAST=1<<26 };
|
||||
CV_ENUM_FLAGS(AccessFlag);
|
||||
__CV_ENUM_FLAGS_BITWISE_AND(AccessFlag, int, AccessFlag);
|
||||
|
||||
CV__DEBUG_NS_BEGIN
|
||||
|
||||
@@ -156,7 +158,7 @@ Custom type is wrapped as Mat-compatible `CV_8UC<N>` values (N = sizeof(T), N <=
|
||||
class CV_EXPORTS _InputArray
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
enum KindFlag {
|
||||
KIND_SHIFT = 16,
|
||||
FIXED_TYPE = 0x8000 << KIND_SHIFT,
|
||||
FIXED_SIZE = 0x4000 << KIND_SHIFT,
|
||||
@@ -221,7 +223,7 @@ public:
|
||||
void* getObj() const;
|
||||
Size getSz() const;
|
||||
|
||||
int kind() const;
|
||||
_InputArray::KindFlag kind() const;
|
||||
int dims(int i=-1) const;
|
||||
int cols(int i=-1) const;
|
||||
int rows(int i=-1) const;
|
||||
@@ -257,7 +259,8 @@ protected:
|
||||
void init(int _flags, const void* _obj);
|
||||
void init(int _flags, const void* _obj, Size _sz);
|
||||
};
|
||||
|
||||
CV_ENUM_FLAGS(_InputArray::KindFlag);
|
||||
__CV_ENUM_FLAGS_BITWISE_AND(_InputArray::KindFlag, int, _InputArray::KindFlag);
|
||||
|
||||
/** @brief This type is very similar to InputArray except that it is used for input/output and output function
|
||||
parameters.
|
||||
@@ -287,7 +290,7 @@ generators:
|
||||
class CV_EXPORTS _OutputArray : public _InputArray
|
||||
{
|
||||
public:
|
||||
enum
|
||||
enum DepthMask
|
||||
{
|
||||
DEPTH_MASK_8U = 1 << CV_8U,
|
||||
DEPTH_MASK_8S = 1 << CV_8S,
|
||||
@@ -356,9 +359,9 @@ public:
|
||||
std::vector<cuda::GpuMat>& getGpuMatVecRef() const;
|
||||
ogl::Buffer& getOGlBufferRef() const;
|
||||
cuda::HostMem& getHostMemRef() const;
|
||||
void create(Size sz, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const;
|
||||
void create(int rows, int cols, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const;
|
||||
void create(int dims, const int* size, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const;
|
||||
void create(Size sz, int type, int i=-1, bool allowTransposed=false, _OutputArray::DepthMask fixedDepthMask=static_cast<_OutputArray::DepthMask>(0)) const;
|
||||
void create(int rows, int cols, int type, int i=-1, bool allowTransposed=false, _OutputArray::DepthMask fixedDepthMask=static_cast<_OutputArray::DepthMask>(0)) const;
|
||||
void create(int dims, const int* size, int type, int i=-1, bool allowTransposed=false, _OutputArray::DepthMask fixedDepthMask=static_cast<_OutputArray::DepthMask>(0)) const;
|
||||
void createSameSize(const _InputArray& arr, int mtype) const;
|
||||
void release() const;
|
||||
void clear() const;
|
||||
@@ -467,10 +470,10 @@ public:
|
||||
// uchar*& datastart, uchar*& data, size_t* step) = 0;
|
||||
//virtual void deallocate(int* refcount, uchar* datastart, uchar* data) = 0;
|
||||
virtual UMatData* allocate(int dims, const int* sizes, int type,
|
||||
void* data, size_t* step, int flags, UMatUsageFlags usageFlags) const = 0;
|
||||
virtual bool allocate(UMatData* data, int accessflags, UMatUsageFlags usageFlags) const = 0;
|
||||
void* data, size_t* step, AccessFlag flags, UMatUsageFlags usageFlags) const = 0;
|
||||
virtual bool allocate(UMatData* data, AccessFlag accessflags, UMatUsageFlags usageFlags) const = 0;
|
||||
virtual void deallocate(UMatData* data) const = 0;
|
||||
virtual void map(UMatData* data, int accessflags) const;
|
||||
virtual void map(UMatData* data, AccessFlag accessflags) const;
|
||||
virtual void unmap(UMatData* data) const;
|
||||
virtual void download(UMatData* data, void* dst, int dims, const size_t sz[],
|
||||
const size_t srcofs[], const size_t srcstep[],
|
||||
@@ -523,7 +526,7 @@ protected:
|
||||
// it should be explicitly initialized using init().
|
||||
struct CV_EXPORTS UMatData
|
||||
{
|
||||
enum { COPY_ON_MAP=1, HOST_COPY_OBSOLETE=2,
|
||||
enum MemoryFlag { COPY_ON_MAP=1, HOST_COPY_OBSOLETE=2,
|
||||
DEVICE_COPY_OBSOLETE=4, TEMP_UMAT=8, TEMP_COPIED_UMAT=24,
|
||||
USER_ALLOCATED=32, DEVICE_MEM_MAPPED=64,
|
||||
ASYNC_CLEANUP=128
|
||||
@@ -553,13 +556,14 @@ struct CV_EXPORTS UMatData
|
||||
uchar* origdata;
|
||||
size_t size;
|
||||
|
||||
int flags;
|
||||
UMatData::MemoryFlag flags;
|
||||
void* handle;
|
||||
void* userdata;
|
||||
int allocatorFlags_;
|
||||
int mapcount;
|
||||
UMatData* originalUMatData;
|
||||
};
|
||||
CV_ENUM_FLAGS(UMatData::MemoryFlag);
|
||||
|
||||
|
||||
struct CV_EXPORTS MatSize
|
||||
@@ -1061,7 +1065,7 @@ public:
|
||||
Mat& operator = (const MatExpr& expr);
|
||||
|
||||
//! retrieve UMat from Mat
|
||||
UMat getUMat(int accessFlags, UMatUsageFlags usageFlags = USAGE_DEFAULT) const;
|
||||
UMat getUMat(AccessFlag accessFlags, UMatUsageFlags usageFlags = USAGE_DEFAULT) const;
|
||||
|
||||
/** @brief Creates a matrix header for the specified matrix row.
|
||||
|
||||
@@ -2420,7 +2424,7 @@ public:
|
||||
//! assignment operators
|
||||
UMat& operator = (const UMat& m);
|
||||
|
||||
Mat getMat(int flags) const;
|
||||
Mat getMat(AccessFlag flags) const;
|
||||
|
||||
//! returns a new matrix header for the specified row
|
||||
UMat row(int y) const;
|
||||
@@ -2546,7 +2550,7 @@ public:
|
||||
The UMat instance should be kept alive during the use of the handle to prevent the buffer to be
|
||||
returned to the OpenCV buffer pool.
|
||||
*/
|
||||
void* handle(int accessFlags) const;
|
||||
void* handle(AccessFlag accessFlags) const;
|
||||
void ndoffset(size_t* ofs) const;
|
||||
|
||||
enum { MAGIC_VAL = 0x42FF0000, AUTO_STEP = 0, CONTINUOUS_FLAG = CV_MAT_CONT_FLAG, SUBMATRIX_FLAG = CV_SUBMAT_FLAG };
|
||||
|
||||
@@ -83,7 +83,7 @@ inline void* _InputArray::getObj() const { return obj; }
|
||||
inline int _InputArray::getFlags() const { return flags; }
|
||||
inline Size _InputArray::getSz() const { return sz; }
|
||||
|
||||
inline _InputArray::_InputArray() { init(NONE, 0); }
|
||||
inline _InputArray::_InputArray() { init(0 + NONE, 0); }
|
||||
inline _InputArray::_InputArray(int _flags, void* _obj) { init(_flags, _obj); }
|
||||
inline _InputArray::_InputArray(const Mat& m) { init(MAT+ACCESS_READ, &m); }
|
||||
inline _InputArray::_InputArray(const std::vector<Mat>& vec) { init(STD_VECTOR_MAT+ACCESS_READ, &vec); }
|
||||
@@ -185,12 +185,12 @@ inline bool _InputArray::isGpuMatVector() const { return kind() == _InputArray::
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline _OutputArray::_OutputArray() { init(ACCESS_WRITE, 0); }
|
||||
inline _OutputArray::_OutputArray(int _flags, void* _obj) { init(_flags|ACCESS_WRITE, _obj); }
|
||||
inline _OutputArray::_OutputArray() { init(NONE + ACCESS_WRITE, 0); }
|
||||
inline _OutputArray::_OutputArray(int _flags, void* _obj) { init(_flags + ACCESS_WRITE, _obj); }
|
||||
inline _OutputArray::_OutputArray(Mat& m) { init(MAT+ACCESS_WRITE, &m); }
|
||||
inline _OutputArray::_OutputArray(std::vector<Mat>& vec) { init(STD_VECTOR_MAT+ACCESS_WRITE, &vec); }
|
||||
inline _OutputArray::_OutputArray(UMat& m) { init(UMAT+ACCESS_WRITE, &m); }
|
||||
inline _OutputArray::_OutputArray(std::vector<UMat>& vec) { init(STD_VECTOR_UMAT+ACCESS_WRITE, &vec); }
|
||||
inline _OutputArray::_OutputArray(std::vector<Mat>& vec) { init(STD_VECTOR_MAT + ACCESS_WRITE, &vec); }
|
||||
inline _OutputArray::_OutputArray(UMat& m) { init(UMAT + ACCESS_WRITE, &m); }
|
||||
inline _OutputArray::_OutputArray(std::vector<UMat>& vec) { init(STD_VECTOR_UMAT + ACCESS_WRITE, &vec); }
|
||||
|
||||
template<typename _Tp> inline
|
||||
_OutputArray::_OutputArray(std::vector<_Tp>& vec)
|
||||
@@ -311,8 +311,8 @@ _OutputArray _OutputArray::rawOut(std::array<_Tp, _Nm>& arr)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline _InputOutputArray::_InputOutputArray() { init(ACCESS_RW, 0); }
|
||||
inline _InputOutputArray::_InputOutputArray(int _flags, void* _obj) { init(_flags|ACCESS_RW, _obj); }
|
||||
inline _InputOutputArray::_InputOutputArray() { init(0+ACCESS_RW, 0); }
|
||||
inline _InputOutputArray::_InputOutputArray(int _flags, void* _obj) { init(_flags+ACCESS_RW, _obj); }
|
||||
inline _InputOutputArray::_InputOutputArray(Mat& m) { init(MAT+ACCESS_RW, &m); }
|
||||
inline _InputOutputArray::_InputOutputArray(std::vector<Mat>& vec) { init(STD_VECTOR_MAT+ACCESS_RW, &vec); }
|
||||
inline _InputOutputArray::_InputOutputArray(UMat& m) { init(UMAT+ACCESS_RW, &m); }
|
||||
@@ -600,7 +600,7 @@ Mat::Mat(Size _sz, int _type, void* _data, size_t _step)
|
||||
|
||||
template<typename _Tp> inline
|
||||
Mat::Mat(const std::vector<_Tp>& vec, bool copyData)
|
||||
: flags(MAGIC_VAL | traits::Type<_Tp>::value | CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()),
|
||||
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()),
|
||||
cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
if(vec.empty())
|
||||
@@ -637,7 +637,7 @@ Mat::Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp
|
||||
|
||||
template<typename _Tp, std::size_t _Nm> inline
|
||||
Mat::Mat(const std::array<_Tp, _Nm>& arr, bool copyData)
|
||||
: flags(MAGIC_VAL | traits::Type<_Tp>::value | CV_MAT_CONT_FLAG), dims(2), rows((int)arr.size()),
|
||||
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)arr.size()),
|
||||
cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
if(arr.empty())
|
||||
@@ -654,7 +654,7 @@ Mat::Mat(const std::array<_Tp, _Nm>& arr, bool copyData)
|
||||
|
||||
template<typename _Tp, int n> inline
|
||||
Mat::Mat(const Vec<_Tp, n>& vec, bool copyData)
|
||||
: flags(MAGIC_VAL | traits::Type<_Tp>::value | CV_MAT_CONT_FLAG), dims(2), rows(n), cols(1), data(0),
|
||||
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(n), cols(1), data(0),
|
||||
datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
if( !copyData )
|
||||
@@ -670,7 +670,7 @@ Mat::Mat(const Vec<_Tp, n>& vec, bool copyData)
|
||||
|
||||
template<typename _Tp, int m, int n> inline
|
||||
Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData)
|
||||
: flags(MAGIC_VAL | traits::Type<_Tp>::value | CV_MAT_CONT_FLAG), dims(2), rows(m), cols(n), data(0),
|
||||
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(m), cols(n), data(0),
|
||||
datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
if( !copyData )
|
||||
@@ -686,7 +686,7 @@ Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData)
|
||||
|
||||
template<typename _Tp> inline
|
||||
Mat::Mat(const Point_<_Tp>& pt, bool copyData)
|
||||
: flags(MAGIC_VAL | traits::Type<_Tp>::value | CV_MAT_CONT_FLAG), dims(2), rows(2), cols(1), data(0),
|
||||
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(2), cols(1), data(0),
|
||||
datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
if( !copyData )
|
||||
@@ -705,7 +705,7 @@ Mat::Mat(const Point_<_Tp>& pt, bool copyData)
|
||||
|
||||
template<typename _Tp> inline
|
||||
Mat::Mat(const Point3_<_Tp>& pt, bool copyData)
|
||||
: flags(MAGIC_VAL | traits::Type<_Tp>::value | CV_MAT_CONT_FLAG), dims(2), rows(3), cols(1), data(0),
|
||||
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(3), cols(1), data(0),
|
||||
datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
if( !copyData )
|
||||
@@ -725,7 +725,7 @@ Mat::Mat(const Point3_<_Tp>& pt, bool copyData)
|
||||
|
||||
template<typename _Tp> inline
|
||||
Mat::Mat(const MatCommaInitializer_<_Tp>& commaInitializer)
|
||||
: flags(MAGIC_VAL | traits::Type<_Tp>::value | CV_MAT_CONT_FLAG), dims(0), rows(0), cols(0), data(0),
|
||||
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(0), rows(0), cols(0), data(0),
|
||||
datastart(0), dataend(0), allocator(0), u(0), size(&rows)
|
||||
{
|
||||
*this = commaInitializer.operator Mat_<_Tp>();
|
||||
@@ -1554,7 +1554,7 @@ template<typename _Tp> inline
|
||||
Mat_<_Tp>::Mat_()
|
||||
: Mat()
|
||||
{
|
||||
flags = (flags & ~CV_MAT_TYPE_MASK) | traits::Type<_Tp>::value;
|
||||
flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value;
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
@@ -1611,7 +1611,7 @@ template<typename _Tp> inline
|
||||
Mat_<_Tp>::Mat_(const Mat& m)
|
||||
: Mat()
|
||||
{
|
||||
flags = (flags & ~CV_MAT_TYPE_MASK) | traits::Type<_Tp>::value;
|
||||
flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value;
|
||||
*this = m;
|
||||
}
|
||||
|
||||
@@ -1751,7 +1751,7 @@ void Mat_<_Tp>::release()
|
||||
{
|
||||
Mat::release();
|
||||
#ifdef _DEBUG
|
||||
flags = (flags & ~CV_MAT_TYPE_MASK) | traits::Type<_Tp>::value;
|
||||
flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2069,7 +2069,7 @@ template<typename _Tp> inline
|
||||
Mat_<_Tp>::Mat_(Mat&& m)
|
||||
: Mat()
|
||||
{
|
||||
flags = (flags & ~CV_MAT_TYPE_MASK) | traits::Type<_Tp>::value;
|
||||
flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value;
|
||||
*this = m;
|
||||
}
|
||||
|
||||
@@ -2095,7 +2095,7 @@ template<typename _Tp> inline
|
||||
Mat_<_Tp>::Mat_(MatExpr&& e)
|
||||
: Mat()
|
||||
{
|
||||
flags = (flags & ~CV_MAT_TYPE_MASK) | traits::Type<_Tp>::value;
|
||||
flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value;
|
||||
*this = Mat(e);
|
||||
}
|
||||
|
||||
@@ -2431,7 +2431,7 @@ SparseMatConstIterator_<_Tp> SparseMat::end() const
|
||||
template<typename _Tp> inline
|
||||
SparseMat_<_Tp>::SparseMat_()
|
||||
{
|
||||
flags = MAGIC_VAL | traits::Type<_Tp>::value;
|
||||
flags = MAGIC_VAL + traits::Type<_Tp>::value;
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
@@ -3654,7 +3654,7 @@ UMat::UMat(const UMat& m)
|
||||
|
||||
template<typename _Tp> inline
|
||||
UMat::UMat(const std::vector<_Tp>& vec, bool copyData)
|
||||
: flags(MAGIC_VAL | traits::Type<_Tp>::value | CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()),
|
||||
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()),
|
||||
cols(1), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows)
|
||||
{
|
||||
if(vec.empty())
|
||||
|
||||
@@ -548,7 +548,7 @@ calling unmapGLBuffer() function.
|
||||
@param accessFlags - data access flags (ACCESS_READ|ACCESS_WRITE).
|
||||
@return Returns UMat object
|
||||
*/
|
||||
CV_EXPORTS UMat mapGLBuffer(const Buffer& buffer, int accessFlags = ACCESS_READ|ACCESS_WRITE);
|
||||
CV_EXPORTS UMat mapGLBuffer(const Buffer& buffer, AccessFlag accessFlags = ACCESS_READ | ACCESS_WRITE);
|
||||
|
||||
/** @brief Unmaps Buffer object (releases UMat, previously mapped from Buffer).
|
||||
|
||||
|
||||
@@ -392,7 +392,7 @@ CV_EXPORTS String format( const char* fmt, ... );
|
||||
///////////////////////////////// Formatted output of cv::Mat /////////////////////////////////
|
||||
|
||||
static inline
|
||||
Ptr<Formatted> format(InputArray mtx, int fmt)
|
||||
Ptr<Formatted> format(InputArray mtx, Formatter::FormatType fmt)
|
||||
{
|
||||
return Formatter::get(fmt)->format(mtx.getMat());
|
||||
}
|
||||
|
||||
@@ -1049,6 +1049,12 @@ void write(FileStorage& fs, const String& name, const DMatch& m)
|
||||
write(fs, m.distance);
|
||||
}
|
||||
|
||||
template<typename _Tp, typename std::enable_if< std::is_enum<_Tp>::value >::type* = nullptr>
|
||||
static inline void write( FileStorage& fs, const String& name, const _Tp& val )
|
||||
{
|
||||
write(fs, name, static_cast<int>(val));
|
||||
}
|
||||
|
||||
template<typename _Tp> static inline
|
||||
void write( FileStorage& fs, const String& name, const std::vector<_Tp>& vec )
|
||||
{
|
||||
@@ -1137,6 +1143,14 @@ void read( FileNodeIterator& it, std::vector<_Tp>& vec, size_t maxCount = (size_
|
||||
r(vec, maxCount);
|
||||
}
|
||||
|
||||
template<typename _Tp, typename std::enable_if< std::is_enum<_Tp>::value >::type* = nullptr>
|
||||
static inline void read(const FileNode& node, _Tp& value, const _Tp& default_value = static_cast<_Tp>(0))
|
||||
{
|
||||
int temp;
|
||||
read(node, temp, static_cast<int>(default_value));
|
||||
value = static_cast<_Tp>(temp);
|
||||
}
|
||||
|
||||
template<typename _Tp> static inline
|
||||
void read( const FileNode& node, std::vector<_Tp>& vec, const std::vector<_Tp>& default_value = std::vector<_Tp>() )
|
||||
{
|
||||
|
||||
@@ -943,8 +943,8 @@ public:
|
||||
void printErrors() const;
|
||||
|
||||
protected:
|
||||
void getByName(const String& name, bool space_delete, int type, void* dst) const;
|
||||
void getByIndex(int index, bool space_delete, int type, void* dst) const;
|
||||
void getByName(const String& name, bool space_delete, Param type, void* dst) const;
|
||||
void getByIndex(int index, bool space_delete, Param type, void* dst) const;
|
||||
|
||||
struct Impl;
|
||||
Impl* impl;
|
||||
|
||||
@@ -7,6 +7,8 @@ typedef std::vector<Range> vector_Range;
|
||||
CV_PY_TO_CLASS(UMat);
|
||||
CV_PY_FROM_CLASS(UMat);
|
||||
CV_PY_TO_ENUM(UMatUsageFlags);
|
||||
CV_PY_FROM_ENUM(AccessFlag);
|
||||
CV_PY_TO_ENUM(AccessFlag);
|
||||
|
||||
static bool cv_mappable_to(const Ptr<Mat>& src, Ptr<UMat>& dst)
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
The UMat instance should be kept alive during the use of the handle to prevent the buffer to be
|
||||
returned to the OpenCV buffer pool.
|
||||
*/
|
||||
CV_WRAP void* handle(int accessFlags) const;
|
||||
CV_WRAP void* handle(AccessFlag accessFlags) const;
|
||||
|
||||
// offset of the submatrix (or 0)
|
||||
CV_PROP_RW size_t offset;
|
||||
|
||||
@@ -167,7 +167,7 @@ static void binary_op( InputArray _src1, InputArray _src2, OutputArray _dst,
|
||||
bool bitwise, int oclop )
|
||||
{
|
||||
const _InputArray *psrc1 = &_src1, *psrc2 = &_src2;
|
||||
int kind1 = psrc1->kind(), kind2 = psrc2->kind();
|
||||
_InputArray::KindFlag kind1 = psrc1->kind(), kind2 = psrc2->kind();
|
||||
int type1 = psrc1->type(), depth1 = CV_MAT_DEPTH(type1), cn = CV_MAT_CN(type1);
|
||||
int type2 = psrc2->type(), depth2 = CV_MAT_DEPTH(type2), cn2 = CV_MAT_CN(type2);
|
||||
int dims1 = psrc1->dims(), dims2 = psrc2->dims();
|
||||
@@ -600,7 +600,7 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
|
||||
void* usrdata=0, int oclop=-1 )
|
||||
{
|
||||
const _InputArray *psrc1 = &_src1, *psrc2 = &_src2;
|
||||
int kind1 = psrc1->kind(), kind2 = psrc2->kind();
|
||||
_InputArray::KindFlag kind1 = psrc1->kind(), kind2 = psrc2->kind();
|
||||
bool haveMask = !_mask.empty();
|
||||
bool reallocate = false;
|
||||
int type1 = psrc1->type(), depth1 = CV_MAT_DEPTH(type1), cn = CV_MAT_CN(type1);
|
||||
@@ -1214,7 +1214,7 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op)
|
||||
CV_OCL_RUN(_src1.dims() <= 2 && _src2.dims() <= 2 && OCL_PERFORMANCE_CHECK(_dst.isUMat()),
|
||||
ocl_compare(_src1, _src2, _dst, op, haveScalar))
|
||||
|
||||
int kind1 = _src1.kind(), kind2 = _src2.kind();
|
||||
_InputArray::KindFlag kind1 = _src1.kind(), kind2 = _src2.kind();
|
||||
Mat src1 = _src1.getMat(), src2 = _src2.getMat();
|
||||
|
||||
if( kind1 == kind2 && src1.dims <= 2 && src2.dims <= 2 && src1.size() == src2.size() && src1.type() == src2.type() )
|
||||
@@ -1587,7 +1587,7 @@ static bool ocl_inRange( InputArray _src, InputArray _lowerb,
|
||||
InputArray _upperb, OutputArray _dst )
|
||||
{
|
||||
const ocl::Device & d = ocl::Device::getDefault();
|
||||
int skind = _src.kind(), lkind = _lowerb.kind(), ukind = _upperb.kind();
|
||||
_InputArray::KindFlag skind = _src.kind(), lkind = _lowerb.kind(), ukind = _upperb.kind();
|
||||
Size ssize = _src.size(), lsize = _lowerb.size(), usize = _upperb.size();
|
||||
int stype = _src.type(), ltype = _lowerb.type(), utype = _upperb.type();
|
||||
int sdepth = CV_MAT_DEPTH(stype), ldepth = CV_MAT_DEPTH(ltype), udepth = CV_MAT_DEPTH(utype);
|
||||
@@ -1712,7 +1712,7 @@ void cv::inRange(InputArray _src, InputArray _lowerb,
|
||||
_upperb.dims() <= 2 && OCL_PERFORMANCE_CHECK(_dst.isUMat()),
|
||||
ocl_inRange(_src, _lowerb, _upperb, _dst))
|
||||
|
||||
int skind = _src.kind(), lkind = _lowerb.kind(), ukind = _upperb.kind();
|
||||
_InputArray::KindFlag skind = _src.kind(), lkind = _lowerb.kind(), ukind = _upperb.kind();
|
||||
Mat src = _src.getMat(), lb = _lowerb.getMat(), ub = _upperb.getMat();
|
||||
|
||||
bool lbScalar = false, ubScalar = false;
|
||||
|
||||
@@ -53,7 +53,7 @@ struct CommandLineParser::Impl
|
||||
};
|
||||
|
||||
|
||||
static const char* get_type_name(int type)
|
||||
static const char* get_type_name(Param type)
|
||||
{
|
||||
if( type == Param::INT )
|
||||
return "int";
|
||||
@@ -81,7 +81,7 @@ static bool parse_bool(std::string str)
|
||||
return b;
|
||||
}
|
||||
|
||||
static void from_str(const String& str, int type, void* dst)
|
||||
static void from_str(const String& str, Param type, void* dst)
|
||||
{
|
||||
std::stringstream ss(str.c_str());
|
||||
if( type == Param::INT )
|
||||
@@ -117,7 +117,7 @@ static void from_str(const String& str, int type, void* dst)
|
||||
}
|
||||
}
|
||||
|
||||
void CommandLineParser::getByName(const String& name, bool space_delete, int type, void* dst) const
|
||||
void CommandLineParser::getByName(const String& name, bool space_delete, Param type, void* dst) const
|
||||
{
|
||||
CV_TRY
|
||||
{
|
||||
@@ -154,7 +154,7 @@ void CommandLineParser::getByName(const String& name, bool space_delete, int typ
|
||||
}
|
||||
|
||||
|
||||
void CommandLineParser::getByIndex(int index, bool space_delete, int type, void* dst) const
|
||||
void CommandLineParser::getByIndex(int index, bool space_delete, Param type, void* dst) const
|
||||
{
|
||||
CV_TRY
|
||||
{
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
|
||||
UMatData* allocate(int dims, const int* sizes, int type,
|
||||
void* data0, size_t* step,
|
||||
int /*flags*/, UMatUsageFlags /*usageFlags*/) const CV_OVERRIDE
|
||||
AccessFlag /*flags*/, UMatUsageFlags /*usageFlags*/) const CV_OVERRIDE
|
||||
{
|
||||
size_t total = CV_ELEM_SIZE(type);
|
||||
for (int i = dims-1; i >= 0; i--)
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
return u;
|
||||
}
|
||||
|
||||
bool allocate(UMatData* u, int /*accessFlags*/, UMatUsageFlags /*usageFlags*/) const CV_OVERRIDE
|
||||
bool allocate(UMatData* u, AccessFlag /*accessFlags*/, UMatUsageFlags /*usageFlags*/) const CV_OVERRIDE
|
||||
{
|
||||
return (u != NULL);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
namespace cv {
|
||||
|
||||
void MatAllocator::map(UMatData*, int) const
|
||||
void MatAllocator::map(UMatData*, AccessFlag) const
|
||||
{
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ class StdMatAllocator CV_FINAL : public MatAllocator
|
||||
{
|
||||
public:
|
||||
UMatData* allocate(int dims, const int* sizes, int type,
|
||||
void* data0, size_t* step, int /*flags*/, UMatUsageFlags /*usageFlags*/) const CV_OVERRIDE
|
||||
void* data0, size_t* step, AccessFlag /*flags*/, UMatUsageFlags /*usageFlags*/) const CV_OVERRIDE
|
||||
{
|
||||
size_t total = CV_ELEM_SIZE(type);
|
||||
for( int i = dims-1; i >= 0; i-- )
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
return u;
|
||||
}
|
||||
|
||||
bool allocate(UMatData* u, int /*accessFlags*/, UMatUsageFlags /*usageFlags*/) const CV_OVERRIDE
|
||||
bool allocate(UMatData* u, AccessFlag /*accessFlags*/, UMatUsageFlags /*usageFlags*/) const CV_OVERRIDE
|
||||
{
|
||||
if(!u) return false;
|
||||
return true;
|
||||
@@ -357,13 +357,13 @@ void Mat::create(int d, const int* _sizes, int _type)
|
||||
a = a0;
|
||||
CV_TRY
|
||||
{
|
||||
u = a->allocate(dims, size, _type, 0, step.p, 0, USAGE_DEFAULT);
|
||||
u = a->allocate(dims, size, _type, 0, step.p, ACCESS_RW /* ignored */, USAGE_DEFAULT);
|
||||
CV_Assert(u != 0);
|
||||
}
|
||||
CV_CATCH_ALL
|
||||
{
|
||||
if(a != a0)
|
||||
u = a0->allocate(dims, size, _type, 0, step.p, 0, USAGE_DEFAULT);
|
||||
u = a0->allocate(dims, size, _type, 0, step.p, ACCESS_RW /* ignored */, USAGE_DEFAULT);
|
||||
CV_Assert(u != 0);
|
||||
}
|
||||
CV_Assert( step[dims-1] == (size_t)CV_ELEM_SIZE(flags) );
|
||||
|
||||
@@ -14,8 +14,8 @@ namespace cv {
|
||||
|
||||
Mat _InputArray::getMat_(int i) const
|
||||
{
|
||||
int k = kind();
|
||||
int accessFlags = flags & ACCESS_MASK;
|
||||
_InputArray::KindFlag k = kind();
|
||||
AccessFlag accessFlags = flags & ACCESS_MASK;
|
||||
|
||||
if( k == MAT )
|
||||
{
|
||||
@@ -132,8 +132,8 @@ Mat _InputArray::getMat_(int i) const
|
||||
|
||||
UMat _InputArray::getUMat(int i) const
|
||||
{
|
||||
int k = kind();
|
||||
int accessFlags = flags & ACCESS_MASK;
|
||||
_InputArray::KindFlag k = kind();
|
||||
AccessFlag accessFlags = flags & ACCESS_MASK;
|
||||
|
||||
if( k == UMAT )
|
||||
{
|
||||
@@ -164,8 +164,8 @@ UMat _InputArray::getUMat(int i) const
|
||||
|
||||
void _InputArray::getMatVector(std::vector<Mat>& mv) const
|
||||
{
|
||||
int k = kind();
|
||||
int accessFlags = flags & ACCESS_MASK;
|
||||
_InputArray::KindFlag k = kind();
|
||||
AccessFlag accessFlags = flags & ACCESS_MASK;
|
||||
|
||||
if( k == MAT )
|
||||
{
|
||||
@@ -272,8 +272,8 @@ void _InputArray::getMatVector(std::vector<Mat>& mv) const
|
||||
|
||||
void _InputArray::getUMatVector(std::vector<UMat>& umv) const
|
||||
{
|
||||
int k = kind();
|
||||
int accessFlags = flags & ACCESS_MASK;
|
||||
_InputArray::KindFlag k = kind();
|
||||
AccessFlag accessFlags = flags & ACCESS_MASK;
|
||||
|
||||
if( k == NONE )
|
||||
{
|
||||
@@ -334,7 +334,7 @@ void _InputArray::getUMatVector(std::vector<UMat>& umv) const
|
||||
|
||||
cuda::GpuMat _InputArray::getGpuMat() const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
|
||||
if (k == CUDA_GPU_MAT)
|
||||
{
|
||||
@@ -360,7 +360,7 @@ cuda::GpuMat _InputArray::getGpuMat() const
|
||||
}
|
||||
void _InputArray::getGpuMatVector(std::vector<cuda::GpuMat>& gpumv) const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
if (k == STD_VECTOR_CUDA_GPU_MAT)
|
||||
{
|
||||
gpumv = *(std::vector<cuda::GpuMat>*)obj;
|
||||
@@ -368,7 +368,7 @@ void _InputArray::getGpuMatVector(std::vector<cuda::GpuMat>& gpumv) const
|
||||
}
|
||||
ogl::Buffer _InputArray::getOGlBuffer() const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
|
||||
CV_Assert(k == OPENGL_BUFFER);
|
||||
|
||||
@@ -376,7 +376,7 @@ ogl::Buffer _InputArray::getOGlBuffer() const
|
||||
return *gl_buf;
|
||||
}
|
||||
|
||||
int _InputArray::kind() const
|
||||
_InputArray::KindFlag _InputArray::kind() const
|
||||
{
|
||||
return flags & KIND_MASK;
|
||||
}
|
||||
@@ -393,7 +393,7 @@ int _InputArray::cols(int i) const
|
||||
|
||||
Size _InputArray::size(int i) const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
|
||||
if( k == MAT )
|
||||
{
|
||||
@@ -515,7 +515,8 @@ Size _InputArray::size(int i) const
|
||||
|
||||
int _InputArray::sizend(int* arrsz, int i) const
|
||||
{
|
||||
int j, d=0, k = kind();
|
||||
int j, d = 0;
|
||||
_InputArray::KindFlag k = kind();
|
||||
|
||||
if( k == NONE )
|
||||
;
|
||||
@@ -583,7 +584,7 @@ int _InputArray::sizend(int* arrsz, int i) const
|
||||
|
||||
bool _InputArray::sameSize(const _InputArray& arr) const
|
||||
{
|
||||
int k1 = kind(), k2 = arr.kind();
|
||||
_InputArray::KindFlag k1 = kind(), k2 = arr.kind();
|
||||
Size sz1;
|
||||
|
||||
if( k1 == MAT )
|
||||
@@ -617,7 +618,7 @@ bool _InputArray::sameSize(const _InputArray& arr) const
|
||||
|
||||
int _InputArray::dims(int i) const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
|
||||
if( k == MAT )
|
||||
{
|
||||
@@ -714,7 +715,7 @@ int _InputArray::dims(int i) const
|
||||
|
||||
size_t _InputArray::total(int i) const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
|
||||
if( k == MAT )
|
||||
{
|
||||
@@ -763,7 +764,7 @@ size_t _InputArray::total(int i) const
|
||||
|
||||
int _InputArray::type(int i) const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
|
||||
if( k == MAT )
|
||||
return ((const Mat*)obj)->type();
|
||||
@@ -852,7 +853,7 @@ int _InputArray::channels(int i) const
|
||||
|
||||
bool _InputArray::empty() const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
|
||||
if( k == MAT )
|
||||
return ((const Mat*)obj)->empty();
|
||||
@@ -924,7 +925,7 @@ bool _InputArray::empty() const
|
||||
|
||||
bool _InputArray::isContinuous(int i) const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
|
||||
if( k == MAT )
|
||||
return i < 0 ? ((const Mat*)obj)->isContinuous() : true;
|
||||
@@ -965,7 +966,7 @@ bool _InputArray::isContinuous(int i) const
|
||||
|
||||
bool _InputArray::isSubmatrix(int i) const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
|
||||
if( k == MAT )
|
||||
return i < 0 ? ((const Mat*)obj)->isSubmatrix() : false;
|
||||
@@ -1003,7 +1004,7 @@ bool _InputArray::isSubmatrix(int i) const
|
||||
|
||||
size_t _InputArray::offset(int i) const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
|
||||
if( k == MAT )
|
||||
{
|
||||
@@ -1067,7 +1068,7 @@ size_t _InputArray::offset(int i) const
|
||||
|
||||
size_t _InputArray::step(int i) const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
|
||||
if( k == MAT )
|
||||
{
|
||||
@@ -1127,7 +1128,7 @@ size_t _InputArray::step(int i) const
|
||||
|
||||
void _InputArray::copyTo(const _OutputArray& arr) const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
|
||||
if( k == NONE )
|
||||
arr.release();
|
||||
@@ -1156,7 +1157,7 @@ void _InputArray::copyTo(const _OutputArray& arr) const
|
||||
|
||||
void _InputArray::copyTo(const _OutputArray& arr, const _InputArray & mask) const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
|
||||
if( k == NONE )
|
||||
arr.release();
|
||||
@@ -1185,9 +1186,9 @@ bool _OutputArray::fixedType() const
|
||||
return (flags & FIXED_TYPE) == FIXED_TYPE;
|
||||
}
|
||||
|
||||
void _OutputArray::create(Size _sz, int mtype, int i, bool allowTransposed, int fixedDepthMask) const
|
||||
void _OutputArray::create(Size _sz, int mtype, int i, bool allowTransposed, _OutputArray::DepthMask fixedDepthMask) const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
if( k == MAT && i < 0 && !allowTransposed && fixedDepthMask == 0 )
|
||||
{
|
||||
CV_Assert(!fixedSize() || ((Mat*)obj)->size.operator()() == _sz);
|
||||
@@ -1227,9 +1228,9 @@ void _OutputArray::create(Size _sz, int mtype, int i, bool allowTransposed, int
|
||||
create(2, sizes, mtype, i, allowTransposed, fixedDepthMask);
|
||||
}
|
||||
|
||||
void _OutputArray::create(int _rows, int _cols, int mtype, int i, bool allowTransposed, int fixedDepthMask) const
|
||||
void _OutputArray::create(int _rows, int _cols, int mtype, int i, bool allowTransposed, _OutputArray::DepthMask fixedDepthMask) const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
if( k == MAT && i < 0 && !allowTransposed && fixedDepthMask == 0 )
|
||||
{
|
||||
CV_Assert(!fixedSize() || ((Mat*)obj)->size.operator()() == Size(_cols, _rows));
|
||||
@@ -1270,7 +1271,7 @@ void _OutputArray::create(int _rows, int _cols, int mtype, int i, bool allowTran
|
||||
}
|
||||
|
||||
void _OutputArray::create(int d, const int* sizes, int mtype, int i,
|
||||
bool allowTransposed, int fixedDepthMask) const
|
||||
bool allowTransposed, _OutputArray::DepthMask fixedDepthMask) const
|
||||
{
|
||||
int sizebuf[2];
|
||||
if(d == 1)
|
||||
@@ -1280,7 +1281,7 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i,
|
||||
sizebuf[1] = 1;
|
||||
sizes = sizebuf;
|
||||
}
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
mtype = CV_MAT_TYPE(mtype);
|
||||
|
||||
if( k == MAT )
|
||||
@@ -1667,7 +1668,7 @@ void _OutputArray::release() const
|
||||
{
|
||||
CV_Assert(!fixedSize());
|
||||
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
|
||||
if( k == MAT )
|
||||
{
|
||||
@@ -1735,7 +1736,7 @@ void _OutputArray::release() const
|
||||
|
||||
void _OutputArray::clear() const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
|
||||
if( k == MAT )
|
||||
{
|
||||
@@ -1754,7 +1755,7 @@ bool _OutputArray::needed() const
|
||||
|
||||
Mat& _OutputArray::getMatRef(int i) const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
if( i < 0 )
|
||||
{
|
||||
CV_Assert( k == MAT );
|
||||
@@ -1779,7 +1780,7 @@ Mat& _OutputArray::getMatRef(int i) const
|
||||
|
||||
UMat& _OutputArray::getUMatRef(int i) const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
if( i < 0 )
|
||||
{
|
||||
CV_Assert( k == UMAT );
|
||||
@@ -1796,34 +1797,34 @@ UMat& _OutputArray::getUMatRef(int i) const
|
||||
|
||||
cuda::GpuMat& _OutputArray::getGpuMatRef() const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
CV_Assert( k == CUDA_GPU_MAT );
|
||||
return *(cuda::GpuMat*)obj;
|
||||
}
|
||||
std::vector<cuda::GpuMat>& _OutputArray::getGpuMatVecRef() const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
CV_Assert(k == STD_VECTOR_CUDA_GPU_MAT);
|
||||
return *(std::vector<cuda::GpuMat>*)obj;
|
||||
}
|
||||
|
||||
ogl::Buffer& _OutputArray::getOGlBufferRef() const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
CV_Assert( k == OPENGL_BUFFER );
|
||||
return *(ogl::Buffer*)obj;
|
||||
}
|
||||
|
||||
cuda::HostMem& _OutputArray::getHostMemRef() const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
CV_Assert( k == CUDA_HOST_MEM );
|
||||
return *(cuda::HostMem*)obj;
|
||||
}
|
||||
|
||||
void _OutputArray::setTo(const _InputArray& arr, const _InputArray & mask) const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
|
||||
if( k == NONE )
|
||||
;
|
||||
@@ -1847,7 +1848,7 @@ void _OutputArray::setTo(const _InputArray& arr, const _InputArray & mask) const
|
||||
|
||||
void _OutputArray::assign(const UMat& u) const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
if (k == UMAT)
|
||||
{
|
||||
*(UMat*)obj = u;
|
||||
@@ -1869,7 +1870,7 @@ void _OutputArray::assign(const UMat& u) const
|
||||
|
||||
void _OutputArray::assign(const Mat& m) const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
if (k == UMAT)
|
||||
{
|
||||
m.copyTo(*(UMat*)obj); // TODO check m.getUMat()
|
||||
@@ -1891,7 +1892,7 @@ void _OutputArray::assign(const Mat& m) const
|
||||
|
||||
void _OutputArray::assign(const std::vector<UMat>& v) const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
if (k == STD_VECTOR_UMAT)
|
||||
{
|
||||
std::vector<UMat>& this_v = *(std::vector<UMat>*)obj;
|
||||
@@ -1929,7 +1930,7 @@ void _OutputArray::assign(const std::vector<UMat>& v) const
|
||||
|
||||
void _OutputArray::assign(const std::vector<Mat>& v) const
|
||||
{
|
||||
int k = kind();
|
||||
_InputArray::KindFlag k = kind();
|
||||
if (k == STD_VECTOR_UMAT)
|
||||
{
|
||||
std::vector<UMat>& this_v = *(std::vector<UMat>*)obj;
|
||||
|
||||
+19
-17
@@ -2972,8 +2972,8 @@ int Kernel::set(int i, const KernelArg& arg)
|
||||
cl_int status = 0;
|
||||
if( arg.m )
|
||||
{
|
||||
int accessFlags = ((arg.flags & KernelArg::READ_ONLY) ? ACCESS_READ : 0) +
|
||||
((arg.flags & KernelArg::WRITE_ONLY) ? ACCESS_WRITE : 0);
|
||||
AccessFlag accessFlags = ((arg.flags & KernelArg::READ_ONLY) ? ACCESS_READ : static_cast<AccessFlag>(0)) |
|
||||
((arg.flags & KernelArg::WRITE_ONLY) ? ACCESS_WRITE : static_cast<AccessFlag>(0));
|
||||
bool ptronly = (arg.flags & KernelArg::PTR_ONLY) != 0;
|
||||
cl_mem h = (cl_mem)arg.m->handle(accessFlags);
|
||||
|
||||
@@ -3050,7 +3050,7 @@ int Kernel::set(int i, const KernelArg& arg)
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
p->addUMat(*arg.m, (accessFlags & ACCESS_WRITE) != 0);
|
||||
p->addUMat(*arg.m, !!(accessFlags & ACCESS_WRITE));
|
||||
return i;
|
||||
}
|
||||
status = clSetKernelArg(p->handle, (cl_uint)i, arg.sz, arg.obj);
|
||||
@@ -4516,13 +4516,13 @@ public:
|
||||
}
|
||||
|
||||
UMatData* defaultAllocate(int dims, const int* sizes, int type, void* data, size_t* step,
|
||||
int flags, UMatUsageFlags usageFlags) const
|
||||
AccessFlag flags, UMatUsageFlags usageFlags) const
|
||||
{
|
||||
UMatData* u = matStdAllocator->allocate(dims, sizes, type, data, step, flags, usageFlags);
|
||||
return u;
|
||||
}
|
||||
|
||||
void getBestFlags(const Context& ctx, int /*flags*/, UMatUsageFlags usageFlags, int& createFlags, int& flags0) const
|
||||
void getBestFlags(const Context& ctx, AccessFlag /*flags*/, UMatUsageFlags usageFlags, int& createFlags, UMatData::MemoryFlag& flags0) const
|
||||
{
|
||||
const Device& dev = ctx.device(0);
|
||||
createFlags = 0;
|
||||
@@ -4530,13 +4530,13 @@ public:
|
||||
createFlags |= CL_MEM_ALLOC_HOST_PTR;
|
||||
|
||||
if( dev.hostUnifiedMemory() )
|
||||
flags0 = 0;
|
||||
flags0 = static_cast<UMatData::MemoryFlag>(0);
|
||||
else
|
||||
flags0 = UMatData::COPY_ON_MAP;
|
||||
}
|
||||
|
||||
UMatData* allocate(int dims, const int* sizes, int type,
|
||||
void* data, size_t* step, int flags, UMatUsageFlags usageFlags) const CV_OVERRIDE
|
||||
void* data, size_t* step, AccessFlag flags, UMatUsageFlags usageFlags) const CV_OVERRIDE
|
||||
{
|
||||
if(!useOpenCL())
|
||||
return defaultAllocate(dims, sizes, type, data, step, flags, usageFlags);
|
||||
@@ -4552,7 +4552,8 @@ public:
|
||||
Context& ctx = Context::getDefault();
|
||||
flushCleanupQueue();
|
||||
|
||||
int createFlags = 0, flags0 = 0;
|
||||
int createFlags = 0;
|
||||
UMatData::MemoryFlag flags0 = static_cast<UMatData::MemoryFlag>(0);
|
||||
getBestFlags(ctx, flags, usageFlags, createFlags, flags0);
|
||||
|
||||
void* handle = NULL;
|
||||
@@ -4600,7 +4601,7 @@ public:
|
||||
return u;
|
||||
}
|
||||
|
||||
bool allocate(UMatData* u, int accessFlags, UMatUsageFlags usageFlags) const CV_OVERRIDE
|
||||
bool allocate(UMatData* u, AccessFlag accessFlags, UMatUsageFlags usageFlags) const CV_OVERRIDE
|
||||
{
|
||||
if(!u)
|
||||
return false;
|
||||
@@ -4613,12 +4614,13 @@ public:
|
||||
{
|
||||
CV_Assert(u->origdata != 0);
|
||||
Context& ctx = Context::getDefault();
|
||||
int createFlags = 0, flags0 = 0;
|
||||
int createFlags = 0;
|
||||
UMatData::MemoryFlag flags0 = static_cast<UMatData::MemoryFlag>(0);
|
||||
getBestFlags(ctx, accessFlags, usageFlags, createFlags, flags0);
|
||||
|
||||
cl_context ctx_handle = (cl_context)ctx.ptr();
|
||||
int allocatorFlags = 0;
|
||||
int tempUMatFlags = 0;
|
||||
UMatData::MemoryFlag tempUMatFlags = static_cast<UMatData::MemoryFlag>(0);
|
||||
void* handle = NULL;
|
||||
cl_int retval = CL_SUCCESS;
|
||||
|
||||
@@ -4703,7 +4705,7 @@ public:
|
||||
u->flags |= tempUMatFlags;
|
||||
u->allocatorFlags_ = allocatorFlags;
|
||||
}
|
||||
if(accessFlags & ACCESS_WRITE)
|
||||
if (!!(accessFlags & ACCESS_WRITE))
|
||||
u->markHostCopyObsolete(true);
|
||||
return true;
|
||||
}
|
||||
@@ -4749,7 +4751,7 @@ public:
|
||||
CV_Assert(u->handle != 0);
|
||||
CV_Assert(u->mapcount == 0);
|
||||
|
||||
if (u->flags & UMatData::ASYNC_CLEANUP)
|
||||
if (!!(u->flags & UMatData::ASYNC_CLEANUP))
|
||||
addToCleanupQueue(u);
|
||||
else
|
||||
deallocate_(u);
|
||||
@@ -4924,11 +4926,11 @@ public:
|
||||
}
|
||||
|
||||
// synchronized call (external UMatDataAutoLock, see UMat::getMat)
|
||||
void map(UMatData* u, int accessFlags) const CV_OVERRIDE
|
||||
void map(UMatData* u, AccessFlag accessFlags) const CV_OVERRIDE
|
||||
{
|
||||
CV_Assert(u && u->handle);
|
||||
|
||||
if(accessFlags & ACCESS_WRITE)
|
||||
if (!!(accessFlags & ACCESS_WRITE))
|
||||
u->markDeviceCopyObsolete(true);
|
||||
|
||||
cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
|
||||
@@ -4995,7 +4997,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
if( (accessFlags & ACCESS_READ) != 0 && u->hostCopyObsolete() )
|
||||
if (!!(accessFlags & ACCESS_READ) && u->hostCopyObsolete())
|
||||
{
|
||||
AlignedDataPtr<false, true> alignedPtr(u->data, u->size, CV_OPENCL_DATA_PTR_ALIGNMENT);
|
||||
#ifdef HAVE_OPENCL_SVM
|
||||
@@ -5735,7 +5737,7 @@ void convertFromBuffer(void* cl_mem_buffer, size_t step, int rows, int cols, int
|
||||
dst.u = new UMatData(getOpenCLAllocator());
|
||||
dst.u->data = 0;
|
||||
dst.u->allocatorFlags_ = 0; // not allocated from any OpenCV buffer pool
|
||||
dst.u->flags = 0;
|
||||
dst.u->flags = static_cast<UMatData::MemoryFlag>(0);
|
||||
dst.u->handle = cl_mem_buffer;
|
||||
dst.u->origdata = 0;
|
||||
dst.u->prevAllocator = 0;
|
||||
|
||||
@@ -1804,8 +1804,8 @@ void convertFromGLTexture2D(const Texture2D& texture, OutputArray dst)
|
||||
#endif
|
||||
}
|
||||
|
||||
//void mapGLBuffer(const Buffer& buffer, UMat& dst, int accessFlags)
|
||||
UMat mapGLBuffer(const Buffer& buffer, int accessFlags)
|
||||
//void mapGLBuffer(const Buffer& buffer, UMat& dst, AccessFlag accessFlags)
|
||||
UMat mapGLBuffer(const Buffer& buffer, AccessFlag accessFlags)
|
||||
{
|
||||
CV_UNUSED(buffer); CV_UNUSED(accessFlags);
|
||||
#if !defined(HAVE_OPENGL)
|
||||
|
||||
@@ -372,7 +372,7 @@ namespace cv
|
||||
Formatted::~Formatted() {}
|
||||
Formatter::~Formatter() {}
|
||||
|
||||
Ptr<Formatter> Formatter::get(int fmt)
|
||||
Ptr<Formatter> Formatter::get(Formatter::FormatType fmt)
|
||||
{
|
||||
switch(fmt)
|
||||
{
|
||||
|
||||
@@ -210,7 +210,7 @@ enum { BLOCK_SIZE = 1024 };
|
||||
#define ARITHM_USE_IPP 0
|
||||
#endif
|
||||
|
||||
inline bool checkScalar(const Mat& sc, int atype, int sckind, int akind)
|
||||
inline bool checkScalar(const Mat& sc, int atype, _InputArray::KindFlag sckind, _InputArray::KindFlag akind)
|
||||
{
|
||||
if( sc.dims > 2 || !sc.isContinuous() )
|
||||
return false;
|
||||
@@ -224,7 +224,7 @@ inline bool checkScalar(const Mat& sc, int atype, int sckind, int akind)
|
||||
(sz == Size(1, 4) && sc.type() == CV_64F && cn <= 4);
|
||||
}
|
||||
|
||||
inline bool checkScalar(InputArray sc, int atype, int sckind, int akind)
|
||||
inline bool checkScalar(InputArray sc, int atype, _InputArray::KindFlag sckind, _InputArray::KindFlag akind)
|
||||
{
|
||||
if( sc.dims() > 2 || !sc.isContinuous() )
|
||||
return false;
|
||||
|
||||
@@ -64,7 +64,7 @@ UMatData::UMatData(const MatAllocator* allocator)
|
||||
urefcount = refcount = mapcount = 0;
|
||||
data = origdata = 0;
|
||||
size = 0;
|
||||
flags = 0;
|
||||
flags = static_cast<UMatData::MemoryFlag>(0);
|
||||
handle = 0;
|
||||
userdata = 0;
|
||||
allocatorFlags_ = 0;
|
||||
@@ -78,7 +78,7 @@ UMatData::~UMatData()
|
||||
CV_Assert(mapcount == 0);
|
||||
data = origdata = 0;
|
||||
size = 0;
|
||||
flags = 0;
|
||||
flags = static_cast<UMatData::MemoryFlag>(0);
|
||||
handle = 0;
|
||||
userdata = 0;
|
||||
allocatorFlags_ = 0;
|
||||
@@ -333,7 +333,7 @@ void finalizeHdr(UMat& m)
|
||||
}
|
||||
|
||||
|
||||
UMat Mat::getUMat(int accessFlags, UMatUsageFlags usageFlags) const
|
||||
UMat Mat::getUMat(AccessFlag accessFlags, UMatUsageFlags usageFlags) const
|
||||
{
|
||||
UMat hdr;
|
||||
if(!data)
|
||||
@@ -444,13 +444,13 @@ void UMat::create(int d, const int* _sizes, int _type, UMatUsageFlags _usageFlag
|
||||
}
|
||||
CV_TRY
|
||||
{
|
||||
u = a->allocate(dims, size, _type, 0, step.p, 0, usageFlags);
|
||||
u = a->allocate(dims, size, _type, 0, step.p, ACCESS_RW /* ignored */, usageFlags);
|
||||
CV_Assert(u != 0);
|
||||
}
|
||||
CV_CATCH_ALL
|
||||
{
|
||||
if(a != a0)
|
||||
u = a0->allocate(dims, size, _type, 0, step.p, 0, usageFlags);
|
||||
u = a0->allocate(dims, size, _type, 0, step.p, ACCESS_RW /* ignored */, usageFlags);
|
||||
CV_Assert(u != 0);
|
||||
}
|
||||
CV_Assert( step[dims-1] == (size_t)CV_ELEM_SIZE(flags) );
|
||||
@@ -813,7 +813,7 @@ UMat UMat::reshape(int _cn, int _newndims, const int* _newsz) const
|
||||
CV_Error(CV_StsNotImplemented, "Reshaping of n-dimensional non-continuous matrices is not supported yet");
|
||||
}
|
||||
|
||||
Mat UMat::getMat(int accessFlags) const
|
||||
Mat UMat::getMat(AccessFlag accessFlags) const
|
||||
{
|
||||
if(!u)
|
||||
return Mat();
|
||||
@@ -840,7 +840,7 @@ Mat UMat::getMat(int accessFlags) const
|
||||
}
|
||||
}
|
||||
|
||||
void* UMat::handle(int accessFlags) const
|
||||
void* UMat::handle(AccessFlag accessFlags) const
|
||||
{
|
||||
if( !u )
|
||||
return 0;
|
||||
@@ -852,7 +852,7 @@ void* UMat::handle(int accessFlags) const
|
||||
u->currAllocator->unmap(u);
|
||||
}
|
||||
|
||||
if ((accessFlags & ACCESS_WRITE) != 0)
|
||||
if (!!(accessFlags & ACCESS_WRITE))
|
||||
u->markHostCopyObsolete(true);
|
||||
|
||||
return u->handle;
|
||||
|
||||
@@ -946,7 +946,7 @@ void Core_ArrayOpTest::run( int /* start_from */)
|
||||
}
|
||||
|
||||
|
||||
template <class ElemType>
|
||||
template <class T>
|
||||
int calcDiffElemCountImpl(const vector<Mat>& mv, const Mat& m)
|
||||
{
|
||||
int diffElemCount = 0;
|
||||
@@ -955,12 +955,12 @@ int calcDiffElemCountImpl(const vector<Mat>& mv, const Mat& m)
|
||||
{
|
||||
for(int x = 0; x < m.cols; x++)
|
||||
{
|
||||
const ElemType* mElem = &m.at<ElemType>(y,x*mChannels);
|
||||
const T* mElem = &m.at<T>(y, x*mChannels);
|
||||
size_t loc = 0;
|
||||
for(size_t i = 0; i < mv.size(); i++)
|
||||
{
|
||||
const size_t mvChannel = mv[i].channels();
|
||||
const ElemType* mvElem = &mv[i].at<ElemType>(y,x*(int)mvChannel);
|
||||
const T* mvElem = &mv[i].at<T>(y, x*(int)mvChannel);
|
||||
for(size_t li = 0; li < mvChannel; li++)
|
||||
if(mElem[loc + li] != mvElem[li])
|
||||
diffElemCount++;
|
||||
|
||||
Reference in New Issue
Block a user