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
pull/12604/head
Hamdi Sahloul 7 years ago committed by Alexander Alekhin
parent 84ae8097b1
commit ef5579dc86
  1. 46
      modules/core/include/opencv2/core.hpp
  2. 24
      modules/core/include/opencv2/core/base.hpp
  3. 138
      modules/core/include/opencv2/core/cvdef.h
  4. 36
      modules/core/include/opencv2/core/mat.hpp
  5. 44
      modules/core/include/opencv2/core/mat.inl.hpp
  6. 2
      modules/core/include/opencv2/core/opengl.hpp
  7. 2
      modules/core/include/opencv2/core/operations.hpp
  8. 14
      modules/core/include/opencv2/core/persistence.hpp
  9. 4
      modules/core/include/opencv2/core/utility.hpp
  10. 2
      modules/core/misc/python/pyopencv_umat.hpp
  11. 2
      modules/core/misc/python/shadow_umat.hpp
  12. 10
      modules/core/src/arithm.cpp
  13. 8
      modules/core/src/command_line_parser.cpp
  14. 4
      modules/core/src/cuda_host_mem.cpp
  15. 10
      modules/core/src/matrix.cpp
  16. 89
      modules/core/src/matrix_wrap.cpp
  17. 36
      modules/core/src/ocl.cpp
  18. 4
      modules/core/src/opengl.cpp
  19. 2
      modules/core/src/out.cpp
  20. 4
      modules/core/src/precomp.hpp
  21. 16
      modules/core/src/umatrix.cpp
  22. 6
      modules/core/test/test_mat.cpp
  23. 4
      modules/dnn/include/opencv2/dnn/dict.hpp
  24. 22
      modules/dnn/include/opencv2/dnn/dnn.inl.hpp
  25. 163
      modules/features2d/include/opencv2/features2d.hpp
  26. 21
      modules/features2d/misc/python/pyopencv_features2d.hpp
  27. 16
      modules/features2d/src/agast.cpp
  28. 4
      modules/features2d/src/agast_score.cpp
  29. 6
      modules/features2d/src/agast_score.hpp
  30. 24
      modules/features2d/src/akaze.cpp
  31. 16
      modules/features2d/src/draw.cpp
  32. 20
      modules/features2d/src/fast.cpp
  33. 4
      modules/features2d/src/hal_replacement.hpp
  34. 12
      modules/features2d/src/kaze.cpp
  35. 4
      modules/features2d/src/kaze/AKAZEConfig.h
  36. 4
      modules/features2d/src/kaze/AKAZEFeatures.cpp
  37. 2
      modules/features2d/src/kaze/KAZEConfig.h
  38. 2
      modules/features2d/src/matchers.cpp
  39. 12
      modules/features2d/src/orb.cpp
  40. 4
      modules/features2d/test/test_agast.cpp
  41. 4
      modules/features2d/test/test_fast.cpp
  42. 2
      modules/features2d/test/test_orb.cpp
  43. 8
      modules/objdetect/include/opencv2/objdetect.hpp
  44. 13
      modules/objdetect/misc/python/pyopencv_objdetect.hpp
  45. 10
      modules/objdetect/src/hog.cpp
  46. 4
      modules/python/src2/cv2.cpp
  47. 4
      modules/stitching/include/opencv2/stitching/detail/matchers.hpp
  48. 4
      modules/stitching/src/matchers.cpp
  49. 2
      modules/ts/include/opencv2/ts.hpp
  50. 2
      modules/ts/src/ts_func.cpp
  51. 4
      modules/video/src/lkpyramid.cpp

