From a0cbca2c1694f37dc96ecd6911a9ead85240a5d9 Mon Sep 17 00:00:00 2001 From: Hamdi Sahloul Date: Fri, 21 Sep 2018 18:10:58 +0900 Subject: [PATCH] PR #12487 --- modules/core/include/opencv2/core.hpp | 9 ++++++++ modules/core/include/opencv2/core/base.hpp | 2 +- modules/core/include/opencv2/core/cvdef.h | 2 +- .../core/include/opencv2/core/hal/interface.h | 22 +++++++++++++++++++ modules/core/include/opencv2/core/mat.hpp | 1 + modules/core/test/test_mat.cpp | 6 ++--- modules/java/generator/gen_java.py | 4 +++- 7 files changed, 40 insertions(+), 6 deletions(-) diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index 1e271a6fd312..baaaeed5ef44 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -3253,6 +3253,15 @@ template<> struct ParamType enum { type = Param::SCALAR }; }; +template +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; + + enum { type = Param::INT }; +}; + //! @} core_basic } //namespace cv diff --git a/modules/core/include/opencv2/core/base.hpp b/modules/core/include/opencv2/core/base.hpp index 24f92b5413fa..443f5b49ba63 100644 --- a/modules/core/include/opencv2/core/base.hpp +++ b/modules/core/include/opencv2/core/base.hpp @@ -450,7 +450,7 @@ configurations while CV_DbgAssert is only retained in the Debug configuration. #define CV_Assert_9( expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8, expr9 ) CV_Assert_8(expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8 ); CV_Assert_1(expr9) #define CV_Assert_10( expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8, expr9, expr10 ) CV_Assert_9(expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8, expr9 ); CV_Assert_1(expr10) -#define CV_Assert_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 diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h index 8c4ae7d9f9b9..429931317acf 100644 --- a/modules/core/include/opencv2/core/cvdef.h +++ b/modules/core/include/opencv2/core/cvdef.h @@ -80,7 +80,7 @@ namespace cv { namespace debug_build_guard { } using namespace debug_build_guard #endif #define __CV_VA_NUM_ARGS_HELPER(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N -#define __CV_VA_NUM_ARGS(...) __CV_VA_NUM_ARGS_HELPER(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) +#define __CV_VA_NUM_ARGS(...) __CV_EXPAND(__CV_VA_NUM_ARGS_HELPER(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)) // undef problematic defines sometimes defined by system headers (windows.h in particular) #undef small diff --git a/modules/core/include/opencv2/core/hal/interface.h b/modules/core/include/opencv2/core/hal/interface.h index 6f0a83d35928..df846e9b0691 100644 --- a/modules/core/include/opencv2/core/hal/interface.h +++ b/modules/core/include/opencv2/core/hal/interface.h @@ -66,6 +66,28 @@ typedef signed char schar; #define CV_USRTYPE1 (void)"CV_USRTYPE1 support has been dropped in OpenCV 4.0" +//! test: Simplify the reviewer life +//Reduced version of PR #12487 +//TODO: Remove these before merege +#define ElemType int +#define ElemDepth int +#define MagicFlag int +#define CV_DEPTH_AUTO -1 +#define CV_TYPE_AUTO -1 +#define __CV_MAX_DEPTH_0(m, n) (m != 7 || n <= 3 ? m : n) /* CV_16F workaround */ +#define __CV_MAX_DEPTH_1(d1, d2) __CV_MAX_DEPTH_0(std::max(d1, d2), std::min(d1, d2)) +#define __CV_MAX_DEPTH_2(d1, d2) __CV_MAX_DEPTH_1(static_cast(d1), static_cast(d2)) +#define __CV_MAX_DEPTH_3(d, ...) __CV_EXPAND(__CV_MAX_DEPTH_2(d, __CV_MAX_DEPTH_2(__VA_ARGS__))) +#define __CV_MAX_DEPTH_4(d, ...) __CV_EXPAND(__CV_MAX_DEPTH_2(d, __CV_MAX_DEPTH_3(__VA_ARGS__))) +#define CV_MAX_DEPTH(...) __CV_EXPAND(static_cast(__CV_CAT(__CV_MAX_DEPTH_, __CV_VA_NUM_ARGS(__VA_ARGS__)) (__VA_ARGS__))) +#define __CV_MIN_DEPTH_0(m, n) (m == 7 && n >= 4 ? m : n) /* CV_16F workaround */ +#define __CV_MIN_DEPTH_1(d1, d2) __CV_MIN_DEPTH_0(std::max(d1, d2), std::min(d1, d2)) +#define __CV_MIN_DEPTH_2(d1, d2) __CV_MIN_DEPTH_1(static_cast(d1), static_cast(d2)) +#define __CV_MIN_DEPTH_3(d, ...) __CV_EXPAND(__CV_MIN_DEPTH_2(d, __CV_MIN_DEPTH_2(__VA_ARGS__))) +#define __CV_MIN_DEPTH_4(d, ...) __CV_EXPAND(__CV_MIN_DEPTH_2(d, __CV_MIN_DEPTH_3(__VA_ARGS__))) +#define CV_MIN_DEPTH(...) __CV_EXPAND(static_cast(__CV_CAT(__CV_MIN_DEPTH_, __CV_VA_NUM_ARGS(__VA_ARGS__)) (__VA_ARGS__))) +//end of ! test + #define CV_CN_MAX 512 #define CV_CN_SHIFT 3 #define CV_DEPTH_MAX (1 << CV_CN_SHIFT) diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index 2efcf17b6cca..2daeb432f8ea 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -287,6 +287,7 @@ There are several synonyms for OutputArray that are used to assist automatic Pyt class CV_EXPORTS _OutputArray : public _InputArray { public: + typedef int DepthMask; //TODO: Remove me enum { DEPTH_MASK_8U = 1 << CV_8U, diff --git a/modules/core/test/test_mat.cpp b/modules/core/test/test_mat.cpp index dab8373d5e5b..32b83d431b45 100644 --- a/modules/core/test/test_mat.cpp +++ b/modules/core/test/test_mat.cpp @@ -946,7 +946,7 @@ void Core_ArrayOpTest::run( int /* start_from */) } -template +template int calcDiffElemCountImpl(const vector& mv, const Mat& m) { int diffElemCount = 0; @@ -955,12 +955,12 @@ int calcDiffElemCountImpl(const vector& mv, const Mat& m) { for(int x = 0; x < m.cols; x++) { - const ElemType* mElem = &m.at(y,x*mChannels); + const T* mElem = &m.at(y, x*mChannels); size_t loc = 0; for(size_t i = 0; i < mv.size(); i++) { const size_t mvChannel = mv[i].channels(); - const ElemType* mvElem = &mv[i].at(y,x*(int)mvChannel); + const T* mvElem = &mv[i].at(y, x*(int)mvChannel); for(size_t li = 0; li < mvChannel; li++) if(mElem[loc + li] != mvElem[li]) diffElemCount++; diff --git a/modules/java/generator/gen_java.py b/modules/java/generator/gen_java.py index c2f6e8514c5b..f17819fadfb8 100755 --- a/modules/java/generator/gen_java.py +++ b/modules/java/generator/gen_java.py @@ -64,7 +64,9 @@ def checkFileRemap(path): "size_t" : { "j_type" : "long", "jn_type" : "long", "jni_type" : "jlong", "suffix" : "J" }, "__int64" : { "j_type" : "long", "jn_type" : "long", "jni_type" : "jlong", "suffix" : "J" }, "int64" : { "j_type" : "long", "jn_type" : "long", "jni_type" : "jlong", "suffix" : "J" }, - "double[]": { "j_type" : "double[]", "jn_type" : "double[]", "jni_type" : "jdoubleArray", "suffix" : "_3D" } + "double[]": { "j_type" : "double[]", "jn_type" : "double[]", "jni_type" : "jdoubleArray", "suffix" : "_3D" }, + "ElemType": { "j_type" : "int", "jn_type" : "int", "jni_type" : "jint", "suffix" : "I", "cast_from" : "int", "cast_to" : "ElemType" }, + "ElemDepth": { "j_type" : "int", "jn_type" : "int", "jni_type" : "jint", "suffix" : "I", "cast_from" : "int", "cast_to" : "ElemDepth" }, } # Defines a rule to add extra prefixes for names from specific namespaces.