@ -2997,7 +2997,8 @@ public:
class CV_EXPORTS Formatter class CV_EXPORTS Formatter
{ {
public: public:
enum { FMT_DEFAULT = 0, enum FormatType {
FMT_DEFAULT = 0,
FMT_MATLAB = 1, FMT_MATLAB = 1,
FMT_CSV = 2, FMT_CSV = 2,
FMT_PYTHON = 3, FMT_PYTHON = 3,
@ -3014,7 +3015,7 @@ public:
virtual void set64fPrecision(int p = 16) = 0; virtual void set64fPrecision(int p = 16) = 0;
virtual void setMultiline(bool ml = true) = 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; 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 /** @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; void writeFormat(FileStorage& fs) const;
}; };
struct Param { enum struct Param {
enum { INT=0, BOOLEAN=1, REAL=2, STRING=3, MAT=4, MAT_VECTOR=5, ALGORITHM=6, FLOAT=7, 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 }; UNSIGNED_INT=8, UINT64=9, UCHAR=11, SCALAR=12
}; };
@ -3162,7 +3163,7 @@ template<> struct ParamType<bool>
typedef bool const_param_type; typedef bool const_param_type;
typedef bool member_type; typedef bool member_type;
enum { type = Param::BOOLEAN }; static const Param type = Param::BOOLEAN;
}; };
template<> struct ParamType<int> template<> struct ParamType<int>
@ -3170,7 +3171,7 @@ template<> struct ParamType<int>
typedef int const_param_type; typedef int const_param_type;
typedef int member_type; typedef int member_type;
enum { type = Param::INT }; static const Param type = Param::INT;
}; };
template<> struct ParamType<double> template<> struct ParamType<double>
@ -3178,7 +3179,7 @@ template<> struct ParamType<double>
typedef double const_param_type; typedef double const_param_type;
typedef double member_type; typedef double member_type;
enum { type = Param::REAL }; static const Param type = Param::REAL;
}; };
template<> struct ParamType<String> template<> struct ParamType<String>
@ -3186,7 +3187,7 @@ template<> struct ParamType<String>
typedef const String& const_param_type; typedef const String& const_param_type;
typedef String member_type; typedef String member_type;
enum { type = Param::STRING }; static const Param type = Param::STRING;
}; };
template<> struct ParamType<Mat> template<> struct ParamType<Mat>
@ -3194,7 +3195,7 @@ template<> struct ParamType<Mat>
typedef const Mat& const_param_type; typedef const Mat& const_param_type;
typedef Mat member_type; typedef Mat member_type;
enum { type = Param::MAT }; static const Param type = Param::MAT;
}; };
template<> struct ParamType<std::vector<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 const std::vector<Mat>& const_param_type;
typedef std::vector<Mat> member_type; typedef std::vector<Mat> member_type;
enum { type = Param::MAT_VECTOR }; static const Param type = Param::MAT_VECTOR;
}; };
template<> struct ParamType<Algorithm> template<> struct ParamType<Algorithm>
@ -3210,7 +3211,7 @@ template<> struct ParamType<Algorithm>
typedef const Ptr<Algorithm>& const_param_type; typedef const Ptr<Algorithm>& const_param_type;
typedef Ptr<Algorithm> member_type; typedef Ptr<Algorithm> member_type;
enum { type = Param::ALGORITHM }; static const Param type = Param::ALGORITHM;
}; };
template<> struct ParamType<float> template<> struct ParamType<float>
@ -3218,7 +3219,7 @@ template<> struct ParamType<float>
typedef float const_param_type; typedef float const_param_type;
typedef float member_type; typedef float member_type;
enum { type = Param::FLOAT }; static const Param type = Param::FLOAT;
}; };
template<> struct ParamType<unsigned> template<> struct ParamType<unsigned>
@ -3226,7 +3227,7 @@ template<> struct ParamType<unsigned>
typedef unsigned const_param_type; typedef unsigned const_param_type;
typedef unsigned member_type; typedef unsigned member_type;
enum { type = Param::UNSIGNED_INT }; static const Param type = Param::UNSIGNED_INT;
}; };
template<> struct ParamType<uint64> template<> struct ParamType<uint64>
@ -3234,7 +3235,7 @@ template<> struct ParamType<uint64>
typedef uint64 const_param_type; typedef uint64 const_param_type;
typedef uint64 member_type; typedef uint64 member_type;
enum { type = Param::UINT64 }; static const Param type = Param::UINT64;
}; };
template<> struct ParamType<uchar> template<> struct ParamType<uchar>
@ -3242,7 +3243,7 @@ template<> struct ParamType<uchar>
typedef uchar const_param_type; typedef uchar const_param_type;
typedef uchar member_type; typedef uchar member_type;
enum { type = Param::UCHAR }; static const Param type = Param::UCHAR;
}; };
template<> struct ParamType<Scalar> template<> struct ParamType<Scalar>
@ -3250,7 +3251,16 @@ template<> struct ParamType<Scalar>
typedef const Scalar& const_param_type; typedef const Scalar& const_param_type;
typedef Scalar member_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 //! @} core_basic

@ -440,17 +440,17 @@ configurations while CV_DbgAssert is only retained in the Debug configuration.
#endif #endif
#define CV_Assert_1 CV_Assert #define CV_Assert_1 CV_Assert
#define CV_Assert_2( expr1, expr2 ) CV_Assert_1(expr1); CV_Assert_1(expr2) #define CV_Assert_2( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_1( __VA_ARGS__ ))
#define CV_Assert_3( expr1, expr2, expr3 ) CV_Assert_2(expr1, expr2); CV_Assert_1(expr3) #define CV_Assert_3( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_2( __VA_ARGS__ ))
#define CV_Assert_4( expr1, expr2, expr3, expr4 ) CV_Assert_3(expr1, expr2, expr3); CV_Assert_1(expr4) #define CV_Assert_4( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_3( __VA_ARGS__ ))
#define CV_Assert_5( expr1, expr2, expr3, expr4, expr5 ) CV_Assert_4(expr1, expr2, expr3, expr4); CV_Assert_1(expr5) #define CV_Assert_5( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_4( __VA_ARGS__ ))
#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_6( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_5( __VA_ARGS__ ))
#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_7( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_6( __VA_ARGS__ ))
#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_8( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_7( __VA_ARGS__ ))
#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_9( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_8( __VA_ARGS__ ))
#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_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 //! @endcond
@ -467,7 +467,7 @@ configurations while CV_DbgAssert is only retained in the Debug configuration.
*/ */
struct CV_EXPORTS Hamming struct CV_EXPORTS Hamming
{ {
enum { normType = NORM_HAMMING }; static const NormTypes normType = NORM_HAMMING;
typedef unsigned char ValueType; typedef unsigned char ValueType;
typedef int ResultType; typedef int ResultType;

@ -80,7 +80,7 @@ namespace cv { namespace debug_build_guard { } using namespace debug_build_guard
#endif #endif
#define __CV_VA_NUM_ARGS_HELPER(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N #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 problematic defines sometimes defined by system headers (windows.h in particular)
#undef small #undef small
@ -330,6 +330,142 @@ Cv64suf;
# define MAX(a,b) ((a) < (b) ? (b) : (a)) # define MAX(a,b) ((a) < (b) ? (b) : (a))
#endif #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 * * static analysys *
\****************************************************************************************/ \****************************************************************************************/

@ -61,8 +61,10 @@ namespace cv
//! @addtogroup core_basic //! @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 }; 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 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 class CV_EXPORTS _InputArray
{ {
public: public:
enum { enum KindFlag {
KIND_SHIFT = 16, KIND_SHIFT = 16,
FIXED_TYPE = 0x8000 << KIND_SHIFT, FIXED_TYPE = 0x8000 << KIND_SHIFT,
FIXED_SIZE = 0x4000 << KIND_SHIFT, FIXED_SIZE = 0x4000 << KIND_SHIFT,
@ -221,7 +223,7 @@ public:
void* getObj() const; void* getObj() const;
Size getSz() const; Size getSz() const;
int kind() const; _InputArray::KindFlag kind() const;
int dims(int i=-1) const; int dims(int i=-1) const;
int cols(int i=-1) const; int cols(int i=-1) const;
int rows(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);
void init(int _flags, const void* _obj, Size _sz); 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 /** @brief This type is very similar to InputArray except that it is used for input/output and output function
parameters. parameters.
@ -287,7 +290,7 @@ generators:
class CV_EXPORTS _OutputArray : public _InputArray class CV_EXPORTS _OutputArray : public _InputArray
{ {
public: public:
enum enum DepthMask
{ {
DEPTH_MASK_8U = 1 << CV_8U, DEPTH_MASK_8U = 1 << CV_8U,
DEPTH_MASK_8S = 1 << CV_8S, DEPTH_MASK_8S = 1 << CV_8S,
@ -356,9 +359,9 @@ public:
std::vector<cuda::GpuMat>& getGpuMatVecRef() const; std::vector<cuda::GpuMat>& getGpuMatVecRef() const;
ogl::Buffer& getOGlBufferRef() const; ogl::Buffer& getOGlBufferRef() const;
cuda::HostMem& getHostMemRef() const; cuda::HostMem& getHostMemRef() const;
void create(Size sz, 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, int fixedDepthMask=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, int fixedDepthMask=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 createSameSize(const _InputArray& arr, int mtype) const;
void release() const; void release() const;
void clear() const; void clear() const;
@ -467,10 +470,10 @@ public:
// uchar*& datastart, uchar*& data, size_t* step) = 0; // uchar*& datastart, uchar*& data, size_t* step) = 0;
//virtual void deallocate(int* refcount, uchar* datastart, uchar* data) = 0; //virtual void deallocate(int* refcount, uchar* datastart, uchar* data) = 0;
virtual UMatData* allocate(int dims, const int* sizes, int type, virtual UMatData* allocate(int dims, const int* sizes, int type,
void* data, size_t* step, int flags, UMatUsageFlags usageFlags) const = 0; void* data, size_t* step, AccessFlag flags, UMatUsageFlags usageFlags) const = 0;
virtual bool allocate(UMatData* data, int accessflags, UMatUsageFlags usageFlags) const = 0; virtual bool allocate(UMatData* data, AccessFlag accessflags, UMatUsageFlags usageFlags) const = 0;
virtual void deallocate(UMatData* data) 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 unmap(UMatData* data) const;
virtual void download(UMatData* data, void* dst, int dims, const size_t sz[], virtual void download(UMatData* data, void* dst, int dims, const size_t sz[],
const size_t srcofs[], const size_t srcstep[], const size_t srcofs[], const size_t srcstep[],
@ -523,7 +526,7 @@ protected:
// it should be explicitly initialized using init(). // it should be explicitly initialized using init().
struct CV_EXPORTS UMatData 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, DEVICE_COPY_OBSOLETE=4, TEMP_UMAT=8, TEMP_COPIED_UMAT=24,
USER_ALLOCATED=32, DEVICE_MEM_MAPPED=64, USER_ALLOCATED=32, DEVICE_MEM_MAPPED=64,
ASYNC_CLEANUP=128 ASYNC_CLEANUP=128
@ -553,13 +556,14 @@ struct CV_EXPORTS UMatData
uchar* origdata; uchar* origdata;
size_t size; size_t size;
int flags; UMatData::MemoryFlag flags;
void* handle; void* handle;
void* userdata; void* userdata;
int allocatorFlags_; int allocatorFlags_;
int mapcount; int mapcount;
UMatData* originalUMatData; UMatData* originalUMatData;
}; };
CV_ENUM_FLAGS(UMatData::MemoryFlag);
struct CV_EXPORTS MatSize struct CV_EXPORTS MatSize
@ -1061,7 +1065,7 @@ public:
Mat& operator = (const MatExpr& expr); Mat& operator = (const MatExpr& expr);
//! retrieve UMat from Mat //! 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. /** @brief Creates a matrix header for the specified matrix row.
@ -2420,7 +2424,7 @@ public:
//! assignment operators //! assignment operators
UMat& operator = (const UMat& m); UMat& operator = (const UMat& m);
Mat getMat(int flags) const; Mat getMat(AccessFlag flags) const;
//! returns a new matrix header for the specified row //! returns a new matrix header for the specified row
UMat row(int y) const; 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 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. returned to the OpenCV buffer pool.
*/ */
void* handle(int accessFlags) const; void* handle(AccessFlag accessFlags) const;
void ndoffset(size_t* ofs) 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 }; 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 int _InputArray::getFlags() const { return flags; }
inline Size _InputArray::getSz() const { return sz; } 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(int _flags, void* _obj) { init(_flags, _obj); }
inline _InputArray::_InputArray(const Mat& m) { init(MAT+ACCESS_READ, &m); } 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); } 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() { init(NONE + ACCESS_WRITE, 0); }
inline _OutputArray::_OutputArray(int _flags, void* _obj) { init(_flags|ACCESS_WRITE, _obj); } 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(Mat& m) { init(MAT+ACCESS_WRITE, &m); }
inline _OutputArray::_OutputArray(std::vector<Mat>& vec) { init(STD_VECTOR_MAT+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(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<UMat>& vec) { init(STD_VECTOR_UMAT + ACCESS_WRITE, &vec); }
template<typename _Tp> inline template<typename _Tp> inline
_OutputArray::_OutputArray(std::vector<_Tp>& vec) _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() { init(0+ACCESS_RW, 0); }
inline _InputOutputArray::_InputOutputArray(int _flags, void* _obj) { init(_flags|ACCESS_RW, _obj); } 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(Mat& m) { init(MAT+ACCESS_RW, &m); }
inline _InputOutputArray::_InputOutputArray(std::vector<Mat>& vec) { init(STD_VECTOR_MAT+ACCESS_RW, &vec); } inline _InputOutputArray::_InputOutputArray(std::vector<Mat>& vec) { init(STD_VECTOR_MAT+ACCESS_RW, &vec); }
inline _InputOutputArray::_InputOutputArray(UMat& m) { init(UMAT+ACCESS_RW, &m); } 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 template<typename _Tp> inline
Mat::Mat(const std::vector<_Tp>& vec, bool copyData) 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) cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
{ {
if(vec.empty()) 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 template<typename _Tp, std::size_t _Nm> inline
Mat::Mat(const std::array<_Tp, _Nm>& arr, bool copyData) 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) cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
{ {
if(arr.empty()) if(arr.empty())
@ -654,7 +654,7 @@ Mat::Mat(const std::array<_Tp, _Nm>& arr, bool copyData)
template<typename _Tp, int n> inline template<typename _Tp, int n> inline
Mat::Mat(const Vec<_Tp, n>& vec, bool copyData) 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) datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
{ {
if( !copyData ) if( !copyData )
@ -670,7 +670,7 @@ Mat::Mat(const Vec<_Tp, n>& vec, bool copyData)
template<typename _Tp, int m, int n> inline template<typename _Tp, int m, int n> inline
Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData) 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) datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
{ {
if( !copyData ) if( !copyData )
@ -686,7 +686,7 @@ Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData)
template<typename _Tp> inline template<typename _Tp> inline
Mat::Mat(const Point_<_Tp>& pt, bool copyData) 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) datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
{ {
if( !copyData ) if( !copyData )
@ -705,7 +705,7 @@ Mat::Mat(const Point_<_Tp>& pt, bool copyData)
template<typename _Tp> inline template<typename _Tp> inline
Mat::Mat(const Point3_<_Tp>& pt, bool copyData) 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) datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
{ {
if( !copyData ) if( !copyData )
@ -725,7 +725,7 @@ Mat::Mat(const Point3_<_Tp>& pt, bool copyData)
template<typename _Tp> inline template<typename _Tp> inline
Mat::Mat(const MatCommaInitializer_<_Tp>& commaInitializer) 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) datastart(0), dataend(0), allocator(0), u(0), size(&rows)
{ {
*this = commaInitializer.operator Mat_<_Tp>(); *this = commaInitializer.operator Mat_<_Tp>();
@ -1554,7 +1554,7 @@ template<typename _Tp> inline
Mat_<_Tp>::Mat_() Mat_<_Tp>::Mat_()
: 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 template<typename _Tp> inline
@ -1611,7 +1611,7 @@ template<typename _Tp> inline
Mat_<_Tp>::Mat_(const Mat& m) Mat_<_Tp>::Mat_(const Mat& m)
: Mat() : Mat()
{ {
flags = (flags & ~CV_MAT_TYPE_MASK) | traits::Type<_Tp>::value; flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value;
*this = m; *this = m;
} }
@ -1751,7 +1751,7 @@ void Mat_<_Tp>::release()
{ {
Mat::release(); Mat::release();
#ifdef _DEBUG #ifdef _DEBUG
flags = (flags & ~CV_MAT_TYPE_MASK) | traits::Type<_Tp>::value; flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value;
#endif #endif
} }
@ -2069,7 +2069,7 @@ template<typename _Tp> inline
Mat_<_Tp>::Mat_(Mat&& m) Mat_<_Tp>::Mat_(Mat&& m)
: Mat() : Mat()
{ {
flags = (flags & ~CV_MAT_TYPE_MASK) | traits::Type<_Tp>::value; flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value;
*this = m; *this = m;
} }
@ -2095,7 +2095,7 @@ template<typename _Tp> inline
Mat_<_Tp>::Mat_(MatExpr&& e) Mat_<_Tp>::Mat_(MatExpr&& e)
: Mat() : Mat()
{ {
flags = (flags & ~CV_MAT_TYPE_MASK) | traits::Type<_Tp>::value; flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value;
*this = Mat(e); *this = Mat(e);
} }
@ -2431,7 +2431,7 @@ SparseMatConstIterator_<_Tp> SparseMat::end() const
template<typename _Tp> inline template<typename _Tp> inline
SparseMat_<_Tp>::SparseMat_() SparseMat_<_Tp>::SparseMat_()
{ {
flags = MAGIC_VAL | traits::Type<_Tp>::value; flags = MAGIC_VAL + traits::Type<_Tp>::value;
} }
template<typename _Tp> inline template<typename _Tp> inline
@ -3654,7 +3654,7 @@ UMat::UMat(const UMat& m)
template<typename _Tp> inline template<typename _Tp> inline
UMat::UMat(const std::vector<_Tp>& vec, bool copyData) 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) cols(1), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows)
{ {
if(vec.empty()) if(vec.empty())

@ -548,7 +548,7 @@ calling unmapGLBuffer() function.
@param accessFlags - data access flags (ACCESS_READ|ACCESS_WRITE). @param accessFlags - data access flags (ACCESS_READ|ACCESS_WRITE).
@return Returns UMat object @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). /** @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 ///////////////////////////////// ///////////////////////////////// Formatted output of cv::Mat /////////////////////////////////
static inline static inline
Ptr<Formatted> format(InputArray mtx, int fmt) Ptr<Formatted> format(InputArray mtx, Formatter::FormatType fmt)
{ {
return Formatter::get(fmt)->format(mtx.getMat()); 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); 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 template<typename _Tp> static inline
void write( FileStorage& fs, const String& name, const std::vector<_Tp>& vec ) 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); 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 template<typename _Tp> static inline
void read( const FileNode& node, std::vector<_Tp>& vec, const std::vector<_Tp>& default_value = std::vector<_Tp>() ) 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; void printErrors() const;
protected: protected:
void getByName(const String& name, 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, int type, void* dst) const; void getByIndex(int index, bool space_delete, Param type, void* dst) const;
struct Impl; struct Impl;
Impl* impl; Impl* impl;

@ -7,6 +7,8 @@ typedef std::vector<Range> vector_Range;
CV_PY_TO_CLASS(UMat); CV_PY_TO_CLASS(UMat);
CV_PY_FROM_CLASS(UMat); CV_PY_FROM_CLASS(UMat);
CV_PY_TO_ENUM(UMatUsageFlags); 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) 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 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. 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) // offset of the submatrix (or 0)
CV_PROP_RW size_t offset; CV_PROP_RW size_t offset;

@ -167,7 +167,7 @@ static void binary_op( InputArray _src1, InputArray _src2, OutputArray _dst,
bool bitwise, int oclop ) bool bitwise, int oclop )
{ {
const _InputArray *psrc1 = &_src1, *psrc2 = &_src2; 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 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 type2 = psrc2->type(), depth2 = CV_MAT_DEPTH(type2), cn2 = CV_MAT_CN(type2);
int dims1 = psrc1->dims(), dims2 = psrc2->dims(); 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 ) void* usrdata=0, int oclop=-1 )
{ {
const _InputArray *psrc1 = &_src1, *psrc2 = &_src2; 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 haveMask = !_mask.empty();
bool reallocate = false; bool reallocate = false;
int type1 = psrc1->type(), depth1 = CV_MAT_DEPTH(type1), cn = CV_MAT_CN(type1); 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()), CV_OCL_RUN(_src1.dims() <= 2 && _src2.dims() <= 2 && OCL_PERFORMANCE_CHECK(_dst.isUMat()),
ocl_compare(_src1, _src2, _dst, op, haveScalar)) 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(); Mat src1 = _src1.getMat(), src2 = _src2.getMat();
if( kind1 == kind2 && src1.dims <= 2 && src2.dims <= 2 && src1.size() == src2.size() && src1.type() == src2.type() ) 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 ) InputArray _upperb, OutputArray _dst )
{ {
const ocl::Device & d = ocl::Device::getDefault(); 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(); Size ssize = _src.size(), lsize = _lowerb.size(), usize = _upperb.size();
int stype = _src.type(), ltype = _lowerb.type(), utype = _upperb.type(); 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); 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()), _upperb.dims() <= 2 && OCL_PERFORMANCE_CHECK(_dst.isUMat()),
ocl_inRange(_src, _lowerb, _upperb, _dst)) 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(); Mat src = _src.getMat(), lb = _lowerb.getMat(), ub = _upperb.getMat();
bool lbScalar = false, ubScalar = false; 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 ) if( type == Param::INT )
return "int"; return "int";
@ -81,7 +81,7 @@ static bool parse_bool(std::string str)
return b; 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()); std::stringstream ss(str.c_str());
if( type == Param::INT ) 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 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 CV_TRY
{ {

@ -60,7 +60,7 @@ public:
UMatData* allocate(int dims, const int* sizes, int type, UMatData* allocate(int dims, const int* sizes, int type,
void* data0, size_t* step, 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); size_t total = CV_ELEM_SIZE(type);
for (int i = dims-1; i >= 0; i--) for (int i = dims-1; i >= 0; i--)
@ -100,7 +100,7 @@ public:
return u; 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); return (u != NULL);
} }

@ -7,7 +7,7 @@
namespace cv { 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: public:
UMatData* allocate(int dims, const int* sizes, int type, 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); size_t total = CV_ELEM_SIZE(type);
for( int i = dims-1; i >= 0; i-- ) for( int i = dims-1; i >= 0; i-- )
@ -154,7 +154,7 @@ public:
return u; 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; if(!u) return false;
return true; return true;
@ -357,13 +357,13 @@ void Mat::create(int d, const int* _sizes, int _type)
a = a0; a = a0;
CV_TRY 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_Assert(u != 0);
} }
CV_CATCH_ALL CV_CATCH_ALL
{ {
if(a != a0) 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(u != 0);
} }
CV_Assert( step[dims-1] == (size_t)CV_ELEM_SIZE(flags) ); CV_Assert( step[dims-1] == (size_t)CV_ELEM_SIZE(flags) );

@ -14,8 +14,8 @@ namespace cv {
Mat _InputArray::getMat_(int i) const Mat _InputArray::getMat_(int i) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
int accessFlags = flags & ACCESS_MASK; AccessFlag accessFlags = flags & ACCESS_MASK;
if( k == MAT ) if( k == MAT )
{ {
@ -132,8 +132,8 @@ Mat _InputArray::getMat_(int i) const
UMat _InputArray::getUMat(int i) const UMat _InputArray::getUMat(int i) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
int accessFlags = flags & ACCESS_MASK; AccessFlag accessFlags = flags & ACCESS_MASK;
if( k == UMAT ) if( k == UMAT )
{ {
@ -164,8 +164,8 @@ UMat _InputArray::getUMat(int i) const
void _InputArray::getMatVector(std::vector<Mat>& mv) const void _InputArray::getMatVector(std::vector<Mat>& mv) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
int accessFlags = flags & ACCESS_MASK; AccessFlag accessFlags = flags & ACCESS_MASK;
if( k == MAT ) if( k == MAT )
{ {
@ -272,8 +272,8 @@ void _InputArray::getMatVector(std::vector<Mat>& mv) const
void _InputArray::getUMatVector(std::vector<UMat>& umv) const void _InputArray::getUMatVector(std::vector<UMat>& umv) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
int accessFlags = flags & ACCESS_MASK; AccessFlag accessFlags = flags & ACCESS_MASK;
if( k == NONE ) if( k == NONE )
{ {
@ -334,7 +334,7 @@ void _InputArray::getUMatVector(std::vector<UMat>& umv) const
cuda::GpuMat _InputArray::getGpuMat() const cuda::GpuMat _InputArray::getGpuMat() const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
if (k == CUDA_GPU_MAT) if (k == CUDA_GPU_MAT)
{ {
@ -360,7 +360,7 @@ cuda::GpuMat _InputArray::getGpuMat() const
} }
void _InputArray::getGpuMatVector(std::vector<cuda::GpuMat>& gpumv) const void _InputArray::getGpuMatVector(std::vector<cuda::GpuMat>& gpumv) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
if (k == STD_VECTOR_CUDA_GPU_MAT) if (k == STD_VECTOR_CUDA_GPU_MAT)
{ {
gpumv = *(std::vector<cuda::GpuMat>*)obj; gpumv = *(std::vector<cuda::GpuMat>*)obj;
@ -368,7 +368,7 @@ void _InputArray::getGpuMatVector(std::vector<cuda::GpuMat>& gpumv) const
} }
ogl::Buffer _InputArray::getOGlBuffer() const ogl::Buffer _InputArray::getOGlBuffer() const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
CV_Assert(k == OPENGL_BUFFER); CV_Assert(k == OPENGL_BUFFER);
@ -376,7 +376,7 @@ ogl::Buffer _InputArray::getOGlBuffer() const
return *gl_buf; return *gl_buf;
} }
int _InputArray::kind() const _InputArray::KindFlag _InputArray::kind() const
{ {
return flags & KIND_MASK; return flags & KIND_MASK;
} }
@ -393,7 +393,7 @@ int _InputArray::cols(int i) const
Size _InputArray::size(int i) const Size _InputArray::size(int i) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
if( k == MAT ) if( k == MAT )
{ {
@ -515,7 +515,8 @@ Size _InputArray::size(int i) const
int _InputArray::sizend(int* arrsz, 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 ) if( k == NONE )
; ;
@ -583,7 +584,7 @@ int _InputArray::sizend(int* arrsz, int i) const
bool _InputArray::sameSize(const _InputArray& arr) const bool _InputArray::sameSize(const _InputArray& arr) const
{ {
int k1 = kind(), k2 = arr.kind(); _InputArray::KindFlag k1 = kind(), k2 = arr.kind();
Size sz1; Size sz1;
if( k1 == MAT ) if( k1 == MAT )
@ -617,7 +618,7 @@ bool _InputArray::sameSize(const _InputArray& arr) const
int _InputArray::dims(int i) const int _InputArray::dims(int i) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
if( k == MAT ) if( k == MAT )
{ {
@ -714,7 +715,7 @@ int _InputArray::dims(int i) const
size_t _InputArray::total(int i) const size_t _InputArray::total(int i) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
if( k == MAT ) if( k == MAT )
{ {
@ -763,7 +764,7 @@ size_t _InputArray::total(int i) const
int _InputArray::type(int i) const int _InputArray::type(int i) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
if( k == MAT ) if( k == MAT )
return ((const Mat*)obj)->type(); return ((const Mat*)obj)->type();
@ -852,7 +853,7 @@ int _InputArray::channels(int i) const
bool _InputArray::empty() const bool _InputArray::empty() const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
if( k == MAT ) if( k == MAT )
return ((const Mat*)obj)->empty(); return ((const Mat*)obj)->empty();
@ -924,7 +925,7 @@ bool _InputArray::empty() const
bool _InputArray::isContinuous(int i) const bool _InputArray::isContinuous(int i) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
if( k == MAT ) if( k == MAT )
return i < 0 ? ((const Mat*)obj)->isContinuous() : true; return i < 0 ? ((const Mat*)obj)->isContinuous() : true;
@ -965,7 +966,7 @@ bool _InputArray::isContinuous(int i) const
bool _InputArray::isSubmatrix(int i) const bool _InputArray::isSubmatrix(int i) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
if( k == MAT ) if( k == MAT )
return i < 0 ? ((const Mat*)obj)->isSubmatrix() : false; 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 size_t _InputArray::offset(int i) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
if( k == MAT ) if( k == MAT )
{ {
@ -1067,7 +1068,7 @@ size_t _InputArray::offset(int i) const
size_t _InputArray::step(int i) const size_t _InputArray::step(int i) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
if( k == MAT ) if( k == MAT )
{ {
@ -1127,7 +1128,7 @@ size_t _InputArray::step(int i) const
void _InputArray::copyTo(const _OutputArray& arr) const void _InputArray::copyTo(const _OutputArray& arr) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
if( k == NONE ) if( k == NONE )
arr.release(); arr.release();
@ -1156,7 +1157,7 @@ void _InputArray::copyTo(const _OutputArray& arr) const
void _InputArray::copyTo(const _OutputArray& arr, const _InputArray & mask) const void _InputArray::copyTo(const _OutputArray& arr, const _InputArray & mask) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
if( k == NONE ) if( k == NONE )
arr.release(); arr.release();
@ -1185,9 +1186,9 @@ bool _OutputArray::fixedType() const
return (flags & FIXED_TYPE) == FIXED_TYPE; 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 ) if( k == MAT && i < 0 && !allowTransposed && fixedDepthMask == 0 )
{ {
CV_Assert(!fixedSize() || ((Mat*)obj)->size.operator()() == _sz); 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); 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 ) if( k == MAT && i < 0 && !allowTransposed && fixedDepthMask == 0 )
{ {
CV_Assert(!fixedSize() || ((Mat*)obj)->size.operator()() == Size(_cols, _rows)); 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, 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]; int sizebuf[2];
if(d == 1) if(d == 1)
@ -1280,7 +1281,7 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i,
sizebuf[1] = 1; sizebuf[1] = 1;
sizes = sizebuf; sizes = sizebuf;
} }
int k = kind(); _InputArray::KindFlag k = kind();
mtype = CV_MAT_TYPE(mtype); mtype = CV_MAT_TYPE(mtype);
if( k == MAT ) if( k == MAT )
@ -1667,7 +1668,7 @@ void _OutputArray::release() const
{ {
CV_Assert(!fixedSize()); CV_Assert(!fixedSize());
int k = kind(); _InputArray::KindFlag k = kind();
if( k == MAT ) if( k == MAT )
{ {
@ -1735,7 +1736,7 @@ void _OutputArray::release() const
void _OutputArray::clear() const void _OutputArray::clear() const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
if( k == MAT ) if( k == MAT )
{ {
@ -1754,7 +1755,7 @@ bool _OutputArray::needed() const
Mat& _OutputArray::getMatRef(int i) const Mat& _OutputArray::getMatRef(int i) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
if( i < 0 ) if( i < 0 )
{ {
CV_Assert( k == MAT ); CV_Assert( k == MAT );
@ -1779,7 +1780,7 @@ Mat& _OutputArray::getMatRef(int i) const
UMat& _OutputArray::getUMatRef(int i) const UMat& _OutputArray::getUMatRef(int i) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
if( i < 0 ) if( i < 0 )
{ {
CV_Assert( k == UMAT ); CV_Assert( k == UMAT );
@ -1796,34 +1797,34 @@ UMat& _OutputArray::getUMatRef(int i) const
cuda::GpuMat& _OutputArray::getGpuMatRef() const cuda::GpuMat& _OutputArray::getGpuMatRef() const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
CV_Assert( k == CUDA_GPU_MAT ); CV_Assert( k == CUDA_GPU_MAT );
return *(cuda::GpuMat*)obj; return *(cuda::GpuMat*)obj;
} }
std::vector<cuda::GpuMat>& _OutputArray::getGpuMatVecRef() const std::vector<cuda::GpuMat>& _OutputArray::getGpuMatVecRef() const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
CV_Assert(k == STD_VECTOR_CUDA_GPU_MAT); CV_Assert(k == STD_VECTOR_CUDA_GPU_MAT);
return *(std::vector<cuda::GpuMat>*)obj; return *(std::vector<cuda::GpuMat>*)obj;
} }
ogl::Buffer& _OutputArray::getOGlBufferRef() const ogl::Buffer& _OutputArray::getOGlBufferRef() const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
CV_Assert( k == OPENGL_BUFFER ); CV_Assert( k == OPENGL_BUFFER );
return *(ogl::Buffer*)obj; return *(ogl::Buffer*)obj;
} }
cuda::HostMem& _OutputArray::getHostMemRef() const cuda::HostMem& _OutputArray::getHostMemRef() const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
CV_Assert( k == CUDA_HOST_MEM ); CV_Assert( k == CUDA_HOST_MEM );
return *(cuda::HostMem*)obj; return *(cuda::HostMem*)obj;
} }
void _OutputArray::setTo(const _InputArray& arr, const _InputArray & mask) const void _OutputArray::setTo(const _InputArray& arr, const _InputArray & mask) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
if( k == NONE ) if( k == NONE )
; ;
@ -1847,7 +1848,7 @@ void _OutputArray::setTo(const _InputArray& arr, const _InputArray & mask) const
void _OutputArray::assign(const UMat& u) const void _OutputArray::assign(const UMat& u) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
if (k == UMAT) if (k == UMAT)
{ {
*(UMat*)obj = u; *(UMat*)obj = u;
@ -1869,7 +1870,7 @@ void _OutputArray::assign(const UMat& u) const
void _OutputArray::assign(const Mat& m) const void _OutputArray::assign(const Mat& m) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
if (k == UMAT) if (k == UMAT)
{ {
m.copyTo(*(UMat*)obj); // TODO check m.getUMat() 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 void _OutputArray::assign(const std::vector<UMat>& v) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
if (k == STD_VECTOR_UMAT) if (k == STD_VECTOR_UMAT)
{ {
std::vector<UMat>& this_v = *(std::vector<UMat>*)obj; 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 void _OutputArray::assign(const std::vector<Mat>& v) const
{ {
int k = kind(); _InputArray::KindFlag k = kind();
if (k == STD_VECTOR_UMAT) if (k == STD_VECTOR_UMAT)
{ {
std::vector<UMat>& this_v = *(std::vector<UMat>*)obj; std::vector<UMat>& this_v = *(std::vector<UMat>*)obj;

@ -2972,8 +2972,8 @@ int Kernel::set(int i, const KernelArg& arg)
cl_int status = 0; cl_int status = 0;
if( arg.m ) if( arg.m )
{ {
int accessFlags = ((arg.flags & KernelArg::READ_ONLY) ? ACCESS_READ : 0) + AccessFlag accessFlags = ((arg.flags & KernelArg::READ_ONLY) ? ACCESS_READ : static_cast<AccessFlag>(0)) |
((arg.flags & KernelArg::WRITE_ONLY) ? ACCESS_WRITE : 0); ((arg.flags & KernelArg::WRITE_ONLY) ? ACCESS_WRITE : static_cast<AccessFlag>(0));
bool ptronly = (arg.flags & KernelArg::PTR_ONLY) != 0; bool ptronly = (arg.flags & KernelArg::PTR_ONLY) != 0;
cl_mem h = (cl_mem)arg.m->handle(accessFlags); cl_mem h = (cl_mem)arg.m->handle(accessFlags);
@ -3050,7 +3050,7 @@ int Kernel::set(int i, const KernelArg& arg)
i += 3; i += 3;
} }
} }
p->addUMat(*arg.m, (accessFlags & ACCESS_WRITE) != 0); p->addUMat(*arg.m, !!(accessFlags & ACCESS_WRITE));
return i; return i;
} }
status = clSetKernelArg(p->handle, (cl_uint)i, arg.sz, arg.obj); 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, 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); UMatData* u = matStdAllocator->allocate(dims, sizes, type, data, step, flags, usageFlags);
return u; 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); const Device& dev = ctx.device(0);
createFlags = 0; createFlags = 0;
@ -4530,13 +4530,13 @@ public:
createFlags |= CL_MEM_ALLOC_HOST_PTR; createFlags |= CL_MEM_ALLOC_HOST_PTR;
if( dev.hostUnifiedMemory() ) if( dev.hostUnifiedMemory() )
flags0 = 0; flags0 = static_cast<UMatData::MemoryFlag>(0);
else else
flags0 = UMatData::COPY_ON_MAP; flags0 = UMatData::COPY_ON_MAP;
} }
UMatData* allocate(int dims, const int* sizes, int type, 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()) if(!useOpenCL())
return defaultAllocate(dims, sizes, type, data, step, flags, usageFlags); return defaultAllocate(dims, sizes, type, data, step, flags, usageFlags);
@ -4552,7 +4552,8 @@ public:
Context& ctx = Context::getDefault(); Context& ctx = Context::getDefault();
flushCleanupQueue(); flushCleanupQueue();
int createFlags = 0, flags0 = 0; int createFlags = 0;
UMatData::MemoryFlag flags0 = static_cast<UMatData::MemoryFlag>(0);
getBestFlags(ctx, flags, usageFlags, createFlags, flags0); getBestFlags(ctx, flags, usageFlags, createFlags, flags0);
void* handle = NULL; void* handle = NULL;
@ -4600,7 +4601,7 @@ public:
return u; 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) if(!u)
return false; return false;
@ -4613,12 +4614,13 @@ public:
{ {
CV_Assert(u->origdata != 0); CV_Assert(u->origdata != 0);
Context& ctx = Context::getDefault(); 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); getBestFlags(ctx, accessFlags, usageFlags, createFlags, flags0);
cl_context ctx_handle = (cl_context)ctx.ptr(); cl_context ctx_handle = (cl_context)ctx.ptr();
int allocatorFlags = 0; int allocatorFlags = 0;
int tempUMatFlags = 0; UMatData::MemoryFlag tempUMatFlags = static_cast<UMatData::MemoryFlag>(0);
void* handle = NULL; void* handle = NULL;
cl_int retval = CL_SUCCESS; cl_int retval = CL_SUCCESS;
@ -4703,7 +4705,7 @@ public:
u->flags |= tempUMatFlags; u->flags |= tempUMatFlags;
u->allocatorFlags_ = allocatorFlags; u->allocatorFlags_ = allocatorFlags;
} }
if(accessFlags & ACCESS_WRITE) if (!!(accessFlags & ACCESS_WRITE))
u->markHostCopyObsolete(true); u->markHostCopyObsolete(true);
return true; return true;
} }
@ -4749,7 +4751,7 @@ public:
CV_Assert(u->handle != 0); CV_Assert(u->handle != 0);
CV_Assert(u->mapcount == 0); CV_Assert(u->mapcount == 0);
if (u->flags & UMatData::ASYNC_CLEANUP) if (!!(u->flags & UMatData::ASYNC_CLEANUP))
addToCleanupQueue(u); addToCleanupQueue(u);
else else
deallocate_(u); deallocate_(u);
@ -4924,11 +4926,11 @@ public:
} }
// synchronized call (external UMatDataAutoLock, see UMat::getMat) // 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); CV_Assert(u && u->handle);
if(accessFlags & ACCESS_WRITE) if (!!(accessFlags & ACCESS_WRITE))
u->markDeviceCopyObsolete(true); u->markDeviceCopyObsolete(true);
cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr(); 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); AlignedDataPtr<false, true> alignedPtr(u->data, u->size, CV_OPENCL_DATA_PTR_ALIGNMENT);
#ifdef HAVE_OPENCL_SVM #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 = new UMatData(getOpenCLAllocator());
dst.u->data = 0; dst.u->data = 0;
dst.u->allocatorFlags_ = 0; // not allocated from any OpenCV buffer pool 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->handle = cl_mem_buffer;
dst.u->origdata = 0; dst.u->origdata = 0;
dst.u->prevAllocator = 0; dst.u->prevAllocator = 0;

@ -1804,8 +1804,8 @@ void convertFromGLTexture2D(const Texture2D& texture, OutputArray dst)
#endif #endif
} }
//void mapGLBuffer(const Buffer& buffer, UMat& dst, int accessFlags) //void mapGLBuffer(const Buffer& buffer, UMat& dst, AccessFlag accessFlags)
UMat mapGLBuffer(const Buffer& buffer, int accessFlags) UMat mapGLBuffer(const Buffer& buffer, AccessFlag accessFlags)
{ {
CV_UNUSED(buffer); CV_UNUSED(accessFlags); CV_UNUSED(buffer); CV_UNUSED(accessFlags);
#if !defined(HAVE_OPENGL) #if !defined(HAVE_OPENGL)

@ -372,7 +372,7 @@ namespace cv
Formatted::~Formatted() {} Formatted::~Formatted() {}
Formatter::~Formatter() {} Formatter::~Formatter() {}
Ptr<Formatter> Formatter::get(int fmt) Ptr<Formatter> Formatter::get(Formatter::FormatType fmt)
{ {
switch(fmt) switch(fmt)
{ {

@ -210,7 +210,7 @@ enum { BLOCK_SIZE = 1024 };
#define ARITHM_USE_IPP 0 #define ARITHM_USE_IPP 0
#endif #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() ) if( sc.dims > 2 || !sc.isContinuous() )
return false; 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); (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() ) if( sc.dims() > 2 || !sc.isContinuous() )
return false; return false;

@ -64,7 +64,7 @@ UMatData::UMatData(const MatAllocator* allocator)
urefcount = refcount = mapcount = 0; urefcount = refcount = mapcount = 0;
data = origdata = 0; data = origdata = 0;
size = 0; size = 0;
flags = 0; flags = static_cast<UMatData::MemoryFlag>(0);
handle = 0; handle = 0;
userdata = 0; userdata = 0;
allocatorFlags_ = 0; allocatorFlags_ = 0;
@ -78,7 +78,7 @@ UMatData::~UMatData()
CV_Assert(mapcount == 0); CV_Assert(mapcount == 0);
data = origdata = 0; data = origdata = 0;
size = 0; size = 0;
flags = 0; flags = static_cast<UMatData::MemoryFlag>(0);
handle = 0; handle = 0;
userdata = 0; userdata = 0;
allocatorFlags_ = 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; UMat hdr;
if(!data) if(!data)
@ -444,13 +444,13 @@ void UMat::create(int d, const int* _sizes, int _type, UMatUsageFlags _usageFlag
} }
CV_TRY 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_Assert(u != 0);
} }
CV_CATCH_ALL CV_CATCH_ALL
{ {
if(a != a0) 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(u != 0);
} }
CV_Assert( step[dims-1] == (size_t)CV_ELEM_SIZE(flags) ); 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"); 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) if(!u)
return Mat(); 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 ) if( !u )
return 0; return 0;
@ -852,7 +852,7 @@ void* UMat::handle(int accessFlags) const
u->currAllocator->unmap(u); u->currAllocator->unmap(u);
} }
if ((accessFlags & ACCESS_WRITE) != 0) if (!!(accessFlags & ACCESS_WRITE))
u->markHostCopyObsolete(true); u->markHostCopyObsolete(true);
return u->handle; 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 calcDiffElemCountImpl(const vector<Mat>& mv, const Mat& m)
{ {
int diffElemCount = 0; int diffElemCount = 0;
@ -955,12 +955,12 @@ int calcDiffElemCountImpl(const vector<Mat>& mv, const Mat& m)
{ {
for(int x = 0; x < m.cols; x++) 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; size_t loc = 0;
for(size_t i = 0; i < mv.size(); i++) for(size_t i = 0; i < mv.size(); i++)
{ {
const size_t mvChannel = mv[i].channels(); 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++) for(size_t li = 0; li < mvChannel; li++)
if(mElem[loc + li] != mvElem[li]) if(mElem[loc + li] != mvElem[li])
diffElemCount++; diffElemCount++;

@ -95,7 +95,7 @@ struct CV_EXPORTS_W DictValue
private: private:
int type; Param type;
union union
{ {
@ -105,7 +105,7 @@ private:
void *pv; void *pv;
}; };
DictValue(int _type, void *_p) : type(_type), pv(_p) {} DictValue(Param _type, void *_p) : type(_type), pv(_p) {}
void release(); void release();
}; };

@ -199,6 +199,16 @@ inline void DictValue::release()
case Param::REAL: case Param::REAL:
delete pd; delete pd;
break; break;
case Param::BOOLEAN:
case Param::MAT:
case Param::MAT_VECTOR:
case Param::ALGORITHM:
case Param::FLOAT:
case Param::UNSIGNED_INT:
case Param::UINT64:
case Param::UCHAR:
case Param::SCALAR:
break; // unhandled
} }
} }
@ -273,8 +283,18 @@ inline int DictValue::size() const
return (int)ps->size(); return (int)ps->size();
case Param::REAL: case Param::REAL:
return (int)pd->size(); return (int)pd->size();
case Param::BOOLEAN:
case Param::MAT:
case Param::MAT_VECTOR:
case Param::ALGORITHM:
case Param::FLOAT:
case Param::UNSIGNED_INT:
case Param::UINT64:
case Param::UCHAR:
case Param::SCALAR:
break; // unhandled
} }
CV_Error(Error::StsInternal, ""); CV_Error_(Error::StsInternal, ("Unhandled type (%d)", static_cast<int>(type)));
} }
inline std::ostream &operator<<(std::ostream &stream, const DictValue &dictv) inline std::ostream &operator<<(std::ostream &stream, const DictValue &dictv)

@ -293,7 +293,8 @@ k-tuples) are rotated according to the measured orientation).
class CV_EXPORTS_W ORB : public Feature2D class CV_EXPORTS_W ORB : public Feature2D
{ {
public: public:
enum { kBytes = 32, HARRIS_SCORE=0, FAST_SCORE=1 }; enum ScoreType { HARRIS_SCORE=0, FAST_SCORE=1 };
static const int kBytes = 32;
/** @brief The ORB constructor /** @brief The ORB constructor
@ -327,7 +328,7 @@ public:
@param fastThreshold @param fastThreshold
*/ */
CV_WRAP static Ptr<ORB> create(int nfeatures=500, float scaleFactor=1.2f, int nlevels=8, int edgeThreshold=31, CV_WRAP static Ptr<ORB> create(int nfeatures=500, float scaleFactor=1.2f, int nlevels=8, int edgeThreshold=31,
int firstLevel=0, int WTA_K=2, int scoreType=ORB::HARRIS_SCORE, int patchSize=31, int fastThreshold=20); int firstLevel=0, int WTA_K=2, ORB::ScoreType scoreType=ORB::HARRIS_SCORE, int patchSize=31, int fastThreshold=20);
CV_WRAP virtual void setMaxFeatures(int maxFeatures) = 0; CV_WRAP virtual void setMaxFeatures(int maxFeatures) = 0;
CV_WRAP virtual int getMaxFeatures() const = 0; CV_WRAP virtual int getMaxFeatures() const = 0;
@ -347,8 +348,8 @@ public:
CV_WRAP virtual void setWTA_K(int wta_k) = 0; CV_WRAP virtual void setWTA_K(int wta_k) = 0;
CV_WRAP virtual int getWTA_K() const = 0; CV_WRAP virtual int getWTA_K() const = 0;
CV_WRAP virtual void setScoreType(int scoreType) = 0; CV_WRAP virtual void setScoreType(ORB::ScoreType scoreType) = 0;
CV_WRAP virtual int getScoreType() const = 0; CV_WRAP virtual ORB::ScoreType getScoreType() const = 0;
CV_WRAP virtual void setPatchSize(int patchSize) = 0; CV_WRAP virtual void setPatchSize(int patchSize) = 0;
CV_WRAP virtual int getPatchSize() const = 0; CV_WRAP virtual int getPatchSize() const = 0;
@ -418,6 +419,41 @@ public:
CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; CV_WRAP virtual String getDefaultName() const CV_OVERRIDE;
}; };
//! @} features2d_main
//! @addtogroup features2d_main
//! @{
/** @brief Wrapping class for feature detection using the FAST method. :
*/
class CV_EXPORTS_W FastFeatureDetector : public Feature2D
{
public:
enum DetectorType
{
TYPE_5_8 = 0, TYPE_7_12 = 1, TYPE_9_16 = 2
};
enum
{
THRESHOLD = 10000, NONMAX_SUPPRESSION=10001, FAST_N=10002
};
CV_WRAP static Ptr<FastFeatureDetector> create( int threshold=10,
bool nonmaxSuppression=true,
FastFeatureDetector::DetectorType type=FastFeatureDetector::TYPE_9_16 );
CV_WRAP virtual void setThreshold(int threshold) = 0;
CV_WRAP virtual int getThreshold() const = 0;
CV_WRAP virtual void setNonmaxSuppression(bool f) = 0;
CV_WRAP virtual bool getNonmaxSuppression() const = 0;
CV_WRAP virtual void setType(FastFeatureDetector::DetectorType type) = 0;
CV_WRAP virtual FastFeatureDetector::DetectorType getType() const = 0;
CV_WRAP virtual String getDefaultName() const CV_OVERRIDE;
};
/** @overload */ /** @overload */
CV_EXPORTS void FAST( InputArray image, CV_OUT std::vector<KeyPoint>& keypoints, CV_EXPORTS void FAST( InputArray image, CV_OUT std::vector<KeyPoint>& keypoints,
int threshold, bool nonmaxSuppression=true ); int threshold, bool nonmaxSuppression=true );
@ -441,27 +477,31 @@ cv2.FAST_FEATURE_DETECTOR_TYPE_7_12 and cv2.FAST_FEATURE_DETECTOR_TYPE_9_16. For
detection, use cv2.FAST.detect() method. detection, use cv2.FAST.detect() method.
*/ */
CV_EXPORTS void FAST( InputArray image, CV_OUT std::vector<KeyPoint>& keypoints, CV_EXPORTS void FAST( InputArray image, CV_OUT std::vector<KeyPoint>& keypoints,
int threshold, bool nonmaxSuppression, int type ); int threshold, bool nonmaxSuppression, FastFeatureDetector::DetectorType type );
//! @} features2d_main //! @} features2d_main
//! @addtogroup features2d_main //! @addtogroup features2d_main
//! @{ //! @{
/** @brief Wrapping class for feature detection using the FAST method. : /** @brief Wrapping class for feature detection using the AGAST method. :
*/ */
class CV_EXPORTS_W FastFeatureDetector : public Feature2D class CV_EXPORTS_W AgastFeatureDetector : public Feature2D
{ {
public: public:
enum DetectorType
{
AGAST_5_8 = 0, AGAST_7_12d = 1, AGAST_7_12s = 2, OAST_9_16 = 3,
};
enum enum
{ {
TYPE_5_8 = 0, TYPE_7_12 = 1, TYPE_9_16 = 2, THRESHOLD = 10000, NONMAX_SUPPRESSION = 10001,
THRESHOLD = 10000, NONMAX_SUPPRESSION=10001, FAST_N=10002,
}; };
CV_WRAP static Ptr<FastFeatureDetector> create( int threshold=10, CV_WRAP static Ptr<AgastFeatureDetector> create( int threshold=10,
bool nonmaxSuppression=true, bool nonmaxSuppression=true,
int type=FastFeatureDetector::TYPE_9_16 ); AgastFeatureDetector::DetectorType type = AgastFeatureDetector::OAST_9_16);
CV_WRAP virtual void setThreshold(int threshold) = 0; CV_WRAP virtual void setThreshold(int threshold) = 0;
CV_WRAP virtual int getThreshold() const = 0; CV_WRAP virtual int getThreshold() const = 0;
@ -469,8 +509,8 @@ public:
CV_WRAP virtual void setNonmaxSuppression(bool f) = 0; CV_WRAP virtual void setNonmaxSuppression(bool f) = 0;
CV_WRAP virtual bool getNonmaxSuppression() const = 0; CV_WRAP virtual bool getNonmaxSuppression() const = 0;
CV_WRAP virtual void setType(int type) = 0; CV_WRAP virtual void setType(AgastFeatureDetector::DetectorType type) = 0;
CV_WRAP virtual int getType() const = 0; CV_WRAP virtual AgastFeatureDetector::DetectorType getType() const = 0;
CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; CV_WRAP virtual String getDefaultName() const CV_OVERRIDE;
}; };
@ -497,37 +537,7 @@ Detects corners using the AGAST algorithm by @cite mair2010_agast .
*/ */
CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector<KeyPoint>& keypoints, CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector<KeyPoint>& keypoints,
int threshold, bool nonmaxSuppression, int type ); int threshold, bool nonmaxSuppression, AgastFeatureDetector::DetectorType type );
//! @} features2d_main
//! @addtogroup features2d_main
//! @{
/** @brief Wrapping class for feature detection using the AGAST method. :
*/
class CV_EXPORTS_W AgastFeatureDetector : public Feature2D
{
public:
enum
{
AGAST_5_8 = 0, AGAST_7_12d = 1, AGAST_7_12s = 2, OAST_9_16 = 3,
THRESHOLD = 10000, NONMAX_SUPPRESSION = 10001,
};
CV_WRAP static Ptr<AgastFeatureDetector> create( int threshold=10,
bool nonmaxSuppression=true,
int type=AgastFeatureDetector::OAST_9_16 );
CV_WRAP virtual void setThreshold(int threshold) = 0;
CV_WRAP virtual int getThreshold() const = 0;
CV_WRAP virtual void setNonmaxSuppression(bool f) = 0;
CV_WRAP virtual bool getNonmaxSuppression() const = 0;
CV_WRAP virtual void setType(int type) = 0;
CV_WRAP virtual int getType() const = 0;
CV_WRAP virtual String getDefaultName() const CV_OVERRIDE;
};
/** @brief Wrapping class for feature detection using the goodFeaturesToTrack function. : /** @brief Wrapping class for feature detection using the goodFeaturesToTrack function. :
*/ */
@ -639,7 +649,7 @@ F. Alcantarilla, Adrien Bartoli and Andrew J. Davison. In European Conference on
class CV_EXPORTS_W KAZE : public Feature2D class CV_EXPORTS_W KAZE : public Feature2D
{ {
public: public:
enum enum DiffusivityType
{ {
DIFF_PM_G1 = 0, DIFF_PM_G1 = 0,
DIFF_PM_G2 = 1, DIFF_PM_G2 = 1,
@ -660,7 +670,7 @@ public:
CV_WRAP static Ptr<KAZE> create(bool extended=false, bool upright=false, CV_WRAP static Ptr<KAZE> create(bool extended=false, bool upright=false,
float threshold = 0.001f, float threshold = 0.001f,
int nOctaves = 4, int nOctaveLayers = 4, int nOctaves = 4, int nOctaveLayers = 4,
int diffusivity = KAZE::DIFF_PM_G2); KAZE::DiffusivityType diffusivity = KAZE::DIFF_PM_G2);
CV_WRAP virtual void setExtended(bool extended) = 0; CV_WRAP virtual void setExtended(bool extended) = 0;
CV_WRAP virtual bool getExtended() const = 0; CV_WRAP virtual bool getExtended() const = 0;
@ -677,8 +687,8 @@ public:
CV_WRAP virtual void setNOctaveLayers(int octaveLayers) = 0; CV_WRAP virtual void setNOctaveLayers(int octaveLayers) = 0;
CV_WRAP virtual int getNOctaveLayers() const = 0; CV_WRAP virtual int getNOctaveLayers() const = 0;
CV_WRAP virtual void setDiffusivity(int diff) = 0; CV_WRAP virtual void setDiffusivity(KAZE::DiffusivityType diff) = 0;
CV_WRAP virtual int getDiffusivity() const = 0; CV_WRAP virtual KAZE::DiffusivityType getDiffusivity() const = 0;
CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; CV_WRAP virtual String getDefaultName() const CV_OVERRIDE;
}; };
@ -702,7 +712,7 @@ class CV_EXPORTS_W AKAZE : public Feature2D
{ {
public: public:
// AKAZE descriptor type // AKAZE descriptor type
enum enum DescriptorType
{ {
DESCRIPTOR_KAZE_UPRIGHT = 2, ///< Upright descriptors, not invariant to rotation DESCRIPTOR_KAZE_UPRIGHT = 2, ///< Upright descriptors, not invariant to rotation
DESCRIPTOR_KAZE = 3, DESCRIPTOR_KAZE = 3,
@ -722,13 +732,13 @@ public:
@param diffusivity Diffusivity type. DIFF_PM_G1, DIFF_PM_G2, DIFF_WEICKERT or @param diffusivity Diffusivity type. DIFF_PM_G1, DIFF_PM_G2, DIFF_WEICKERT or
DIFF_CHARBONNIER DIFF_CHARBONNIER
*/ */
CV_WRAP static Ptr<AKAZE> create(int descriptor_type=AKAZE::DESCRIPTOR_MLDB, CV_WRAP static Ptr<AKAZE> create(AKAZE::DescriptorType descriptor_type = AKAZE::DESCRIPTOR_MLDB,
int descriptor_size = 0, int descriptor_channels = 3, int descriptor_size = 0, int descriptor_channels = 3,
float threshold = 0.001f, int nOctaves = 4, float threshold = 0.001f, int nOctaves = 4,
int nOctaveLayers = 4, int diffusivity = KAZE::DIFF_PM_G2); int nOctaveLayers = 4, KAZE::DiffusivityType diffusivity = KAZE::DIFF_PM_G2);
CV_WRAP virtual void setDescriptorType(int dtype) = 0; CV_WRAP virtual void setDescriptorType(AKAZE::DescriptorType dtype) = 0;
CV_WRAP virtual int getDescriptorType() const = 0; CV_WRAP virtual AKAZE::DescriptorType getDescriptorType() const = 0;
CV_WRAP virtual void setDescriptorSize(int dsize) = 0; CV_WRAP virtual void setDescriptorSize(int dsize) = 0;
CV_WRAP virtual int getDescriptorSize() const = 0; CV_WRAP virtual int getDescriptorSize() const = 0;
@ -745,8 +755,8 @@ public:
CV_WRAP virtual void setNOctaveLayers(int octaveLayers) = 0; CV_WRAP virtual void setNOctaveLayers(int octaveLayers) = 0;
CV_WRAP virtual int getNOctaveLayers() const = 0; CV_WRAP virtual int getNOctaveLayers() const = 0;
CV_WRAP virtual void setDiffusivity(int diff) = 0; CV_WRAP virtual void setDiffusivity(KAZE::DiffusivityType diff) = 0;
CV_WRAP virtual int getDiffusivity() const = 0; CV_WRAP virtual KAZE::DiffusivityType getDiffusivity() const = 0;
CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; CV_WRAP virtual String getDefaultName() const CV_OVERRIDE;
}; };
@ -773,7 +783,7 @@ template<> struct Accumulator<short> { typedef float Type; };
template<class T> template<class T>
struct CV_EXPORTS SL2 struct CV_EXPORTS SL2
{ {
enum { normType = NORM_L2SQR }; static const NormTypes normType = NORM_L2SQR;
typedef T ValueType; typedef T ValueType;
typedef typename Accumulator<T>::Type ResultType; typedef typename Accumulator<T>::Type ResultType;
@ -789,7 +799,7 @@ struct CV_EXPORTS SL2
template<class T> template<class T>
struct L2 struct L2
{ {
enum { normType = NORM_L2 }; static const NormTypes normType = NORM_L2;
typedef T ValueType; typedef T ValueType;
typedef typename Accumulator<T>::Type ResultType; typedef typename Accumulator<T>::Type ResultType;
@ -805,7 +815,7 @@ struct L2
template<class T> template<class T>
struct L1 struct L1
{ {
enum { normType = NORM_L1 }; static const NormTypes normType = NORM_L1;
typedef T ValueType; typedef T ValueType;
typedef typename Accumulator<T>::Type ResultType; typedef typename Accumulator<T>::Type ResultType;
@ -830,7 +840,7 @@ an image set.
class CV_EXPORTS_W DescriptorMatcher : public Algorithm class CV_EXPORTS_W DescriptorMatcher : public Algorithm
{ {
public: public:
enum enum MatcherType
{ {
FLANNBASED = 1, FLANNBASED = 1,
BRUTEFORCE = 2, BRUTEFORCE = 2,
@ -839,6 +849,7 @@ public:
BRUTEFORCE_HAMMINGLUT = 5, BRUTEFORCE_HAMMINGLUT = 5,
BRUTEFORCE_SL2 = 6 BRUTEFORCE_SL2 = 6
}; };
virtual ~DescriptorMatcher(); virtual ~DescriptorMatcher();
/** @brief Adds descriptors to train a CPU(trainDescCollectionis) or GPU(utrainDescCollectionis) descriptor /** @brief Adds descriptors to train a CPU(trainDescCollectionis) or GPU(utrainDescCollectionis) descriptor
@ -1016,7 +1027,7 @@ public:
*/ */
CV_WRAP static Ptr<DescriptorMatcher> create( const String& descriptorMatcherType ); CV_WRAP static Ptr<DescriptorMatcher> create( const String& descriptorMatcherType );
CV_WRAP static Ptr<DescriptorMatcher> create( int matcherType ); CV_WRAP static Ptr<DescriptorMatcher> create( const DescriptorMatcher::MatcherType& matcherType );
// see corresponding cv::Algorithm method // see corresponding cv::Algorithm method
@ -1171,20 +1182,20 @@ protected:
//! @addtogroup features2d_draw //! @addtogroup features2d_draw
//! @{ //! @{
struct CV_EXPORTS DrawMatchesFlags enum struct DrawMatchesFlags
{ {
enum{ DEFAULT = 0, //!< Output image matrix will be created (Mat::create), DEFAULT = 0, //!< Output image matrix will be created (Mat::create),
//!< i.e. existing memory of output image may be reused. //!< i.e. existing memory of output image may be reused.
//!< Two source image, matches and single keypoints will be drawn. //!< Two source image, matches and single keypoints will be drawn.
//!< For each keypoint only the center point will be drawn (without //!< For each keypoint only the center point will be drawn (without
//!< the circle around keypoint with keypoint size and orientation). //!< the circle around keypoint with keypoint size and orientation).
DRAW_OVER_OUTIMG = 1, //!< Output image matrix will not be created (Mat::create). DRAW_OVER_OUTIMG = 1, //!< Output image matrix will not be created (Mat::create).
//!< Matches will be drawn on existing content of output image. //!< Matches will be drawn on existing content of output image.
NOT_DRAW_SINGLE_POINTS = 2, //!< Single keypoints will not be drawn. NOT_DRAW_SINGLE_POINTS = 2, //!< Single keypoints will not be drawn.
DRAW_RICH_KEYPOINTS = 4 //!< For each keypoint the circle around keypoint with keypoint size and DRAW_RICH_KEYPOINTS = 4 //!< For each keypoint the circle around keypoint with keypoint size and
//!< orientation will be drawn. //!< orientation will be drawn.
};
}; };
CV_ENUM_FLAGS(DrawMatchesFlags);
/** @brief Draws keypoints. /** @brief Draws keypoints.
@ -1202,7 +1213,7 @@ cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS, cv2.DRAW_MATCHES_FLAGS_DRAW_OVER_OUT
cv2.DRAW_MATCHES_FLAGS_NOT_DRAW_SINGLE_POINTS cv2.DRAW_MATCHES_FLAGS_NOT_DRAW_SINGLE_POINTS
*/ */
CV_EXPORTS_W void drawKeypoints( InputArray image, const std::vector<KeyPoint>& keypoints, InputOutputArray outImage, CV_EXPORTS_W void drawKeypoints( InputArray image, const std::vector<KeyPoint>& keypoints, InputOutputArray outImage,
const Scalar& color=Scalar::all(-1), int flags=DrawMatchesFlags::DEFAULT ); const Scalar& color=Scalar::all(-1), DrawMatchesFlags flags=DrawMatchesFlags::DEFAULT );
/** @brief Draws the found matches of keypoints from two images. /** @brief Draws the found matches of keypoints from two images.
@ -1230,14 +1241,14 @@ CV_EXPORTS_W void drawMatches( InputArray img1, const std::vector<KeyPoint>& key
InputArray img2, const std::vector<KeyPoint>& keypoints2, InputArray img2, const std::vector<KeyPoint>& keypoints2,
const std::vector<DMatch>& matches1to2, InputOutputArray outImg, const std::vector<DMatch>& matches1to2, InputOutputArray outImg,
const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1), const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1),
const std::vector<char>& matchesMask=std::vector<char>(), int flags=DrawMatchesFlags::DEFAULT ); const std::vector<char>& matchesMask=std::vector<char>(), DrawMatchesFlags flags=DrawMatchesFlags::DEFAULT );
/** @overload */ /** @overload */
CV_EXPORTS_AS(drawMatchesKnn) void drawMatches( InputArray img1, const std::vector<KeyPoint>& keypoints1, CV_EXPORTS_AS(drawMatchesKnn) void drawMatches( InputArray img1, const std::vector<KeyPoint>& keypoints1,
InputArray img2, const std::vector<KeyPoint>& keypoints2, InputArray img2, const std::vector<KeyPoint>& keypoints2,
const std::vector<std::vector<DMatch> >& matches1to2, InputOutputArray outImg, const std::vector<std::vector<DMatch> >& matches1to2, InputOutputArray outImg,
const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1), const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1),
const std::vector<std::vector<char> >& matchesMask=std::vector<std::vector<char> >(), int flags=DrawMatchesFlags::DEFAULT ); const std::vector<std::vector<char> >& matchesMask=std::vector<std::vector<char> >(), DrawMatchesFlags flags=DrawMatchesFlags::DEFAULT );
//! @} features2d_draw //! @} features2d_draw

@ -1,3 +1,24 @@
#ifdef HAVE_OPENCV_FEATURES2D #ifdef HAVE_OPENCV_FEATURES2D
typedef SimpleBlobDetector::Params SimpleBlobDetector_Params; typedef SimpleBlobDetector::Params SimpleBlobDetector_Params;
typedef AKAZE::DescriptorType AKAZE_DescriptorType;
typedef AgastFeatureDetector::DetectorType AgastFeatureDetector_DetectorType;
typedef FastFeatureDetector::DetectorType FastFeatureDetector_DetectorType;
typedef DescriptorMatcher::MatcherType DescriptorMatcher_MatcherType;
typedef KAZE::DiffusivityType KAZE_DiffusivityType;
typedef ORB::ScoreType ORB_ScoreType;
CV_PY_FROM_ENUM(AKAZE::DescriptorType);
CV_PY_TO_ENUM(AKAZE::DescriptorType);
CV_PY_FROM_ENUM(AgastFeatureDetector::DetectorType);
CV_PY_TO_ENUM(AgastFeatureDetector::DetectorType);
CV_PY_FROM_ENUM(DrawMatchesFlags);
CV_PY_TO_ENUM(DrawMatchesFlags);
CV_PY_FROM_ENUM(FastFeatureDetector::DetectorType);
CV_PY_TO_ENUM(FastFeatureDetector::DetectorType);
CV_PY_FROM_ENUM(DescriptorMatcher::MatcherType);
CV_PY_TO_ENUM(DescriptorMatcher::MatcherType);
CV_PY_FROM_ENUM(KAZE::DiffusivityType);
CV_PY_TO_ENUM(KAZE::DiffusivityType);
CV_PY_FROM_ENUM(ORB::ScoreType);
CV_PY_TO_ENUM(ORB::ScoreType);
#endif #endif

@ -7446,7 +7446,7 @@ static void OAST_9_16(InputArray _img, std::vector<KeyPoint>& keypoints, int thr
#else // !(defined __i386__ || defined(_M_IX86) || defined __x86_64__ || defined(_M_X64)) #else // !(defined __i386__ || defined(_M_IX86) || defined __x86_64__ || defined(_M_X64))
static void AGAST_ALL(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, int agasttype) static void AGAST_ALL(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, AgastFeatureDetector::DetectorType agasttype)
{ {
cv::Mat img; cv::Mat img;
if(!_img.getMat().isContinuous()) if(!_img.getMat().isContinuous())
@ -7944,8 +7944,8 @@ void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, boo
class AgastFeatureDetector_Impl CV_FINAL : public AgastFeatureDetector class AgastFeatureDetector_Impl CV_FINAL : public AgastFeatureDetector
{ {
public: public:
AgastFeatureDetector_Impl( int _threshold, bool _nonmaxSuppression, int _type ) AgastFeatureDetector_Impl( int _threshold, bool _nonmaxSuppression, DetectorType _type )
: threshold(_threshold), nonmaxSuppression(_nonmaxSuppression), type((short)_type) : threshold(_threshold), nonmaxSuppression(_nonmaxSuppression), type(_type)
{} {}
void detect( InputArray _image, std::vector<KeyPoint>& keypoints, InputArray _mask ) CV_OVERRIDE void detect( InputArray _image, std::vector<KeyPoint>& keypoints, InputArray _mask ) CV_OVERRIDE
@ -7998,20 +7998,20 @@ public:
void setNonmaxSuppression(bool f) CV_OVERRIDE { nonmaxSuppression = f; } void setNonmaxSuppression(bool f) CV_OVERRIDE { nonmaxSuppression = f; }
bool getNonmaxSuppression() const CV_OVERRIDE { return nonmaxSuppression; } bool getNonmaxSuppression() const CV_OVERRIDE { return nonmaxSuppression; }
void setType(int type_) CV_OVERRIDE { type = type_; } void setType(DetectorType type_) CV_OVERRIDE{ type = type_; }
int getType() const CV_OVERRIDE { return type; } DetectorType getType() const CV_OVERRIDE{ return type; }
int threshold; int threshold;
bool nonmaxSuppression; bool nonmaxSuppression;
int type; DetectorType type;
}; };
Ptr<AgastFeatureDetector> AgastFeatureDetector::create( int threshold, bool nonmaxSuppression, int type ) Ptr<AgastFeatureDetector> AgastFeatureDetector::create( int threshold, bool nonmaxSuppression, AgastFeatureDetector::DetectorType type )
{ {
return makePtr<AgastFeatureDetector_Impl>(threshold, nonmaxSuppression, type); return makePtr<AgastFeatureDetector_Impl>(threshold, nonmaxSuppression, type);
} }
void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool nonmax_suppression, int type) void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool nonmax_suppression, AgastFeatureDetector::DetectorType type)
{ {
CV_INSTRUMENT_REGION(); CV_INSTRUMENT_REGION();

@ -47,7 +47,7 @@ The references are:
namespace cv namespace cv
{ {
void makeAgastOffsets(int pixel[16], int rowStride, int type) void makeAgastOffsets(int pixel[16], int rowStride, AgastFeatureDetector::DetectorType type)
{ {
static const int offsets16[][2] = static const int offsets16[][2] =
{ {
@ -9400,7 +9400,7 @@ int agast_tree_search(const uint32_t table_struct32[], int pixel_[], const unsig
} }
// universal pixel mask // universal pixel mask
int AGAST_ALL_SCORE(const uchar* ptr, const int pixel[], int threshold, int agasttype) int AGAST_ALL_SCORE(const uchar* ptr, const int pixel[], int threshold, AgastFeatureDetector::DetectorType agasttype)
{ {
int bmin = threshold; int bmin = threshold;
int bmax = 255; int bmax = 255;

@ -54,13 +54,13 @@ namespace cv
#if !(defined __i386__ || defined(_M_IX86) || defined __x86_64__ || defined(_M_X64)) #if !(defined __i386__ || defined(_M_IX86) || defined __x86_64__ || defined(_M_X64))
int agast_tree_search(const uint32_t table_struct32[], int pixel_[], const unsigned char* const ptr, int threshold); int agast_tree_search(const uint32_t table_struct32[], int pixel_[], const unsigned char* const ptr, int threshold);
int AGAST_ALL_SCORE(const uchar* ptr, const int pixel[], int threshold, int agasttype); int AGAST_ALL_SCORE(const uchar* ptr, const int pixel[], int threshold, AgastFeatureDetector::DetectorType agasttype);
#endif //!(defined __i386__ || defined(_M_IX86) || defined __x86_64__ || defined(_M_X64)) #endif //!(defined __i386__ || defined(_M_IX86) || defined __x86_64__ || defined(_M_X64))
void makeAgastOffsets(int pixel[16], int row_stride, int type); void makeAgastOffsets(int pixel[16], int row_stride, AgastFeatureDetector::DetectorType type);
template<int type> template<AgastFeatureDetector::DetectorType type>
int agast_cornerScore(const uchar* ptr, const int pixel[], int threshold); int agast_cornerScore(const uchar* ptr, const int pixel[], int threshold);

@ -60,8 +60,8 @@ namespace cv
class AKAZE_Impl : public AKAZE class AKAZE_Impl : public AKAZE
{ {
public: public:
AKAZE_Impl(int _descriptor_type, int _descriptor_size, int _descriptor_channels, AKAZE_Impl(DescriptorType _descriptor_type, int _descriptor_size, int _descriptor_channels,
float _threshold, int _octaves, int _sublevels, int _diffusivity) float _threshold, int _octaves, int _sublevels, KAZE::DiffusivityType _diffusivity)
: descriptor(_descriptor_type) : descriptor(_descriptor_type)
, descriptor_channels(_descriptor_channels) , descriptor_channels(_descriptor_channels)
, descriptor_size(_descriptor_size) , descriptor_size(_descriptor_size)
@ -77,8 +77,8 @@ namespace cv
} }
void setDescriptorType(int dtype) CV_OVERRIDE { descriptor = dtype; } void setDescriptorType(DescriptorType dtype) CV_OVERRIDE{ descriptor = dtype; }
int getDescriptorType() const CV_OVERRIDE { return descriptor; } DescriptorType getDescriptorType() const CV_OVERRIDE{ return descriptor; }
void setDescriptorSize(int dsize) CV_OVERRIDE { descriptor_size = dsize; } void setDescriptorSize(int dsize) CV_OVERRIDE { descriptor_size = dsize; }
int getDescriptorSize() const CV_OVERRIDE { return descriptor_size; } int getDescriptorSize() const CV_OVERRIDE { return descriptor_size; }
@ -95,8 +95,8 @@ namespace cv
void setNOctaveLayers(int octaveLayers_) CV_OVERRIDE { sublevels = octaveLayers_; } void setNOctaveLayers(int octaveLayers_) CV_OVERRIDE { sublevels = octaveLayers_; }
int getNOctaveLayers() const CV_OVERRIDE { return sublevels; } int getNOctaveLayers() const CV_OVERRIDE { return sublevels; }
void setDiffusivity(int diff_) CV_OVERRIDE { diffusivity = diff_; } void setDiffusivity(KAZE::DiffusivityType diff_) CV_OVERRIDE{ diffusivity = diff_; }
int getDiffusivity() const CV_OVERRIDE { return diffusivity; } KAZE::DiffusivityType getDiffusivity() const CV_OVERRIDE{ return diffusivity; }
// returns the descriptor size in bytes // returns the descriptor size in bytes
int descriptorSize() const CV_OVERRIDE int descriptorSize() const CV_OVERRIDE
@ -218,28 +218,28 @@ namespace cv
void read(const FileNode& fn) CV_OVERRIDE void read(const FileNode& fn) CV_OVERRIDE
{ {
descriptor = (int)fn["descriptor"]; descriptor = static_cast<DescriptorType>((int)fn["descriptor"]);
descriptor_channels = (int)fn["descriptor_channels"]; descriptor_channels = (int)fn["descriptor_channels"];
descriptor_size = (int)fn["descriptor_size"]; descriptor_size = (int)fn["descriptor_size"];
threshold = (float)fn["threshold"]; threshold = (float)fn["threshold"];
octaves = (int)fn["octaves"]; octaves = (int)fn["octaves"];
sublevels = (int)fn["sublevels"]; sublevels = (int)fn["sublevels"];
diffusivity = (int)fn["diffusivity"]; diffusivity = static_cast<KAZE::DiffusivityType>((int)fn["diffusivity"]);
} }
int descriptor; DescriptorType descriptor;
int descriptor_channels; int descriptor_channels;
int descriptor_size; int descriptor_size;
float threshold; float threshold;
int octaves; int octaves;
int sublevels; int sublevels;
int diffusivity; KAZE::DiffusivityType diffusivity;
}; };
Ptr<AKAZE> AKAZE::create(int descriptor_type, Ptr<AKAZE> AKAZE::create(DescriptorType descriptor_type,
int descriptor_size, int descriptor_channels, int descriptor_size, int descriptor_channels,
float threshold, int octaves, float threshold, int octaves,
int sublevels, int diffusivity) int sublevels, KAZE::DiffusivityType diffusivity)
{ {
return makePtr<AKAZE_Impl>(descriptor_type, descriptor_size, descriptor_channels, return makePtr<AKAZE_Impl>(descriptor_type, descriptor_size, descriptor_channels,
threshold, octaves, sublevels, diffusivity); threshold, octaves, sublevels, diffusivity);

@ -50,12 +50,12 @@ namespace cv
/* /*
* Functions to draw keypoints and matches. * Functions to draw keypoints and matches.
*/ */
static inline void _drawKeypoint( InputOutputArray img, const KeyPoint& p, const Scalar& color, int flags ) static inline void _drawKeypoint( InputOutputArray img, const KeyPoint& p, const Scalar& color, DrawMatchesFlags flags )
{ {
CV_Assert( !img.empty() ); CV_Assert( !img.empty() );
Point center( cvRound(p.pt.x * draw_multiplier), cvRound(p.pt.y * draw_multiplier) ); Point center( cvRound(p.pt.x * draw_multiplier), cvRound(p.pt.y * draw_multiplier) );
if( flags & DrawMatchesFlags::DRAW_RICH_KEYPOINTS ) if( !!(flags & DrawMatchesFlags::DRAW_RICH_KEYPOINTS) )
{ {
int radius = cvRound(p.size/2 * draw_multiplier); // KeyPoint::size is a diameter int radius = cvRound(p.size/2 * draw_multiplier); // KeyPoint::size is a diameter
@ -89,7 +89,7 @@ static inline void _drawKeypoint( InputOutputArray img, const KeyPoint& p, const
} }
void drawKeypoints( InputArray image, const std::vector<KeyPoint>& keypoints, InputOutputArray outImage, void drawKeypoints( InputArray image, const std::vector<KeyPoint>& keypoints, InputOutputArray outImage,
const Scalar& _color, int flags ) const Scalar& _color, DrawMatchesFlags flags )
{ {
CV_INSTRUMENT_REGION(); CV_INSTRUMENT_REGION();
@ -125,12 +125,12 @@ void drawKeypoints( InputArray image, const std::vector<KeyPoint>& keypoints, In
static void _prepareImgAndDrawKeypoints( InputArray img1, const std::vector<KeyPoint>& keypoints1, static void _prepareImgAndDrawKeypoints( InputArray img1, const std::vector<KeyPoint>& keypoints1,
InputArray img2, const std::vector<KeyPoint>& keypoints2, InputArray img2, const std::vector<KeyPoint>& keypoints2,
InputOutputArray _outImg, Mat& outImg1, Mat& outImg2, InputOutputArray _outImg, Mat& outImg1, Mat& outImg2,
const Scalar& singlePointColor, int flags ) const Scalar& singlePointColor, DrawMatchesFlags flags )
{ {
Mat outImg; Mat outImg;
Size img1size = img1.size(), img2size = img2.size(); Size img1size = img1.size(), img2size = img2.size();
Size size( img1size.width + img2size.width, MAX(img1size.height, img2size.height) ); Size size( img1size.width + img2size.width, MAX(img1size.height, img2size.height) );
if( flags & DrawMatchesFlags::DRAW_OVER_OUTIMG ) if( !!(flags & DrawMatchesFlags::DRAW_OVER_OUTIMG) )
{ {
outImg = _outImg.getMat(); outImg = _outImg.getMat();
if( size.width > outImg.cols || size.height > outImg.rows ) if( size.width > outImg.cols || size.height > outImg.rows )
@ -169,7 +169,7 @@ static void _prepareImgAndDrawKeypoints( InputArray img1, const std::vector<KeyP
} }
static inline void _drawMatch( InputOutputArray outImg, InputOutputArray outImg1, InputOutputArray outImg2 , static inline void _drawMatch( InputOutputArray outImg, InputOutputArray outImg1, InputOutputArray outImg2 ,
const KeyPoint& kp1, const KeyPoint& kp2, const Scalar& matchColor, int flags ) const KeyPoint& kp1, const KeyPoint& kp2, const Scalar& matchColor, DrawMatchesFlags flags )
{ {
RNG& rng = theRNG(); RNG& rng = theRNG();
bool isRandMatchColor = matchColor == Scalar::all(-1); bool isRandMatchColor = matchColor == Scalar::all(-1);
@ -192,7 +192,7 @@ void drawMatches( InputArray img1, const std::vector<KeyPoint>& keypoints1,
InputArray img2, const std::vector<KeyPoint>& keypoints2, InputArray img2, const std::vector<KeyPoint>& keypoints2,
const std::vector<DMatch>& matches1to2, InputOutputArray outImg, const std::vector<DMatch>& matches1to2, InputOutputArray outImg,
const Scalar& matchColor, const Scalar& singlePointColor, const Scalar& matchColor, const Scalar& singlePointColor,
const std::vector<char>& matchesMask, int flags ) const std::vector<char>& matchesMask, DrawMatchesFlags flags )
{ {
if( !matchesMask.empty() && matchesMask.size() != matches1to2.size() ) if( !matchesMask.empty() && matchesMask.size() != matches1to2.size() )
CV_Error( Error::StsBadSize, "matchesMask must have the same size as matches1to2" ); CV_Error( Error::StsBadSize, "matchesMask must have the same size as matches1to2" );
@ -221,7 +221,7 @@ void drawMatches( InputArray img1, const std::vector<KeyPoint>& keypoints1,
InputArray img2, const std::vector<KeyPoint>& keypoints2, InputArray img2, const std::vector<KeyPoint>& keypoints2,
const std::vector<std::vector<DMatch> >& matches1to2, InputOutputArray outImg, const std::vector<std::vector<DMatch> >& matches1to2, InputOutputArray outImg,
const Scalar& matchColor, const Scalar& singlePointColor, const Scalar& matchColor, const Scalar& singlePointColor,
const std::vector<std::vector<char> >& matchesMask, int flags ) const std::vector<std::vector<char> >& matchesMask, DrawMatchesFlags flags )
{ {
if( !matchesMask.empty() && matchesMask.size() != matches1to2.size() ) if( !matchesMask.empty() && matchesMask.size() != matches1to2.size() )
CV_Error( Error::StsBadSize, "matchesMask must have the same size as matches1to2" ); CV_Error( Error::StsBadSize, "matchesMask must have the same size as matches1to2" );

@ -415,7 +415,7 @@ static bool openvx_FAST(InputArray _img, std::vector<KeyPoint>& keypoints,
#endif #endif
static inline int hal_FAST(cv::Mat& src, std::vector<KeyPoint>& keypoints, int threshold, bool nonmax_suppression, int type) static inline int hal_FAST(cv::Mat& src, std::vector<KeyPoint>& keypoints, int threshold, bool nonmax_suppression, FastFeatureDetector::DetectorType type)
{ {
if (threshold > 20) if (threshold > 20)
return CV_HAL_ERROR_NOT_IMPLEMENTED; return CV_HAL_ERROR_NOT_IMPLEMENTED;
@ -472,7 +472,7 @@ static inline int hal_FAST(cv::Mat& src, std::vector<KeyPoint>& keypoints, int t
return CV_HAL_ERROR_OK; return CV_HAL_ERROR_OK;
} }
void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool nonmax_suppression, int type) void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool nonmax_suppression, FastFeatureDetector::DetectorType type)
{ {
CV_INSTRUMENT_REGION(); CV_INSTRUMENT_REGION();
@ -514,8 +514,8 @@ void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool
class FastFeatureDetector_Impl CV_FINAL : public FastFeatureDetector class FastFeatureDetector_Impl CV_FINAL : public FastFeatureDetector
{ {
public: public:
FastFeatureDetector_Impl( int _threshold, bool _nonmaxSuppression, int _type ) FastFeatureDetector_Impl( int _threshold, bool _nonmaxSuppression, FastFeatureDetector::DetectorType _type )
: threshold(_threshold), nonmaxSuppression(_nonmaxSuppression), type((short)_type) : threshold(_threshold), nonmaxSuppression(_nonmaxSuppression), type(_type)
{} {}
void detect( InputArray _image, std::vector<KeyPoint>& keypoints, InputArray _mask ) CV_OVERRIDE void detect( InputArray _image, std::vector<KeyPoint>& keypoints, InputArray _mask ) CV_OVERRIDE
@ -548,7 +548,7 @@ public:
else if(prop == NONMAX_SUPPRESSION) else if(prop == NONMAX_SUPPRESSION)
nonmaxSuppression = value != 0; nonmaxSuppression = value != 0;
else if(prop == FAST_N) else if(prop == FAST_N)
type = cvRound(value); type = static_cast<FastFeatureDetector::DetectorType>(cvRound(value));
else else
CV_Error(Error::StsBadArg, ""); CV_Error(Error::StsBadArg, "");
} }
@ -560,7 +560,7 @@ public:
if(prop == NONMAX_SUPPRESSION) if(prop == NONMAX_SUPPRESSION)
return nonmaxSuppression; return nonmaxSuppression;
if(prop == FAST_N) if(prop == FAST_N)
return type; return static_cast<int>(type);
CV_Error(Error::StsBadArg, ""); CV_Error(Error::StsBadArg, "");
return 0; return 0;
} }
@ -571,15 +571,15 @@ public:
void setNonmaxSuppression(bool f) CV_OVERRIDE { nonmaxSuppression = f; } void setNonmaxSuppression(bool f) CV_OVERRIDE { nonmaxSuppression = f; }
bool getNonmaxSuppression() const CV_OVERRIDE { return nonmaxSuppression; } bool getNonmaxSuppression() const CV_OVERRIDE { return nonmaxSuppression; }
void setType(int type_) CV_OVERRIDE { type = type_; } void setType(FastFeatureDetector::DetectorType type_) CV_OVERRIDE{ type = type_; }
int getType() const CV_OVERRIDE { return type; } FastFeatureDetector::DetectorType getType() const CV_OVERRIDE{ return type; }
int threshold; int threshold;
bool nonmaxSuppression; bool nonmaxSuppression;
int type; FastFeatureDetector::DetectorType type;
}; };
Ptr<FastFeatureDetector> FastFeatureDetector::create( int threshold, bool nonmaxSuppression, int type ) Ptr<FastFeatureDetector> FastFeatureDetector::create( int threshold, bool nonmaxSuppression, FastFeatureDetector::DetectorType type )
{ {
return makePtr<FastFeatureDetector_Impl>(threshold, nonmaxSuppression, type); return makePtr<FastFeatureDetector_Impl>(threshold, nonmaxSuppression, type);
} }

@ -66,7 +66,7 @@
@param width,height Source image dimensions @param width,height Source image dimensions
@param type FAST type @param type FAST type
*/ */
inline int hal_ni_FAST_dense(const uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step, int width, int height, int type) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } inline int hal_ni_FAST_dense(const uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step, int width, int height, cv::FastFeatureDetector::DetectorType type) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }
//! @cond IGNORED //! @cond IGNORED
#define cv_hal_FAST_dense hal_ni_FAST_dense #define cv_hal_FAST_dense hal_ni_FAST_dense
@ -94,7 +94,7 @@ inline int hal_ni_FAST_NMS(const uchar* src_data, size_t src_step, uchar* dst_da
@param nonmax_suppression Indicates if make nonmaxima suppression or not. @param nonmax_suppression Indicates if make nonmaxima suppression or not.
@param type FAST type @param type FAST type
*/ */
inline int hal_ni_FAST(const uchar* src_data, size_t src_step, int width, int height, uchar* keypoints_data, size_t* keypoints_count, int threshold, bool nonmax_suppression, int type) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } inline int hal_ni_FAST(const uchar* src_data, size_t src_step, int width, int height, uchar* keypoints_data, size_t* keypoints_count, int threshold, bool nonmax_suppression, int /*cv::FastFeatureDetector::DetectorType*/ type) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }
//! @cond IGNORED //! @cond IGNORED
#define cv_hal_FAST hal_ni_FAST #define cv_hal_FAST hal_ni_FAST

@ -57,7 +57,7 @@ namespace cv
{ {
public: public:
KAZE_Impl(bool _extended, bool _upright, float _threshold, int _octaves, KAZE_Impl(bool _extended, bool _upright, float _threshold, int _octaves,
int _sublevels, int _diffusivity) int _sublevels, KAZE::DiffusivityType _diffusivity)
: extended(_extended) : extended(_extended)
, upright(_upright) , upright(_upright)
, threshold(_threshold) , threshold(_threshold)
@ -84,8 +84,8 @@ namespace cv
void setNOctaveLayers(int octaveLayers_) CV_OVERRIDE { sublevels = octaveLayers_; } void setNOctaveLayers(int octaveLayers_) CV_OVERRIDE { sublevels = octaveLayers_; }
int getNOctaveLayers() const CV_OVERRIDE { return sublevels; } int getNOctaveLayers() const CV_OVERRIDE { return sublevels; }
void setDiffusivity(int diff_) CV_OVERRIDE { diffusivity = diff_; } void setDiffusivity(KAZE::DiffusivityType diff_) CV_OVERRIDE{ diffusivity = diff_; }
int getDiffusivity() const CV_OVERRIDE { return diffusivity; } KAZE::DiffusivityType getDiffusivity() const CV_OVERRIDE{ return diffusivity; }
// returns the descriptor size in bytes // returns the descriptor size in bytes
int descriptorSize() const CV_OVERRIDE int descriptorSize() const CV_OVERRIDE
@ -178,7 +178,7 @@ namespace cv
threshold = (float)fn["threshold"]; threshold = (float)fn["threshold"];
octaves = (int)fn["octaves"]; octaves = (int)fn["octaves"];
sublevels = (int)fn["sublevels"]; sublevels = (int)fn["sublevels"];
diffusivity = (int)fn["diffusivity"]; diffusivity = static_cast<KAZE::DiffusivityType>((int)fn["diffusivity"]);
} }
bool extended; bool extended;
@ -186,13 +186,13 @@ namespace cv
float threshold; float threshold;
int octaves; int octaves;
int sublevels; int sublevels;
int diffusivity; KAZE::DiffusivityType diffusivity;
}; };
Ptr<KAZE> KAZE::create(bool extended, bool upright, Ptr<KAZE> KAZE::create(bool extended, bool upright,
float threshold, float threshold,
int octaves, int sublevels, int octaves, int sublevels,
int diffusivity) KAZE::DiffusivityType diffusivity)
{ {
return makePtr<KAZE_Impl>(extended, upright, threshold, octaves, sublevels, diffusivity); return makePtr<KAZE_Impl>(extended, upright, threshold, octaves, sublevels, diffusivity);
} }

@ -45,12 +45,12 @@ struct AKAZEOptions {
float soffset; ///< Base scale offset (sigma units) float soffset; ///< Base scale offset (sigma units)
float derivative_factor; ///< Factor for the multiscale derivatives float derivative_factor; ///< Factor for the multiscale derivatives
float sderivatives; ///< Smoothing factor for the derivatives float sderivatives; ///< Smoothing factor for the derivatives
int diffusivity; ///< Diffusivity type KAZE::DiffusivityType diffusivity; ///< Diffusivity type
float dthreshold; ///< Detector response threshold to accept point float dthreshold; ///< Detector response threshold to accept point
float min_dthreshold; ///< Minimum detector threshold to accept a point float min_dthreshold; ///< Minimum detector threshold to accept a point
int descriptor; ///< Type of descriptor AKAZE::DescriptorType descriptor; ///< Type of descriptor
int descriptor_size; ///< Size of the descriptor in bits. 0->Full size int descriptor_size; ///< Size of the descriptor in bits. 0->Full size
int descriptor_channels; ///< Number of channels in the descriptor (1, 2, 3) int descriptor_channels; ///< Number of channels in the descriptor (1, 2, 3)
int descriptor_pattern_size; ///< Actual patch size is 2*pattern_size*point.scale int descriptor_pattern_size; ///< Actual patch size is 2*pattern_size*point.scale

@ -377,7 +377,7 @@ ocl_pm_g2(InputArray Lx_, InputArray Ly_, OutputArray Lflow_, float kcontrast)
#endif // HAVE_OPENCL #endif // HAVE_OPENCL
static inline void static inline void
compute_diffusivity(InputArray Lx, InputArray Ly, OutputArray Lflow, float kcontrast, int diffusivity) compute_diffusivity(InputArray Lx, InputArray Ly, OutputArray Lflow, float kcontrast, KAZE::DiffusivityType diffusivity)
{ {
CV_INSTRUMENT_REGION(); CV_INSTRUMENT_REGION();
@ -398,7 +398,7 @@ compute_diffusivity(InputArray Lx, InputArray Ly, OutputArray Lflow, float kcont
charbonnier_diffusivity(Lx, Ly, Lflow, kcontrast); charbonnier_diffusivity(Lx, Ly, Lflow, kcontrast);
break; break;
default: default:
CV_Error(diffusivity, "Diffusivity is not supported"); CV_Error_(Error::StsError, ("Diffusivity is not supported: %d", static_cast<int>(diffusivity)));
break; break;
} }
} }

@ -36,7 +36,7 @@ struct KAZEOptions {
{ {
} }
int diffusivity; KAZE::DiffusivityType diffusivity;
float soffset; float soffset;
int omax; int omax;
int nsublevels; int nsublevels;

@ -1049,7 +1049,7 @@ Ptr<DescriptorMatcher> DescriptorMatcher::create( const String& descriptorMatche
return dm; return dm;
} }
Ptr<DescriptorMatcher> DescriptorMatcher::create(int matcherType) Ptr<DescriptorMatcher> DescriptorMatcher::create( const MatcherType& matcherType )
{ {

@ -655,7 +655,7 @@ class ORB_Impl CV_FINAL : public ORB
{ {
public: public:
explicit ORB_Impl(int _nfeatures, float _scaleFactor, int _nlevels, int _edgeThreshold, explicit ORB_Impl(int _nfeatures, float _scaleFactor, int _nlevels, int _edgeThreshold,
int _firstLevel, int _WTA_K, int _scoreType, int _patchSize, int _fastThreshold) : int _firstLevel, int _WTA_K, ORB::ScoreType _scoreType, int _patchSize, int _fastThreshold) :
nfeatures(_nfeatures), scaleFactor(_scaleFactor), nlevels(_nlevels), nfeatures(_nfeatures), scaleFactor(_scaleFactor), nlevels(_nlevels),
edgeThreshold(_edgeThreshold), firstLevel(_firstLevel), wta_k(_WTA_K), edgeThreshold(_edgeThreshold), firstLevel(_firstLevel), wta_k(_WTA_K),
scoreType(_scoreType), patchSize(_patchSize), fastThreshold(_fastThreshold) scoreType(_scoreType), patchSize(_patchSize), fastThreshold(_fastThreshold)
@ -679,8 +679,8 @@ public:
void setWTA_K(int wta_k_) CV_OVERRIDE { wta_k = wta_k_; } void setWTA_K(int wta_k_) CV_OVERRIDE { wta_k = wta_k_; }
int getWTA_K() const CV_OVERRIDE { return wta_k; } int getWTA_K() const CV_OVERRIDE { return wta_k; }
void setScoreType(int scoreType_) CV_OVERRIDE { scoreType = scoreType_; } void setScoreType(ORB::ScoreType scoreType_) CV_OVERRIDE{ scoreType = scoreType_; }
int getScoreType() const CV_OVERRIDE { return scoreType; } ORB::ScoreType getScoreType() const CV_OVERRIDE{ return scoreType; }
void setPatchSize(int patchSize_) CV_OVERRIDE { patchSize = patchSize_; } void setPatchSize(int patchSize_) CV_OVERRIDE { patchSize = patchSize_; }
int getPatchSize() const CV_OVERRIDE { return patchSize; } int getPatchSize() const CV_OVERRIDE { return patchSize; }
@ -707,7 +707,7 @@ protected:
int edgeThreshold; int edgeThreshold;
int firstLevel; int firstLevel;
int wta_k; int wta_k;
int scoreType; ORB::ScoreType scoreType;
int patchSize; int patchSize;
int fastThreshold; int fastThreshold;
}; };
@ -775,7 +775,7 @@ static void computeKeyPoints(const Mat& imagePyramid,
const std::vector<float>& layerScale, const std::vector<float>& layerScale,
std::vector<KeyPoint>& allKeypoints, std::vector<KeyPoint>& allKeypoints,
int nfeatures, double scaleFactor, int nfeatures, double scaleFactor,
int edgeThreshold, int patchSize, int scoreType, int edgeThreshold, int patchSize, ORB::ScoreType scoreType,
bool useOCL, int fastThreshold ) bool useOCL, int fastThreshold )
{ {
#ifndef HAVE_OPENCL #ifndef HAVE_OPENCL
@ -1195,7 +1195,7 @@ void ORB_Impl::detectAndCompute( InputArray _image, InputArray _mask,
} }
Ptr<ORB> ORB::create(int nfeatures, float scaleFactor, int nlevels, int edgeThreshold, Ptr<ORB> ORB::create(int nfeatures, float scaleFactor, int nlevels, int edgeThreshold,
int firstLevel, int wta_k, int scoreType, int patchSize, int fastThreshold) int firstLevel, int wta_k, ORB::ScoreType scoreType, int patchSize, int fastThreshold)
{ {
CV_Assert(firstLevel >= 0); CV_Assert(firstLevel >= 0);
return makePtr<ORB_Impl>(nfeatures, scaleFactor, nlevels, edgeThreshold, return makePtr<ORB_Impl>(nfeatures, scaleFactor, nlevels, edgeThreshold,

@ -75,8 +75,8 @@ void CV_AgastTest::run( int )
vector<KeyPoint> keypoints1; vector<KeyPoint> keypoints1;
vector<KeyPoint> keypoints2; vector<KeyPoint> keypoints2;
AGAST(gray1, keypoints1, 30, true, type); AGAST(gray1, keypoints1, 30, true, static_cast<AgastFeatureDetector::DetectorType>(type));
AGAST(gray2, keypoints2, (type > 0 ? 30 : 20), true, type); AGAST(gray2, keypoints2, (type > 0 ? 30 : 20), true, static_cast<AgastFeatureDetector::DetectorType>(type));
for(size_t i = 0; i < keypoints1.size(); ++i) for(size_t i = 0; i < keypoints1.size(); ++i)
{ {

@ -75,8 +75,8 @@ void CV_FastTest::run( int )
vector<KeyPoint> keypoints1; vector<KeyPoint> keypoints1;
vector<KeyPoint> keypoints2; vector<KeyPoint> keypoints2;
FAST(gray1, keypoints1, 30, true, type); FAST(gray1, keypoints1, 30, true, static_cast<FastFeatureDetector::DetectorType>(type));
FAST(gray2, keypoints2, (type > 0 ? 30 : 20), true, type); FAST(gray2, keypoints2, (type > 0 ? 30 : 20), true, static_cast<FastFeatureDetector::DetectorType>(type));
for(size_t i = 0; i < keypoints1.size(); ++i) for(size_t i = 0; i < keypoints1.size(); ++i)
{ {

@ -100,7 +100,7 @@ TEST(Features2D_ORB, crash)
int edgeThreshold = 4; int edgeThreshold = 4;
int firstLevel = 0; int firstLevel = 0;
int WTA_K = 2; int WTA_K = 2;
int scoreType = cv::ORB::HARRIS_SCORE; ORB::ScoreType scoreType = cv::ORB::HARRIS_SCORE;
int patchSize = 47; int patchSize = 47;
int fastThreshold = 20; int fastThreshold = 20;

@ -372,10 +372,12 @@ http://www.learnopencv.com/handwritten-digits-classification-an-opencv-c-python-
struct CV_EXPORTS_W HOGDescriptor struct CV_EXPORTS_W HOGDescriptor
{ {
public: public:
enum { L2Hys = 0 //!< Default histogramNormType enum HistogramNormType { L2Hys = 0 //!< Default histogramNormType
}; };
enum { DEFAULT_NLEVELS = 64 //!< Default nlevels value. enum { DEFAULT_NLEVELS = 64 //!< Default nlevels value.
}; };
enum DescriptorStorageFormat { DESCR_FORMAT_COL_BY_COL, DESCR_FORMAT_ROW_BY_ROW };
/**@brief Creates the HOG descriptor and detector with default params. /**@brief Creates the HOG descriptor and detector with default params.
aqual to HOGDescriptor(Size(64,128), Size(16,16), Size(8,8), Size(8,8), 9, 1 ) aqual to HOGDescriptor(Size(64,128), Size(16,16), Size(8,8), Size(8,8), 9, 1 )
@ -402,7 +404,7 @@ public:
*/ */
CV_WRAP HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride, CV_WRAP HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride,
Size _cellSize, int _nbins, int _derivAperture=1, double _winSigma=-1, Size _cellSize, int _nbins, int _derivAperture=1, double _winSigma=-1,
int _histogramNormType=HOGDescriptor::L2Hys, HOGDescriptor::HistogramNormType _histogramNormType=HOGDescriptor::L2Hys,
double _L2HysThreshold=0.2, bool _gammaCorrection=false, double _L2HysThreshold=0.2, bool _gammaCorrection=false,
int _nlevels=HOGDescriptor::DEFAULT_NLEVELS, bool _signedGradient=false) int _nlevels=HOGDescriptor::DEFAULT_NLEVELS, bool _signedGradient=false)
: winSize(_winSize), blockSize(_blockSize), blockStride(_blockStride), cellSize(_cellSize), : winSize(_winSize), blockSize(_blockSize), blockStride(_blockStride), cellSize(_cellSize),
@ -603,7 +605,7 @@ public:
CV_PROP double winSigma; CV_PROP double winSigma;
//! histogramNormType //! histogramNormType
CV_PROP int histogramNormType; CV_PROP HOGDescriptor::HistogramNormType histogramNormType;
//! L2-Hys normalization method shrinkage. //! L2-Hys normalization method shrinkage.
CV_PROP double L2HysThreshold; CV_PROP double L2HysThreshold;

@ -0,0 +1,13 @@
#ifdef HAVE_OPENCV_OBJDETECT
#include "opencv2/objdetect.hpp"
typedef HOGDescriptor::HistogramNormType HOGDescriptor_HistogramNormType;
typedef HOGDescriptor::DescriptorStorageFormat HOGDescriptor_DescriptorStorageFormat;
CV_PY_FROM_ENUM(HOGDescriptor::HistogramNormType);
CV_PY_TO_ENUM(HOGDescriptor::HistogramNormType);
CV_PY_FROM_ENUM(HOGDescriptor::DescriptorStorageFormat);
CV_PY_TO_ENUM(HOGDescriptor::DescriptorStorageFormat);
#endif

@ -63,8 +63,6 @@ namespace cv
#define NTHREADS 256 #define NTHREADS 256
enum {DESCR_FORMAT_COL_BY_COL, DESCR_FORMAT_ROW_BY_ROW};
static int numPartsWithin(int size, int part_size, int stride) static int numPartsWithin(int size, int part_size, int stride)
{ {
return (size - part_size + stride) / stride; return (size - part_size + stride) / stride;
@ -1515,7 +1513,7 @@ static bool ocl_extract_descrs_by_cols(int win_height, int win_width, int block_
return k.run(2, globalThreads, localThreads, false); return k.run(2, globalThreads, localThreads, false);
} }
static bool ocl_compute(InputArray _img, Size win_stride, std::vector<float>& _descriptors, int descr_format, Size blockSize, static bool ocl_compute(InputArray _img, Size win_stride, std::vector<float>& _descriptors, HOGDescriptor::DescriptorStorageFormat descr_format, Size blockSize,
Size cellSize, int nbins, Size blockStride, Size winSize, float sigma, bool gammaCorrection, double L2HysThreshold, bool signedGradient) Size cellSize, int nbins, Size blockStride, Size winSize, float sigma, bool gammaCorrection, double L2HysThreshold, bool signedGradient)
{ {
Size imgSize = _img.size(); Size imgSize = _img.size();
@ -1564,13 +1562,13 @@ static bool ocl_compute(InputArray _img, Size win_stride, std::vector<float>& _d
UMat descriptors(wins_per_img.area(), static_cast<int>(blocks_per_win.area() * block_hist_size), CV_32F); UMat descriptors(wins_per_img.area(), static_cast<int>(blocks_per_win.area() * block_hist_size), CV_32F);
switch (descr_format) switch (descr_format)
{ {
case DESCR_FORMAT_ROW_BY_ROW: case HOGDescriptor::DESCR_FORMAT_ROW_BY_ROW:
if(!ocl_extract_descrs_by_rows(winSize.height, winSize.width, if(!ocl_extract_descrs_by_rows(winSize.height, winSize.width,
blockStride.height, blockStride.width, win_stride.height, win_stride.width, effect_size.height, blockStride.height, blockStride.width, win_stride.height, win_stride.width, effect_size.height,
effect_size.width, block_hists, descriptors, (int)block_hist_size, descr_size, descr_width)) effect_size.width, block_hists, descriptors, (int)block_hist_size, descr_size, descr_width))
return false; return false;
break; break;
case DESCR_FORMAT_COL_BY_COL: case HOGDescriptor::DESCR_FORMAT_COL_BY_COL:
if(!ocl_extract_descrs_by_cols(winSize.height, winSize.width, if(!ocl_extract_descrs_by_cols(winSize.height, winSize.width,
blockStride.height, blockStride.width, win_stride.height, win_stride.width, effect_size.height, effect_size.width, blockStride.height, blockStride.width, win_stride.height, win_stride.width, effect_size.height, effect_size.width,
block_hists, descriptors, (int)block_hist_size, descr_size, blocks_per_win.width, blocks_per_win.height)) block_hists, descriptors, (int)block_hist_size, descr_size, blocks_per_win.width, blocks_per_win.height))
@ -1602,7 +1600,7 @@ void HOGDescriptor::compute(InputArray _img, std::vector<float>& descriptors,
Size paddedImgSize(imgSize.width + padding.width*2, imgSize.height + padding.height*2); Size paddedImgSize(imgSize.width + padding.width*2, imgSize.height + padding.height*2);
CV_OCL_RUN(_img.dims() <= 2 && _img.type() == CV_8UC1 && _img.isUMat(), CV_OCL_RUN(_img.dims() <= 2 && _img.type() == CV_8UC1 && _img.isUMat(),
ocl_compute(_img, winStride, descriptors, DESCR_FORMAT_COL_BY_COL, blockSize, ocl_compute(_img, winStride, descriptors, HOGDescriptor::DESCR_FORMAT_COL_BY_COL, blockSize,
cellSize, nbins, blockStride, winSize, (float)getWinSigma(), gammaCorrection, L2HysThreshold, signedGradient)) cellSize, nbins, blockStride, winSize, (float)getWinSigma(), gammaCorrection, L2HysThreshold, signedGradient))
Mat img = _img.getMat(); Mat img = _img.getMat();

@ -252,7 +252,7 @@ public:
return u; return u;
} }
UMatData* allocate(int dims0, const int* sizes, int type, void* data, size_t* step, int flags, UMatUsageFlags usageFlags) const CV_OVERRIDE UMatData* allocate(int dims0, const int* sizes, int type, void* data, size_t* step, AccessFlag flags, UMatUsageFlags usageFlags) const CV_OVERRIDE
{ {
if( data != 0 ) if( data != 0 )
{ {
@ -281,7 +281,7 @@ public:
return allocate(o, dims0, sizes, type, step); return allocate(o, dims0, sizes, type, step);
} }
bool allocate(UMatData* u, int accessFlags, UMatUsageFlags usageFlags) const CV_OVERRIDE bool allocate(UMatData* u, AccessFlag accessFlags, UMatUsageFlags usageFlags) const CV_OVERRIDE
{ {
return stdAllocator->allocate(u, accessFlags, usageFlags); return stdAllocator->allocate(u, accessFlags, usageFlags);
} }

@ -175,13 +175,13 @@ private:
class CV_EXPORTS AKAZEFeaturesFinder : public detail::FeaturesFinder class CV_EXPORTS AKAZEFeaturesFinder : public detail::FeaturesFinder
{ {
public: public:
AKAZEFeaturesFinder(int descriptor_type = AKAZE::DESCRIPTOR_MLDB, AKAZEFeaturesFinder(AKAZE::DescriptorType descriptor_type = AKAZE::DESCRIPTOR_MLDB,
int descriptor_size = 0, int descriptor_size = 0,
int descriptor_channels = 3, int descriptor_channels = 3,
float threshold = 0.001f, float threshold = 0.001f,
int nOctaves = 4, int nOctaves = 4,
int nOctaveLayers = 4, int nOctaveLayers = 4,
int diffusivity = KAZE::DIFF_PM_G2); KAZE::DiffusivityType diffusivity = KAZE::DIFF_PM_G2);
private: private:
void find(InputArray image, ImageFeatures &features) CV_OVERRIDE; void find(InputArray image, ImageFeatures &features) CV_OVERRIDE;

@ -576,13 +576,13 @@ void OrbFeaturesFinder::find(InputArray image, ImageFeatures &features)
} }
} }
AKAZEFeaturesFinder::AKAZEFeaturesFinder(int descriptor_type, AKAZEFeaturesFinder::AKAZEFeaturesFinder(AKAZE::DescriptorType descriptor_type,
int descriptor_size, int descriptor_size,
int descriptor_channels, int descriptor_channels,
float threshold, float threshold,
int nOctaves, int nOctaves,
int nOctaveLayers, int nOctaveLayers,
int diffusivity) KAZE::DiffusivityType diffusivity)
{ {
akaze = AKAZE::create(descriptor_type, descriptor_size, descriptor_channels, akaze = AKAZE::create(descriptor_type, descriptor_size, descriptor_channels,
threshold, nOctaves, nOctaveLayers, diffusivity); threshold, nOctaves, nOctaveLayers, diffusivity);

@ -184,7 +184,7 @@ double getMaxVal(int depth);
Size randomSize(RNG& rng, double maxSizeLog); Size randomSize(RNG& rng, double maxSizeLog);
void randomSize(RNG& rng, int minDims, int maxDims, double maxSizeLog, vector<int>& sz); void randomSize(RNG& rng, int minDims, int maxDims, double maxSizeLog, vector<int>& sz);
int randomType(RNG& rng, int typeMask, int minChannels, int maxChannels); int randomType(RNG& rng, cv::_OutputArray::DepthMask typeMask, int minChannels, int maxChannels);
Mat randomMat(RNG& rng, Size size, int type, double minVal, double maxVal, bool useRoi); Mat randomMat(RNG& rng, Size size, int type, double minVal, double maxVal, bool useRoi);
Mat randomMat(RNG& rng, const vector<int>& size, int type, double minVal, double maxVal, bool useRoi); Mat randomMat(RNG& rng, const vector<int>& size, int type, double minVal, double maxVal, bool useRoi);
void add(const Mat& a, double alpha, const Mat& b, double beta, void add(const Mat& a, double alpha, const Mat& b, double beta,

@ -68,7 +68,7 @@ void randomSize(RNG& rng, int minDims, int maxDims, double maxSizeLog, vector<in
} }
} }
int randomType(RNG& rng, int typeMask, int minChannels, int maxChannels) int randomType(RNG& rng, _OutputArray::DepthMask typeMask, int minChannels, int maxChannels)
{ {
int channels = rng.uniform(minChannels, maxChannels+1); int channels = rng.uniform(minChannels, maxChannels+1);
int depth = 0; int depth = 0;

@ -704,7 +704,7 @@ int cv::buildOpticalFlowPyramid(InputArray _img, OutputArrayOfArrays pyramid, Si
CV_Assert(img.depth() == CV_8U && winSize.width > 2 && winSize.height > 2 ); CV_Assert(img.depth() == CV_8U && winSize.width > 2 && winSize.height > 2 );
int pyrstep = withDerivatives ? 2 : 1; int pyrstep = withDerivatives ? 2 : 1;
pyramid.create(1, (maxLevel + 1) * pyrstep, 0 /*type*/, -1, true, 0); pyramid.create(1, (maxLevel + 1) * pyrstep, 0 /*type*/, -1, true);
int derivType = CV_MAKETYPE(DataType<cv::detail::deriv_type>::depth, img.channels() * 2); int derivType = CV_MAKETYPE(DataType<cv::detail::deriv_type>::depth, img.channels() * 2);
@ -783,7 +783,7 @@ int cv::buildOpticalFlowPyramid(InputArray _img, OutputArrayOfArrays pyramid, Si
sz = Size((sz.width+1)/2, (sz.height+1)/2); sz = Size((sz.width+1)/2, (sz.height+1)/2);
if( sz.width <= winSize.width || sz.height <= winSize.height ) if( sz.width <= winSize.width || sz.height <= winSize.height )
{ {
pyramid.create(1, (level + 1) * pyrstep, 0 /*type*/, -1, true, 0);//check this pyramid.create(1, (level + 1) * pyrstep, 0 /*type*/, -1, true);//check this
return level; return level;
} }

Loading…
Cancel
Save