From e7b8206a417709037add97c55efeebeca371e7b7 Mon Sep 17 00:00:00 2001 From: Hamdi Sahloul Date: Wed, 12 Sep 2018 22:20:30 +0900 Subject: [PATCH 01/10] Refactor core module --- CMakeLists.txt | 15 + modules/core/include/opencv2/core.hpp | 73 ++-- modules/core/include/opencv2/core/affine.hpp | 15 +- modules/core/include/opencv2/core/check.hpp | 16 +- modules/core/include/opencv2/core/cuda.hpp | 56 +-- .../core/include/opencv2/core/cuda.inl.hpp | 76 ++-- modules/core/include/opencv2/core/cvdef.h | 24 +- .../core/include/opencv2/core/cvstd.inl.hpp | 10 +- modules/core/include/opencv2/core/directx.hpp | 4 +- modules/core/include/opencv2/core/hal/hal.hpp | 6 +- .../core/include/opencv2/core/hal/interface.h | 141 +++++-- modules/core/include/opencv2/core/mat.hpp | 255 +++++++----- modules/core/include/opencv2/core/mat.inl.hpp | 382 +++++++++--------- modules/core/include/opencv2/core/matx.hpp | 54 ++- modules/core/include/opencv2/core/ocl.hpp | 8 +- modules/core/include/opencv2/core/opengl.hpp | 30 +- .../core/include/opencv2/core/operations.hpp | 8 +- .../include/opencv2/core/private.cuda.hpp | 4 +- modules/core/include/opencv2/core/private.hpp | 2 +- modules/core/include/opencv2/core/traits.hpp | 145 +++---- modules/core/include/opencv2/core/types.hpp | 157 ++++--- modules/core/include/opencv2/core/types_c.h | 7 +- .../core/misc/java/src/cpp/core_manual.hpp | 8 +- modules/core/misc/python/pyopencv_core.hpp | 30 +- modules/core/misc/python/pyopencv_cuda.hpp | 30 ++ modules/core/misc/python/shadow_umat.hpp | 8 +- modules/core/perf/perf_merge.cpp | 2 +- modules/core/src/arithm.cpp | 162 ++++---- modules/core/src/array.cpp | 100 +++-- modules/core/src/batch_distance.cpp | 4 +- modules/core/src/channels.cpp | 19 +- modules/core/src/check.cpp | 34 +- modules/core/src/convert.cpp | 26 +- modules/core/src/convert_c.cpp | 2 +- modules/core/src/convert_scale.cpp | 45 ++- modules/core/src/copy.cpp | 27 +- modules/core/src/count_non_zero.cpp | 13 +- modules/core/src/cuda/gpu_mat.cu | 42 +- modules/core/src/cuda_gpu_mat.cpp | 28 +- modules/core/src/cuda_host_mem.cpp | 8 +- modules/core/src/cuda_stream.cpp | 2 +- modules/core/src/datastructs.cpp | 2 +- modules/core/src/directx.cpp | 16 +- modules/core/src/downhill_simplex.cpp | 4 +- modules/core/src/dxt.cpp | 65 +-- modules/core/src/hal_replacement.hpp | 8 +- modules/core/src/lapack.cpp | 15 +- modules/core/src/lda.cpp | 5 +- modules/core/src/lut.cpp | 6 +- modules/core/src/mathfuncs.cpp | 55 ++- modules/core/src/matmul.cpp | 124 +++--- modules/core/src/matrix.cpp | 48 +-- modules/core/src/matrix_c.cpp | 22 +- modules/core/src/matrix_expressions.cpp | 133 +++--- modules/core/src/matrix_operations.cpp | 59 +-- modules/core/src/matrix_sparse.cpp | 50 +-- modules/core/src/matrix_wrap.cpp | 43 +- modules/core/src/mean.cpp | 21 +- modules/core/src/merge.cpp | 15 +- modules/core/src/minmax.cpp | 16 +- modules/core/src/norm.cpp | 28 +- modules/core/src/ocl.cpp | 51 ++- modules/core/src/opengl.cpp | 36 +- modules/core/src/pca.cpp | 10 +- modules/core/src/persistence.cpp | 4 +- modules/core/src/persistence.hpp | 2 +- modules/core/src/persistence_base64.cpp | 2 +- modules/core/src/persistence_c.cpp | 2 +- modules/core/src/persistence_types.cpp | 20 +- modules/core/src/precomp.hpp | 10 +- modules/core/src/rand.cpp | 3 +- modules/core/src/split.cpp | 14 +- modules/core/src/stat.hpp | 4 +- modules/core/src/sum.cpp | 15 +- modules/core/src/umatrix.cpp | 83 ++-- modules/core/src/va_intel.cpp | 4 +- modules/core/test/test_countnonzero.cpp | 8 +- modules/java/generator/gen_java.py | 2 +- 78 files changed, 1694 insertions(+), 1389 deletions(-) create mode 100644 modules/core/misc/python/pyopencv_cuda.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index e54b77ec2f03..a8e88bcde643 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -315,6 +315,8 @@ OCV_OPTION(INSTALL_TESTS "Install accuracy and performance test binar # OpenCV build options # =================================================== +OCV_OPTION(ENABLE_TYPE_SAFE_API "Enable enum-based type-safe API? If disabled, int types will be utilized" ON) +OCV_OPTION(ENABLE_COMPATIBLE_API "Enable backwards compatibility with legacy API?" ON IF ENABLE_TYPE_SAFE_API) OCV_OPTION(ENABLE_CCACHE "Use ccache" (UNIX AND NOT IOS AND (CMAKE_GENERATOR MATCHES "Makefile" OR CMAKE_GENERATOR MATCHES "Ninja")) ) OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" ON IF (MSVC OR (NOT IOS AND NOT CMAKE_CROSSCOMPILING) ) ) OCV_OPTION(ENABLE_SOLUTION_FOLDERS "Solution folder in Visual Studio or in other IDEs" (MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode) ) @@ -343,6 +345,16 @@ OCV_OPTION(CV_TRACE "Enable OpenCV code trace" ON) OCV_OPTION(ENABLE_PYLINT "Add target with Pylint checks" (BUILD_DOCS OR BUILD_EXAMPLES) IF (NOT CMAKE_CROSSCOMPILING AND NOT APPLE_FRAMEWORK) ) OCV_OPTION(ENABLE_FLAKE8 "Add target with Python flake8 checker" (BUILD_DOCS OR BUILD_EXAMPLES) IF (NOT CMAKE_CROSSCOMPILING AND NOT APPLE_FRAMEWORK) ) +if(ENABLE_TYPE_SAFE_API) + add_definitions(-DCV_TYPE_SAFE_API) +else() + set(ENABLE_COMPATIBLE_API OFF) +endif() + +if(ENABLE_COMPATIBLE_API) + add_definitions(-DCV_COMPATIBLE_API) +endif() + if(ENABLE_IMPL_COLLECTION) add_definitions(-DCV_COLLECT_IMPL_DATA) endif() @@ -1020,6 +1032,9 @@ else() endif() status(" ccache:" OPENCV_COMPILER_IS_CCACHE THEN YES ELSE NO) status(" Precompiled headers:" PCHSupport_FOUND AND ENABLE_PRECOMPILED_HEADERS THEN YES ELSE NO) +status(" Type-safe API:" ENABLE_TYPE_SAFE_API THEN "YES" ELSE "NO") +status(" Compatible API:" ENABLE_COMPATIBLE_API THEN "YES" ELSE "NO") + # ========================== Dependencies ============================ ocv_get_all_libs(deps_modules deps_extra deps_3rdparty) diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index c8216b28f393..443a1a29b249 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -325,23 +325,23 @@ The first function in the list above can be replaced with matrix expressions: @endcode The input arrays and the output array can all have the same or different depths. For example, you can add a 16-bit unsigned array to a 8-bit signed array and store the sum as a 32-bit -floating-point array. Depth of the output array is determined by the dtype parameter. In the second -and third cases above, as well as in the first case, when src1.depth() == src2.depth(), dtype can -be set to the default -1. In this case, the output array will have the same depth as the input +floating-point array. Depth of the output array is determined by the ddepth parameter. In the second +and third cases above, as well as in the first case, when src1.depth() == src2.depth(), ddepth can +be set to the default CV_TYPE_AUTO. In this case, the output array will have the same depth as the input array, be it src1, src2 or both. @note Saturation is not applied when the output array has the depth CV_32S. You may even get result of an incorrect sign in the case of overflow. @param src1 first input array or a scalar. @param src2 second input array or a scalar. @param dst output array that has the same size and number of channels as the input array(s); the -depth is defined by dtype or src1/src2. +depth is defined by ddepth or src1/src2. @param mask optional operation mask - 8-bit single channel array, that specifies elements of the output array to be changed. -@param dtype optional depth of the output array (see the discussion below). +@param ddepth optional depth of the output array (see the discussion below). @sa subtract, addWeighted, scaleAdd, Mat::convertTo */ CV_EXPORTS_W void add(InputArray src1, InputArray src2, OutputArray dst, - InputArray mask = noArray(), int dtype = -1); + InputArray mask = noArray(), ElemType ddepth = CV_TYPE_AUTO); /** @brief Calculates the per-element difference between two arrays or array and a scalar. @@ -367,8 +367,8 @@ The first function in the list above can be replaced with matrix expressions: @endcode The input arrays and the output array can all have the same or different depths. For example, you can subtract to 8-bit unsigned arrays and store the difference in a 16-bit signed array. Depth of -the output array is determined by dtype parameter. In the second and third cases above, as well as -in the first case, when src1.depth() == src2.depth(), dtype can be set to the default -1. In this +the output array is determined by ddepth parameter. In the second and third cases above, as well as +in the first case, when src1.depth() == src2.depth(), ddepth can be set to the default CV_TYPE_AUTO. In this case the output array will have the same depth as the input array, be it src1, src2 or both. @note Saturation is not applied when the output array has the depth CV_32S. You may even get result of an incorrect sign in the case of overflow. @@ -377,11 +377,11 @@ result of an incorrect sign in the case of overflow. @param dst output array of the same size and the same number of channels as the input array. @param mask optional operation mask; this is an 8-bit single channel array that specifies elements of the output array to be changed. -@param dtype optional depth of the output array +@param ddepth optional depth of the output array @sa add, addWeighted, scaleAdd, Mat::convertTo */ CV_EXPORTS_W void subtract(InputArray src1, InputArray src2, OutputArray dst, - InputArray mask = noArray(), int dtype = -1); + InputArray mask = noArray(), ElemType ddepth = CV_TYPE_AUTO); /** @brief Calculates the per-element scaled product of two arrays. @@ -401,12 +401,12 @@ overflow. @param src2 second input array of the same size and the same type as src1. @param dst output array of the same size and type as src1. @param scale optional scale factor. -@param dtype optional depth of the output array +@param ddepth optional depth of the output array @sa add, subtract, divide, scaleAdd, addWeighted, accumulate, accumulateProduct, accumulateSquare, Mat::convertTo */ CV_EXPORTS_W void multiply(InputArray src1, InputArray src2, - OutputArray dst, double scale = 1, int dtype = -1); + OutputArray dst, double scale = 1, ElemType ddepth = CV_TYPE_AUTO); /** @brief Performs per-element division of two arrays or a scalar by an array. @@ -424,16 +424,16 @@ result of an incorrect sign in the case of overflow. @param src2 second input array of the same size and type as src1. @param scale scalar factor. @param dst output array of the same size and type as src2. -@param dtype optional depth of the output array; if -1, dst will have depth src2.depth(), but in +@param ddepth optional depth of the output array; if CV_TYPE_AUTO, dst will have depth src2.depth(), but in case of an array-by-array division, you can only pass -1 when src1.depth()==src2.depth(). @sa multiply, add, subtract */ CV_EXPORTS_W void divide(InputArray src1, InputArray src2, OutputArray dst, - double scale = 1, int dtype = -1); + double scale = 1, ElemType ddepth = CV_TYPE_AUTO); /** @overload */ CV_EXPORTS_W void divide(double scale, InputArray src2, - OutputArray dst, int dtype = -1); + OutputArray dst, ElemType ddepth = CV_TYPE_AUTO); /** @brief Calculates the sum of a scaled array and another array. @@ -477,12 +477,12 @@ result of an incorrect sign in the case of overflow. @param beta weight of the second array elements. @param gamma scalar added to each sum. @param dst output array that has the same size and number of channels as the input arrays. -@param dtype optional depth of the output array; when both input arrays have the same depth, dtype -can be set to -1, which will be equivalent to src1.depth(). +@param ddepth optional depth of the output array; when both input arrays have the same depth, ddepth +can be set to CV_TYPE_AUTO, which will be equivalent to src1.depth(). @sa add, subtract, scaleAdd, Mat::convertTo */ CV_EXPORTS_W void addWeighted(InputArray src1, double alpha, InputArray src2, - double beta, double gamma, OutputArray dst, int dtype = -1); + double beta, double gamma, OutputArray dst, ElemType ddepth = CV_TYPE_AUTO); /** @brief Scales, calculates absolute values, and converts the result to 8-bit. @@ -706,7 +706,7 @@ see http://en.wikipedia.org/wiki/Nearest_neighbor_search @todo document */ CV_EXPORTS_W void batchDistance(InputArray src1, InputArray src2, - OutputArray dist, int dtype, OutputArray nidx, + OutputArray dist, ElemType dtype, OutputArray nidx, int normType = NORM_L2, int K = 0, InputArray mask = noArray(), int update = 0, bool crosscheck = false); @@ -764,13 +764,12 @@ normalization. @param beta upper range boundary in case of the range normalization; it is not used for the norm normalization. @param norm_type normalization type (see cv::NormTypes). -@param dtype when negative, the output array has the same type as src; otherwise, it has the same -number of channels as src and the depth =CV_MAT_DEPTH(dtype). +@param ddepth desired output matrix depth. when it is CV_TYPE_AUTO, the output array has the same type as src. @param mask optional operation mask. @sa norm, Mat::convertTo, SparseMat::convertTo */ CV_EXPORTS_W void normalize( InputArray src, InputOutputArray dst, double alpha = 1, double beta = 0, - int norm_type = NORM_L2, int dtype = -1, InputArray mask = noArray()); + int norm_type = NORM_L2, ElemType ddepth = CV_TYPE_AUTO, InputArray mask = noArray()); /** @overload @param src input array. @@ -858,15 +857,15 @@ And the following code demonstrates its usage for a two-channel matrix. @snippet snippets/core_reduce.cpp example2 @param src input 2D matrix. -@param dst output vector. Its size and type is defined by dim and dtype parameters. +@param dst output vector. Its size and type is defined by dim and ddepth parameters. @param dim dimension index along which the matrix is reduced. 0 means that the matrix is reduced to a single row. 1 means that the matrix is reduced to a single column. @param rtype reduction operation that could be one of #ReduceTypes -@param dtype when negative, the output vector will have the same type as the input matrix, -otherwise, its type will be CV_MAKE_TYPE(CV_MAT_DEPTH(dtype), src.channels()). +@param ddepth when it is CV_TYPE_AUTO, the output vector will have the same type as the input matrix, +otherwise, its type will be CV_MAKE_TYPE(ddepth, src.channels()). @sa repeat */ -CV_EXPORTS_W void reduce(InputArray src, OutputArray dst, int dim, int rtype, int dtype = -1); +CV_EXPORTS_W void reduce(InputArray src, OutputArray dst, int dim, int rtype, ElemType ddepth = CV_TYPE_AUTO); /** @brief Creates one multi-channel array out of several single-channel ones. @@ -1649,16 +1648,16 @@ assumed to be zero, that is, nothing is subtracted. If it has the same size as src , it is simply subtracted. Otherwise, it is "repeated" (see repeat ) to cover the full src and then subtracted. Type of the delta matrix, when it is not empty, must be the same as the type of created -output matrix. See the dtype parameter description below. +output matrix. See the ddepth parameter description below. @param scale Optional scale factor for the matrix product. -@param dtype Optional type of the output matrix. When it is negative, -the output matrix will have the same type as src . Otherwise, it will be -type=CV_MAT_DEPTH(dtype) that should be either CV_32F or CV_64F . +@param ddepth Optional depth of the output matrix. When it is CV_TYPE_AUTO, +the output matrix will have the same type as src . Otherwise, it should be either CV_32F or CV_64F, +and the output type will be CV_MAKE_TYPE(ddepth, src.channels()). @sa calcCovarMatrix, gemm, repeat, reduce */ CV_EXPORTS_W void mulTransposed( InputArray src, OutputArray dst, bool aTa, InputArray delta = noArray(), - double scale = 1, int dtype = -1 ); + double scale = 1, ElemType ddepth = CV_TYPE_AUTO); /** @brief Transposes a matrix. @@ -1938,26 +1937,26 @@ The function cv::calcCovarMatrix calculates the covariance matrix and, optionall the set of input vectors. @param samples samples stored as separate matrices @param nsamples number of samples -@param covar output covariance matrix of the type ctype and square size. +@param covar output covariance matrix of the depth cdepth and square size. @param mean input or output (depending on the flags) array as the average value of the input vectors. @param flags operation flags as a combination of #CovarFlags -@param ctype type of the matrixl; it equals 'CV_64F' by default. +@param cdepth depth of the matrixl; it equals 'CV_64F' by default. @sa PCA, mulTransposed, Mahalanobis @todo InputArrayOfArrays */ CV_EXPORTS void calcCovarMatrix( const Mat* samples, int nsamples, Mat& covar, Mat& mean, - int flags, int ctype = CV_64F); + int flags, ElemType cdepth = CV_64F); /** @overload @note use #COVAR_ROWS or #COVAR_COLS flag @param samples samples stored as rows/columns of a single matrix. -@param covar output covariance matrix of the type ctype and square size. +@param covar output covariance matrix of the depth cdepth and square size. @param mean input or output (depending on the flags) array as the average value of the input vectors. @param flags operation flags as a combination of #CovarFlags -@param ctype type of the matrixl; it equals 'CV_64F' by default. +@param cdepth depth of the matrixl; it equals 'CV_64F' by default. */ CV_EXPORTS_W void calcCovarMatrix( InputArray samples, OutputArray covar, - InputOutputArray mean, int flags, int ctype = CV_64F); + InputOutputArray mean, int flags, ElemType cdepth = CV_64F); /** wrap PCA::operator() */ CV_EXPORTS_W void PCACompute(InputArray data, InputOutputArray mean, diff --git a/modules/core/include/opencv2/core/affine.hpp b/modules/core/include/opencv2/core/affine.hpp index 7e2ed3078583..203e191aaf2e 100644 --- a/modules/core/include/opencv2/core/affine.hpp +++ b/modules/core/include/opencv2/core/affine.hpp @@ -300,23 +300,22 @@ namespace cv typedef Affine3::work_type> work_type; typedef _Tp channel_type; - enum { generic_type = 0, - channels = 16, - fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = 16; + static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemType depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; typedef Vec vec_type; }; namespace traits { template - struct Depth< Affine3<_Tp> > { enum { value = Depth<_Tp>::value }; }; + struct Depth< Affine3<_Tp> > { static const ElemType value = Depth<_Tp>::value; }; template - struct Type< Affine3<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 16) }; }; + struct Type< Affine3<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 16); }; } // namespace //! @} core diff --git a/modules/core/include/opencv2/core/check.hpp b/modules/core/include/opencv2/core/check.hpp index bf441383e840..2db6e39f1c96 100644 --- a/modules/core/include/opencv2/core/check.hpp +++ b/modules/core/include/opencv2/core/check.hpp @@ -10,20 +10,20 @@ namespace cv { /** Returns string of cv::Mat depth value: CV_8U -> "CV_8U" or "" */ -CV_EXPORTS const char* depthToString(int depth); +CV_EXPORTS const char* depthToString(ElemType depth); /** Returns string of cv::Mat depth value: CV_8UC3 -> "CV_8UC3" or "" */ -CV_EXPORTS const String typeToString(int type); +CV_EXPORTS const String typeToString(ElemType type); //! @cond IGNORED namespace detail { /** Returns string of cv::Mat depth value: CV_8U -> "CV_8U" or NULL */ -CV_EXPORTS const char* depthToString_(int depth); +CV_EXPORTS const char* depthToString_(ElemType depth); /** Returns string of cv::Mat depth value: CV_8UC3 -> "CV_8UC3" or cv::String() */ -CV_EXPORTS const cv::String typeToString_(int type); +CV_EXPORTS const cv::String typeToString_(ElemType type); enum TestOp { TEST_CUSTOM = 0, @@ -69,16 +69,16 @@ CV_EXPORTS void CV_NORETURN check_failed_auto(const int v1, const int v2, const CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v1, const size_t v2, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const float v1, const float v2, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const double v1, const double v2, const CheckContext& ctx); -CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const int v1, const int v2, const CheckContext& ctx); -CV_EXPORTS void CV_NORETURN check_failed_MatType(const int v1, const int v2, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const ElemType v1, const ElemType v2, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatType(const ElemType v1, const ElemType v2, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v1, const int v2, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const int v, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const float v, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const double v, const CheckContext& ctx); -CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const int v, const CheckContext& ctx); -CV_EXPORTS void CV_NORETURN check_failed_MatType(const int v, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const ElemType v, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatType(const ElemType v, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v, const CheckContext& ctx); diff --git a/modules/core/include/opencv2/core/cuda.hpp b/modules/core/include/opencv2/core/cuda.hpp index 4863a6567457..d765dba734ef 100644 --- a/modules/core/include/opencv2/core/cuda.hpp +++ b/modules/core/include/opencv2/core/cuda.hpp @@ -123,19 +123,19 @@ class CV_EXPORTS_W GpuMat CV_WRAP explicit GpuMat(GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); //! constructs GpuMat of the specified size and type - CV_WRAP GpuMat(int rows, int cols, int type, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); - CV_WRAP GpuMat(Size size, int type, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); + CV_WRAP GpuMat(int rows, int cols, ElemType type, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); + CV_WRAP GpuMat(Size size, ElemType type, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); //! constucts GpuMat and fills it with the specified value _s - CV_WRAP GpuMat(int rows, int cols, int type, Scalar s, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); - CV_WRAP GpuMat(Size size, int type, Scalar s, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); + CV_WRAP GpuMat(int rows, int cols, ElemType type, Scalar s, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); + CV_WRAP GpuMat(Size size, ElemType type, Scalar s, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); //! copy constructor CV_WRAP GpuMat(const GpuMat& m); //! constructor for GpuMat headers pointing to user-allocated data - CV_WRAP GpuMat(int rows, int cols, int type, void* data, size_t step = Mat::AUTO_STEP); - CV_WRAP GpuMat(Size size, int type, void* data, size_t step = Mat::AUTO_STEP); + CV_WRAP GpuMat(int rows, int cols, ElemType type, void* data, size_t step = Mat::AUTO_STEP); + CV_WRAP GpuMat(Size size, ElemType type, void* data, size_t step = Mat::AUTO_STEP); //! creates a GpuMat header for a part of the bigger matrix CV_WRAP GpuMat(const GpuMat& m, Range rowRange, Range colRange); @@ -151,8 +151,8 @@ class CV_EXPORTS_W GpuMat GpuMat& operator =(const GpuMat& m); //! allocates new GpuMat data unless the GpuMat already has specified size and type - CV_WRAP void create(int rows, int cols, int type); - CV_WRAP void create(Size size, int type); + CV_WRAP void create(int rows, int cols, ElemType type); + CV_WRAP void create(Size size, ElemType type); //! decreases reference counter, deallocate the data when reference counter reaches 0 void release(); @@ -222,21 +222,21 @@ class CV_EXPORTS_W GpuMat CV_WRAP GpuMat& setTo(Scalar s, InputArray mask, Stream& stream); //! converts GpuMat to another datatype (Blocking call) - CV_WRAP void convertTo(OutputArray dst, int rtype) const; + CV_WRAP void convertTo(OutputArray dst, ElemType ddepth) const; //! converts GpuMat to another datatype (Non-Blocking call) - CV_WRAP void convertTo(OutputArray dst, int rtype, Stream& stream) const; + CV_WRAP void convertTo(OutputArray dst, ElemType ddepth, Stream& stream) const; //! converts GpuMat to another datatype with scaling (Blocking call) - CV_WRAP void convertTo(OutputArray dst, int rtype, double alpha, double beta = 0.0) const; + CV_WRAP void convertTo(OutputArray dst, ElemType ddepth, double alpha, double beta = 0.0) const; //! converts GpuMat to another datatype with scaling (Non-Blocking call) - CV_WRAP void convertTo(OutputArray dst, int rtype, double alpha, Stream& stream) const; + CV_WRAP void convertTo(OutputArray dst, ElemType ddepth, double alpha, Stream& stream) const; //! converts GpuMat to another datatype with scaling (Non-Blocking call) - CV_WRAP void convertTo(OutputArray dst, int rtype, double alpha, double beta, Stream& stream) const; + CV_WRAP void convertTo(OutputArray dst, ElemType ddepth, double alpha, double beta, Stream& stream) const; - CV_WRAP void assignTo(GpuMat& m, int type = -1) const; + CV_WRAP void assignTo(GpuMat& m, ElemType depth = CV_TYPE_AUTO) const; //! returns pointer to y-th row uchar* ptr(int y = 0); @@ -288,10 +288,10 @@ class CV_EXPORTS_W GpuMat CV_WRAP size_t elemSize1() const; //! returns element type - CV_WRAP int type() const; + CV_WRAP ElemType type() const; //! returns element type - CV_WRAP int depth() const; + CV_WRAP ElemType depth() const; //! returns number of channels CV_WRAP int channels() const; @@ -314,7 +314,7 @@ class CV_EXPORTS_W GpuMat - depth - number of channels */ - int flags; + MagicFlag flags; //! the number of rows and columns int rows, cols; @@ -348,7 +348,7 @@ class CV_EXPORTS_W GpuMat Matrix is called continuous if its elements are stored continuously, that is, without gaps at the end of each row. */ -CV_EXPORTS_W void createContinuous(int rows, int cols, int type, OutputArray arr); +CV_EXPORTS_W void createContinuous(int rows, int cols, ElemType type, OutputArray arr); /** @brief Ensures that the size of a matrix is big enough and the matrix has a proper type. @@ -359,7 +359,7 @@ CV_EXPORTS_W void createContinuous(int rows, int cols, int type, OutputArray arr The function does not reallocate memory if the matrix has proper attributes already. */ -CV_EXPORTS_W void ensureSizeIsEnough(int rows, int cols, int type, OutputArray arr); +CV_EXPORTS_W void ensureSizeIsEnough(int rows, int cols, ElemType type, OutputArray arr); /** @brief BufferPool for use with CUDA streams @@ -486,10 +486,10 @@ class CV_EXPORTS_W BufferPool explicit BufferPool(Stream& stream); //! Allocates a new GpuMat of given size and type. - CV_WRAP GpuMat getBuffer(int rows, int cols, int type); + CV_WRAP GpuMat getBuffer(int rows, int cols, ElemType type); //! Allocates a new GpuMat of given size and type. - CV_WRAP GpuMat getBuffer(Size size, int type) { return getBuffer(size.height, size.width, type); } + CV_WRAP GpuMat getBuffer(Size size, ElemType type) { return getBuffer(size.height, size.width, type); } //! Returns the allocator associated with the stream. CV_WRAP Ptr getAllocator() const { return allocator_; } @@ -532,8 +532,8 @@ class CV_EXPORTS_W HostMem HostMem(const HostMem& m); - CV_WRAP HostMem(int rows, int cols, int type, HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); - CV_WRAP HostMem(Size size, int type, HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); + CV_WRAP HostMem(int rows, int cols, ElemType type, HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); + CV_WRAP HostMem(Size size, ElemType type, HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); //! creates from host memory with coping data CV_WRAP explicit HostMem(InputArray arr, HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); @@ -549,8 +549,8 @@ class CV_EXPORTS_W HostMem CV_WRAP HostMem clone() const; //! allocates new matrix data unless the matrix already has specified size and type. - CV_WRAP void create(int rows, int cols, int type); - void create(Size size, int type); + CV_WRAP void create(int rows, int cols, ElemType type); + void create(Size size, ElemType type); //! creates alternative HostMem header for the same data, with different //! number of channels and/or different number of rows @@ -575,15 +575,15 @@ class CV_EXPORTS_W HostMem CV_WRAP bool isContinuous() const; CV_WRAP size_t elemSize() const; CV_WRAP size_t elemSize1() const; - CV_WRAP int type() const; - CV_WRAP int depth() const; + CV_WRAP ElemType type() const; + CV_WRAP ElemType depth() const; CV_WRAP int channels() const; CV_WRAP size_t step1() const; CV_WRAP Size size() const; CV_WRAP bool empty() const; // Please see cv::Mat for descriptions - int flags; + MagicFlag flags; int rows, cols; CV_PROP size_t step; diff --git a/modules/core/include/opencv2/core/cuda.inl.hpp b/modules/core/include/opencv2/core/cuda.inl.hpp index 35ae2e49d77f..2d614c92f418 100644 --- a/modules/core/include/opencv2/core/cuda.inl.hpp +++ b/modules/core/include/opencv2/core/cuda.inl.hpp @@ -56,28 +56,28 @@ namespace cv { namespace cuda { inline GpuMat::GpuMat(Allocator* allocator_) - : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) + : flags(CV_MAGIC_FLAG_NONE), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) {} inline -GpuMat::GpuMat(int rows_, int cols_, int type_, Allocator* allocator_) - : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) +GpuMat::GpuMat(int rows_, int cols_, ElemType type_, Allocator* allocator_) + : flags(CV_MAGIC_FLAG_NONE), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) { if (rows_ > 0 && cols_ > 0) create(rows_, cols_, type_); } inline -GpuMat::GpuMat(Size size_, int type_, Allocator* allocator_) - : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) +GpuMat::GpuMat(Size size_, ElemType type_, Allocator* allocator_) + : flags(CV_MAGIC_FLAG_NONE), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) { if (size_.height > 0 && size_.width > 0) create(size_.height, size_.width, type_); } inline -GpuMat::GpuMat(int rows_, int cols_, int type_, Scalar s_, Allocator* allocator_) - : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) +GpuMat::GpuMat(int rows_, int cols_, ElemType type_, Scalar s_, Allocator* allocator_) + : flags(CV_MAGIC_FLAG_NONE), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) { if (rows_ > 0 && cols_ > 0) { @@ -87,8 +87,8 @@ GpuMat::GpuMat(int rows_, int cols_, int type_, Scalar s_, Allocator* allocator_ } inline -GpuMat::GpuMat(Size size_, int type_, Scalar s_, Allocator* allocator_) - : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) +GpuMat::GpuMat(Size size_, ElemType type_, Scalar s_, Allocator* allocator_) + : flags(CV_MAGIC_FLAG_NONE), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) { if (size_.height > 0 && size_.width > 0) { @@ -107,7 +107,7 @@ GpuMat::GpuMat(const GpuMat& m) inline GpuMat::GpuMat(InputArray arr, Allocator* allocator_) : - flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) + flags(CV_MAGIC_FLAG_NONE), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) { upload(arr); } @@ -131,7 +131,7 @@ GpuMat& GpuMat::operator =(const GpuMat& m) } inline -void GpuMat::create(Size size_, int type_) +void GpuMat::create(Size size_, ElemType type_) { create(size_.height, size_.width, type_); } @@ -177,30 +177,30 @@ GpuMat& GpuMat::setTo(Scalar s, InputArray mask) } inline -void GpuMat::convertTo(OutputArray dst, int rtype) const +void GpuMat::convertTo(OutputArray dst, ElemType ddepth) const { - convertTo(dst, rtype, Stream::Null()); + convertTo(dst, ddepth, Stream::Null()); } inline -void GpuMat::convertTo(OutputArray dst, int rtype, double alpha, double beta) const +void GpuMat::convertTo(OutputArray dst, ElemType ddepth, double alpha, double beta) const { - convertTo(dst, rtype, alpha, beta, Stream::Null()); + convertTo(dst, ddepth, alpha, beta, Stream::Null()); } inline -void GpuMat::convertTo(OutputArray dst, int rtype, double alpha, Stream& stream) const +void GpuMat::convertTo(OutputArray dst, ElemType ddepth, double alpha, Stream& stream) const { - convertTo(dst, rtype, alpha, 0.0, stream); + convertTo(dst, ddepth, alpha, 0.0, stream); } inline -void GpuMat::assignTo(GpuMat& m, int _type) const +void GpuMat::assignTo(GpuMat& m, ElemType _depth) const { - if (_type < 0) + if (_depth == CV_TYPE_AUTO) m = *this; else - convertTo(m, _type); + convertTo(m, _depth); } inline @@ -292,7 +292,7 @@ GpuMat GpuMat::operator ()(Rect roi) const inline bool GpuMat::isContinuous() const { - return (flags & Mat::CONTINUOUS_FLAG) != 0; + return !!(flags & static_cast(Mat::CONTINUOUS_FLAG)); } inline @@ -308,13 +308,13 @@ size_t GpuMat::elemSize1() const } inline -int GpuMat::type() const +ElemType GpuMat::type() const { return CV_MAT_TYPE(flags); } inline -int GpuMat::depth() const +ElemType GpuMat::depth() const { return CV_MAT_DEPTH(flags); } @@ -344,7 +344,7 @@ bool GpuMat::empty() const } static inline -GpuMat createContinuous(int rows, int cols, int type) +GpuMat createContinuous(int rows, int cols, ElemType type) { GpuMat m; createContinuous(rows, cols, type, m); @@ -352,13 +352,13 @@ GpuMat createContinuous(int rows, int cols, int type) } static inline -void createContinuous(Size size, int type, OutputArray arr) +void createContinuous(Size size, ElemType type, OutputArray arr) { createContinuous(size.height, size.width, type, arr); } static inline -GpuMat createContinuous(Size size, int type) +GpuMat createContinuous(Size size, ElemType type) { GpuMat m; createContinuous(size, type, m); @@ -366,7 +366,7 @@ GpuMat createContinuous(Size size, int type) } static inline -void ensureSizeIsEnough(Size size, int type, OutputArray arr) +void ensureSizeIsEnough(Size size, ElemType type, OutputArray arr) { ensureSizeIsEnough(size.height, size.width, type, arr); } @@ -383,7 +383,7 @@ void swap(GpuMat& a, GpuMat& b) inline HostMem::HostMem(AllocType alloc_type_) - : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) + : flags(CV_MAGIC_FLAG_NONE), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) { } @@ -396,16 +396,16 @@ HostMem::HostMem(const HostMem& m) } inline -HostMem::HostMem(int rows_, int cols_, int type_, AllocType alloc_type_) - : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) +HostMem::HostMem(int rows_, int cols_, ElemType type_, AllocType alloc_type_) + : flags(CV_MAGIC_FLAG_NONE), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) { if (rows_ > 0 && cols_ > 0) create(rows_, cols_, type_); } inline -HostMem::HostMem(Size size_, int type_, AllocType alloc_type_) - : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) +HostMem::HostMem(Size size_, ElemType type_, AllocType alloc_type_) + : flags(CV_MAGIC_FLAG_NONE), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) { if (size_.height > 0 && size_.width > 0) create(size_.height, size_.width, type_); @@ -413,7 +413,7 @@ HostMem::HostMem(Size size_, int type_, AllocType alloc_type_) inline HostMem::HostMem(InputArray arr, AllocType alloc_type_) - : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) + : flags(CV_MAGIC_FLAG_NONE), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) { arr.getMat().copyTo(*this); } @@ -459,7 +459,7 @@ HostMem HostMem::clone() const } inline -void HostMem::create(Size size_, int type_) +void HostMem::create(Size size_, ElemType type_) { create(size_.height, size_.width, type_); } @@ -473,7 +473,7 @@ Mat HostMem::createMatHeader() const inline bool HostMem::isContinuous() const { - return (flags & Mat::CONTINUOUS_FLAG) != 0; + return !!(flags & static_cast(Mat::CONTINUOUS_FLAG)); } inline @@ -489,13 +489,13 @@ size_t HostMem::elemSize1() const } inline -int HostMem::type() const +ElemType HostMem::type() const { return CV_MAT_TYPE(flags); } inline -int HostMem::depth() const +ElemType HostMem::depth() const { return CV_MAT_DEPTH(flags); } @@ -619,7 +619,7 @@ namespace cv { inline Mat::Mat(const cuda::GpuMat& m) - : flags(0), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows) + : flags(CV_MAGIC_FLAG_NONE), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows) { m.download(*this); } diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h index cf97d53de877..908058580df0 100644 --- a/modules/core/include/opencv2/core/cvdef.h +++ b/modules/core/include/opencv2/core/cvdef.h @@ -305,9 +305,9 @@ Cv64suf; \****************************************************************************************/ #define CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT) -#define CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1) +#define CV_MAT_CN(flags) (((static_cast(flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1) #define CV_MAT_TYPE_MASK (CV_DEPTH_MAX*CV_CN_MAX - 1) -#define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK) +#define CV_MAT_TYPE(flags) static_cast(static_cast(flags) & CV_MAT_TYPE_MASK) #define CV_MAT_CONT_FLAG_SHIFT 14 #define CV_MAT_CONT_FLAG (1 << CV_MAT_CONT_FLAG_SHIFT) #define CV_IS_MAT_CONT(flags) ((flags) & CV_MAT_CONT_FLAG) @@ -382,68 +382,68 @@ __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) \ +static inline bool operator!(const EnumType val) \ { \ typedef std::underlying_type::type UnderlyingType; \ return !static_cast(val); \ } \ #define __CV_ENUM_FLAGS_LOGICAL_NOT_EQ(Arg1Type, Arg2Type) \ -static inline bool operator!=(const Arg1Type& a, const Arg2Type& b) \ +static inline bool operator!=(const Arg1Type a, const Arg2Type b) \ { \ return static_cast(a) != static_cast(b); \ } \ #define __CV_ENUM_FLAGS_LOGICAL_EQ(Arg1Type, Arg2Type) \ -static inline bool operator==(const Arg1Type& a, const Arg2Type& b) \ +static inline bool operator==(const Arg1Type a, const Arg2Type b) \ { \ return static_cast(a) == static_cast(b); \ } \ #define __CV_ENUM_FLAGS_BITWISE_NOT(EnumType) \ -static inline EnumType operator~(const EnumType& val) \ +static inline EnumType operator~(const EnumType val) \ { \ typedef std::underlying_type::type UnderlyingType; \ return static_cast(~static_cast(val)); \ } \ #define __CV_ENUM_FLAGS_BITWISE_OR(EnumType, Arg1Type, Arg2Type) \ -static inline EnumType operator|(const Arg1Type& a, const Arg2Type& b) \ +static inline EnumType operator|(const Arg1Type a, const Arg2Type b) \ { \ typedef std::underlying_type::type UnderlyingType; \ return static_cast(static_cast(a) | static_cast(b)); \ } \ #define __CV_ENUM_FLAGS_BITWISE_AND(EnumType, Arg1Type, Arg2Type) \ -static inline EnumType operator&(const Arg1Type& a, const Arg2Type& b) \ +static inline EnumType operator&(const Arg1Type a, const Arg2Type b) \ { \ typedef std::underlying_type::type UnderlyingType; \ return static_cast(static_cast(a) & static_cast(b)); \ } \ #define __CV_ENUM_FLAGS_BITWISE_XOR(EnumType, Arg1Type, Arg2Type) \ -static inline EnumType operator^(const Arg1Type& a, const Arg2Type& b) \ +static inline EnumType operator^(const Arg1Type a, const Arg2Type b) \ { \ typedef std::underlying_type::type UnderlyingType; \ return static_cast(static_cast(a) ^ static_cast(b)); \ } \ #define __CV_ENUM_FLAGS_BITWISE_OR_EQ(EnumType, Arg1Type) \ -static inline EnumType& operator|=(EnumType& _this, const Arg1Type& val) \ +static inline EnumType& operator|=(EnumType& _this, const Arg1Type val) \ { \ _this = static_cast(static_cast(_this) | static_cast(val)); \ return _this; \ } \ #define __CV_ENUM_FLAGS_BITWISE_AND_EQ(EnumType, Arg1Type) \ -static inline EnumType& operator&=(EnumType& _this, const Arg1Type& val) \ +static inline EnumType& operator&=(EnumType& _this, const Arg1Type val) \ { \ _this = static_cast(static_cast(_this) & static_cast(val)); \ return _this; \ } \ #define __CV_ENUM_FLAGS_BITWISE_XOR_EQ(EnumType, Arg1Type) \ -static inline EnumType& operator^=(EnumType& _this, const Arg1Type& val) \ +static inline EnumType& operator^=(EnumType& _this, const Arg1Type val) \ { \ _this = static_cast(static_cast(_this) ^ static_cast(val)); \ return _this; \ diff --git a/modules/core/include/opencv2/core/cvstd.inl.hpp b/modules/core/include/opencv2/core/cvstd.inl.hpp index 5df48abb63b1..f293ce2772d6 100644 --- a/modules/core/include/opencv2/core/cvstd.inl.hpp +++ b/modules/core/include/opencv2/core/cvstd.inl.hpp @@ -64,11 +64,11 @@ template class DataType< std::complex<_Tp> > typedef value_type work_type; typedef _Tp channel_type; - enum { generic_type = 0, - depth = DataType::depth, - channels = 2, - fmt = DataType::fmt + ((channels - 1) << 8), - type = CV_MAKETYPE(depth, channels) }; + static const bool generic_type = false; + static const ElemType depth = DataType::depth; + static const int channels = 2; + static const int fmt = DataType::fmt + ((channels - 1) << 8); + static const ElemType type = CV_MAKETYPE(depth, channels); typedef Vec vec_type; }; diff --git a/modules/core/include/opencv2/core/directx.hpp b/modules/core/include/opencv2/core/directx.hpp index 056a85a1bc99..e4b02d9602d0 100644 --- a/modules/core/include/opencv2/core/directx.hpp +++ b/modules/core/include/opencv2/core/directx.hpp @@ -170,12 +170,12 @@ CV_EXPORTS void convertFromDirect3DSurface9(IDirect3DSurface9* pDirect3DSurface9 //! @brief Get OpenCV type from DirectX type //! @param iDXGI_FORMAT - enum DXGI_FORMAT for D3D10/D3D11 //! @return OpenCV type or -1 if there is no equivalent -CV_EXPORTS int getTypeFromDXGI_FORMAT(const int iDXGI_FORMAT); // enum DXGI_FORMAT for D3D10/D3D11 +CV_EXPORTS ElemType getTypeFromDXGI_FORMAT(const int iDXGI_FORMAT); // enum DXGI_FORMAT for D3D10/D3D11 //! @brief Get OpenCV type from DirectX type //! @param iD3DFORMAT - enum D3DTYPE for D3D9 //! @return OpenCV type or -1 if there is no equivalent -CV_EXPORTS int getTypeFromD3DFORMAT(const int iD3DFORMAT); // enum D3DTYPE for D3D9 +CV_EXPORTS ElemType getTypeFromD3DFORMAT(const int iD3DFORMAT); // enum D3DTYPE for D3D9 //! @} diff --git a/modules/core/include/opencv2/core/hal/hal.hpp b/modules/core/include/opencv2/core/hal/hal.hpp index 0d68078d98d6..3b0e75c6d047 100644 --- a/modules/core/include/opencv2/core/hal/hal.hpp +++ b/modules/core/include/opencv2/core/hal/hal.hpp @@ -203,14 +203,14 @@ CV_EXPORTS void addRNGBias64f( double* arr, const double* scaleBiasPairs, int le struct CV_EXPORTS DFT1D { - static Ptr create(int len, int count, int depth, int flags, bool * useBuffer = 0); + static Ptr create(int len, int count, ElemType depth, int flags, bool * useBuffer = 0); virtual void apply(const uchar *src, uchar *dst) = 0; virtual ~DFT1D() {} }; struct CV_EXPORTS DFT2D { - static Ptr create(int width, int height, int depth, + static Ptr create(int width, int height, ElemType depth, int src_channels, int dst_channels, int flags, int nonzero_rows = 0); virtual void apply(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step) = 0; @@ -219,7 +219,7 @@ struct CV_EXPORTS DFT2D struct CV_EXPORTS DCT2D { - static Ptr create(int width, int height, int depth, int flags); + static Ptr create(int width, int height, ElemType depth, int flags); virtual void apply(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step) = 0; virtual ~DCT2D() {} }; diff --git a/modules/core/include/opencv2/core/hal/interface.h b/modules/core/include/opencv2/core/hal/interface.h index 6f0a83d35928..8525d2dfa860 100644 --- a/modules/core/include/opencv2/core/hal/interface.h +++ b/modules/core/include/opencv2/core/hal/interface.h @@ -64,74 +64,167 @@ typedef signed char schar; # define CV_BIG_UINT(n) n##ULL #endif -#define CV_USRTYPE1 (void)"CV_USRTYPE1 support has been dropped in OpenCV 4.0" +#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__))) #define CV_CN_MAX 512 #define CV_CN_SHIFT 3 #define CV_DEPTH_MAX (1 << CV_CN_SHIFT) -#define CV_8U 0 -#define CV_8S 1 -#define CV_16U 2 -#define CV_16S 3 -#define CV_32S 4 -#define CV_32F 5 -#define CV_64F 6 -#define CV_16F 7 - #define CV_MAT_DEPTH_MASK (CV_DEPTH_MAX - 1) -#define CV_MAT_DEPTH(flags) ((flags) & CV_MAT_DEPTH_MASK) - -#define CV_MAKETYPE(depth,cn) (CV_MAT_DEPTH(depth) + (((cn)-1) << CV_CN_SHIFT)) +#define __CV_MAT_DEPTH(flags) (static_cast(flags) & CV_MAT_DEPTH_MASK) +#define CV_MAT_DEPTH(flags) static_cast(__CV_MAT_DEPTH(flags)) +#define __CV_MAKETYPE(depth,cn) (__CV_MAT_DEPTH(depth) | (((cn)-1) << CV_CN_SHIFT)) +#define CV_MAKETYPE(depth,cn) static_cast(__CV_MAKETYPE(depth,cn)) #define CV_MAKE_TYPE CV_MAKETYPE +#if defined(CV_TYPE_SAFE_API) && defined(__cplusplus) +enum MagicFlag { + CV_MAGIC_FLAG_NONE = 0 +}; + +enum ElemType { + CV_8U = 0, + CV_8S = 1, + CV_16U = 2, + CV_16S = 3, + CV_16F = 7, + CV_32S = 4, + CV_32F = 5, + CV_64F = 6, + + CV_8UC1 = __CV_MAKETYPE(CV_8U, 1), + CV_8UC2 = __CV_MAKETYPE(CV_8U, 2), + CV_8UC3 = __CV_MAKETYPE(CV_8U, 3), + CV_8UC4 = __CV_MAKETYPE(CV_8U, 4), + + CV_8SC1 = __CV_MAKETYPE(CV_8S, 1), + CV_8SC2 = __CV_MAKETYPE(CV_8S, 2), + CV_8SC3 = __CV_MAKETYPE(CV_8S, 3), + CV_8SC4 = __CV_MAKETYPE(CV_8S, 4), + + CV_16UC1 = __CV_MAKETYPE(CV_16U, 1), + CV_16UC2 = __CV_MAKETYPE(CV_16U, 2), + CV_16UC3 = __CV_MAKETYPE(CV_16U, 3), + CV_16UC4 = __CV_MAKETYPE(CV_16U, 4), + + CV_16SC1 = __CV_MAKETYPE(CV_16S, 1), + CV_16SC2 = __CV_MAKETYPE(CV_16S, 2), + CV_16SC3 = __CV_MAKETYPE(CV_16S, 3), + CV_16SC4 = __CV_MAKETYPE(CV_16S, 4), + + CV_16FC1 = __CV_MAKETYPE(CV_16F, 1), + CV_16FC2 = __CV_MAKETYPE(CV_16F, 2), + CV_16FC3 = __CV_MAKETYPE(CV_16F, 3), + CV_16FC4 = __CV_MAKETYPE(CV_16F, 4), + + CV_32SC1 = __CV_MAKETYPE(CV_32S, 1), + CV_32SC2 = __CV_MAKETYPE(CV_32S, 2), + CV_32SC3 = __CV_MAKETYPE(CV_32S, 3), + CV_32SC4 = __CV_MAKETYPE(CV_32S, 4), + + CV_32FC1 = __CV_MAKETYPE(CV_32F, 1), + CV_32FC2 = __CV_MAKETYPE(CV_32F, 2), + CV_32FC3 = __CV_MAKETYPE(CV_32F, 3), + CV_32FC4 = __CV_MAKETYPE(CV_32F, 4), + + CV_64FC1 = __CV_MAKETYPE(CV_64F, 1), + CV_64FC2 = __CV_MAKETYPE(CV_64F, 2), + CV_64FC3 = __CV_MAKETYPE(CV_64F, 3), + CV_64FC4 = __CV_MAKETYPE(CV_64F, 4), + + CV_SEQ_ELTYPE_PTR = __CV_MAKETYPE(CV_8U, 8 /*sizeof(void*)*/), +}; +#define CV_TYPE_AUTO static_cast(-1) +#define CV_TYPE_UNDEFINED static_cast(-2) + + +#else // defined(CV_TYPE_SAFE_API) && defined(__cplusplus) + +typedef int MagicFlag; +#define CV_MAGIC_FLAG_NONE 0 + +typedef int ElemType; +#define CV_TYPE_AUTO -1 +#define CV_8U 0 +#define CV_8S 1 +#define CV_16U 2 +#define CV_16S 3 +#define CV_16F 7 +#define CV_32S 4 +#define CV_32F 5 +#define CV_64F 6 + +typedef int ElemType; +#define CV_TYPE_AUTO -1 +#define CV_TYPE_UNDEFINED -2 + +#define CV_SEQ_ELTYPE_PTR CV_MAKE_TYPE(CV_8U, 8 /*sizeof(void*)*/) + #define CV_8UC1 CV_MAKETYPE(CV_8U,1) #define CV_8UC2 CV_MAKETYPE(CV_8U,2) #define CV_8UC3 CV_MAKETYPE(CV_8U,3) #define CV_8UC4 CV_MAKETYPE(CV_8U,4) -#define CV_8UC(n) CV_MAKETYPE(CV_8U,(n)) #define CV_8SC1 CV_MAKETYPE(CV_8S,1) #define CV_8SC2 CV_MAKETYPE(CV_8S,2) #define CV_8SC3 CV_MAKETYPE(CV_8S,3) #define CV_8SC4 CV_MAKETYPE(CV_8S,4) -#define CV_8SC(n) CV_MAKETYPE(CV_8S,(n)) #define CV_16UC1 CV_MAKETYPE(CV_16U,1) #define CV_16UC2 CV_MAKETYPE(CV_16U,2) #define CV_16UC3 CV_MAKETYPE(CV_16U,3) #define CV_16UC4 CV_MAKETYPE(CV_16U,4) -#define CV_16UC(n) CV_MAKETYPE(CV_16U,(n)) #define CV_16SC1 CV_MAKETYPE(CV_16S,1) #define CV_16SC2 CV_MAKETYPE(CV_16S,2) #define CV_16SC3 CV_MAKETYPE(CV_16S,3) #define CV_16SC4 CV_MAKETYPE(CV_16S,4) -#define CV_16SC(n) CV_MAKETYPE(CV_16S,(n)) + +#define CV_16FC1 CV_MAKETYPE(CV_16F,1) +#define CV_16FC2 CV_MAKETYPE(CV_16F,2) +#define CV_16FC3 CV_MAKETYPE(CV_16F,3) +#define CV_16FC4 CV_MAKETYPE(CV_16F,4) #define CV_32SC1 CV_MAKETYPE(CV_32S,1) #define CV_32SC2 CV_MAKETYPE(CV_32S,2) #define CV_32SC3 CV_MAKETYPE(CV_32S,3) #define CV_32SC4 CV_MAKETYPE(CV_32S,4) -#define CV_32SC(n) CV_MAKETYPE(CV_32S,(n)) #define CV_32FC1 CV_MAKETYPE(CV_32F,1) #define CV_32FC2 CV_MAKETYPE(CV_32F,2) #define CV_32FC3 CV_MAKETYPE(CV_32F,3) #define CV_32FC4 CV_MAKETYPE(CV_32F,4) -#define CV_32FC(n) CV_MAKETYPE(CV_32F,(n)) #define CV_64FC1 CV_MAKETYPE(CV_64F,1) #define CV_64FC2 CV_MAKETYPE(CV_64F,2) #define CV_64FC3 CV_MAKETYPE(CV_64F,3) #define CV_64FC4 CV_MAKETYPE(CV_64F,4) -#define CV_64FC(n) CV_MAKETYPE(CV_64F,(n)) -#define CV_16FC1 CV_MAKETYPE(CV_16F,1) -#define CV_16FC2 CV_MAKETYPE(CV_16F,2) -#define CV_16FC3 CV_MAKETYPE(CV_16F,3) -#define CV_16FC4 CV_MAKETYPE(CV_16F,4) +#endif // defined(CV_TYPE_SAFE_API) && defined(__cplusplus) + +#define CV_USRTYPE1 (void)"CV_USRTYPE1 support has been dropped in OpenCV 4.0" + +#define CV_8UC(n) CV_MAKETYPE(CV_8U,(n)) +#define CV_8SC(n) CV_MAKETYPE(CV_8S,(n)) +#define CV_16UC(n) CV_MAKETYPE(CV_16U,(n)) +#define CV_16SC(n) CV_MAKETYPE(CV_16S,(n)) #define CV_16FC(n) CV_MAKETYPE(CV_16F,(n)) +#define CV_32SC(n) CV_MAKETYPE(CV_32S,(n)) +#define CV_32FC(n) CV_MAKETYPE(CV_32F,(n)) +#define CV_64FC(n) CV_MAKETYPE(CV_64F,(n)) + //! @} //! @name Comparison operation diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index 178ecd493852..521f242cde79 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -61,10 +61,29 @@ namespace cv //! @addtogroup core_basic //! @{ -enum AccessFlag { ACCESS_READ=1<<24, ACCESS_WRITE=1<<25, - ACCESS_RW=3<<24, ACCESS_MASK=ACCESS_RW, ACCESS_FAST=1<<26 }; +enum AccessFlag +{ + ACCESS_READ=1<<24, ACCESS_WRITE=1<<25, + ACCESS_RW=3<<24, ACCESS_MASK=ACCESS_RW, ACCESS_FAST=1<<26 +}; CV_ENUM_FLAGS(AccessFlag); -__CV_ENUM_FLAGS_BITWISE_AND(AccessFlag, int, AccessFlag); +__CV_ENUM_FLAGS_BITWISE_AND(AccessFlag, MagicFlag, AccessFlag); +#if defined(CV_TYPE_SAFE_API) +CV_ENUM_FLAGS(MagicFlag); +CV_ENUM_FLAGS(ElemType); +__CV_ENUM_FLAGS_BITWISE_OR(MagicFlag, int, MagicFlag); +__CV_ENUM_FLAGS_BITWISE_OR(MagicFlag, MagicFlag, int); +__CV_ENUM_FLAGS_BITWISE_AND(MagicFlag, int, MagicFlag); +__CV_ENUM_FLAGS_BITWISE_AND(MagicFlag, MagicFlag, int); +__CV_ENUM_FLAGS_BITWISE_OR(MagicFlag, MagicFlag, ElemType); +__CV_ENUM_FLAGS_BITWISE_OR_EQ(MagicFlag, ElemType); +__CV_ENUM_FLAGS_BITWISE_AND(ElemType, MagicFlag, ElemType); +__CV_ENUM_FLAGS_BITWISE_AND_EQ(MagicFlag, ElemType); + + +__CV_ENUM_FLAGS_BITWISE_OR(MagicFlag, ElemType, AccessFlag); +__CV_ENUM_FLAGS_BITWISE_OR(MagicFlag, MagicFlag, AccessFlag); +#endif CV__DEBUG_NS_BEGIN @@ -158,7 +177,8 @@ Custom type is wrapped as Mat-compatible `CV_8UC` values (N = sizeof(T), N <= class CV_EXPORTS _InputArray { public: - enum KindFlag { + enum KindFlag + { KIND_SHIFT = 16, FIXED_TYPE = 0x8000 << KIND_SHIFT, FIXED_SIZE = 0x4000 << KIND_SHIFT, @@ -183,7 +203,7 @@ class CV_EXPORTS _InputArray }; _InputArray(); - _InputArray(int _flags, void* _obj); + _InputArray(MagicFlag _flags, void* _obj); _InputArray(const Mat& m); _InputArray(const MatExpr& expr); _InputArray(const std::vector& vec); @@ -219,7 +239,7 @@ class CV_EXPORTS _InputArray cuda::GpuMat getGpuMat() const; ogl::Buffer getOGlBuffer() const; - int getFlags() const; + MagicFlag getFlags() const; void* getObj() const; Size getSz() const; @@ -231,8 +251,8 @@ class CV_EXPORTS _InputArray int sizend(int* sz, int i=-1) const; bool sameSize(const _InputArray& arr) const; size_t total(int i=-1) const; - int type(int i=-1) const; - int depth(int i=-1) const; + ElemType type(int i = -1) const; + ElemType depth(int i = -1) const; int channels(int i=-1) const; bool isContinuous(int i=-1) const; bool isSubmatrix(int i=-1) const; @@ -252,15 +272,22 @@ class CV_EXPORTS _InputArray ~_InputArray(); protected: - int flags; + MagicFlag flags; void* obj; Size sz; - void init(int _flags, const void* _obj); - void init(int _flags, const void* _obj, Size _sz); + void init(MagicFlag _flags, const void* _obj); + void init(MagicFlag _flags, const void* _obj, Size _sz); }; CV_ENUM_FLAGS(_InputArray::KindFlag); -__CV_ENUM_FLAGS_BITWISE_AND(_InputArray::KindFlag, int, _InputArray::KindFlag); +__CV_ENUM_FLAGS_BITWISE_AND(_InputArray::KindFlag, MagicFlag, _InputArray::KindFlag); +__CV_ENUM_FLAGS_BITWISE_OR_EQ(MagicFlag, _InputArray::KindFlag); +#if defined(CV_TYPE_SAFE_API) +__CV_ENUM_FLAGS_BITWISE_OR(MagicFlag, MagicFlag, _InputArray::KindFlag); +__CV_ENUM_FLAGS_BITWISE_OR(MagicFlag, _InputArray::KindFlag, ElemType); +__CV_ENUM_FLAGS_BITWISE_OR(MagicFlag, _InputArray::KindFlag, AccessFlag); +#endif + /** @brief This type is very similar to InputArray except that it is used for input/output and output function parameters. @@ -307,7 +334,7 @@ class CV_EXPORTS _OutputArray : public _InputArray }; _OutputArray(); - _OutputArray(int _flags, void* _obj); + _OutputArray(MagicFlag _flags, void* _obj); _OutputArray(Mat& m); _OutputArray(std::vector& vec); _OutputArray(cuda::GpuMat& d_mat); @@ -359,10 +386,10 @@ class CV_EXPORTS _OutputArray : public _InputArray std::vector& getGpuMatVecRef() const; ogl::Buffer& getOGlBufferRef() const; cuda::HostMem& getHostMemRef() const; - void create(Size sz, int type, int i=-1, bool allowTransposed=false, _OutputArray::DepthMask fixedDepthMask=static_cast<_OutputArray::DepthMask>(0)) const; - void create(int rows, int cols, int type, int i=-1, bool allowTransposed=false, _OutputArray::DepthMask fixedDepthMask=static_cast<_OutputArray::DepthMask>(0)) const; - void create(int dims, const int* size, int type, int i=-1, bool allowTransposed=false, _OutputArray::DepthMask fixedDepthMask=static_cast<_OutputArray::DepthMask>(0)) const; - void createSameSize(const _InputArray& arr, int mtype) const; + void create(Size sz, ElemType type, int i = -1, bool allowTransposed = false, _OutputArray::DepthMask fixedDepthMask = static_cast<_OutputArray::DepthMask>(0)) const; + void create(int rows, int cols, ElemType type, int i = -1, bool allowTransposed = false, _OutputArray::DepthMask fixedDepthMask = static_cast<_OutputArray::DepthMask>(0)) const; + void create(int dims, const int* size, ElemType type, int i = -1, bool allowTransposed = false, _OutputArray::DepthMask fixedDepthMask = static_cast<_OutputArray::DepthMask>(0)) const; + void createSameSize(const _InputArray& arr, ElemType mtype) const; void release() const; void clear() const; void setTo(const _InputArray& value, const _InputArray & mask = _InputArray()) const; @@ -379,7 +406,7 @@ class CV_EXPORTS _InputOutputArray : public _OutputArray { public: _InputOutputArray(); - _InputOutputArray(int _flags, void* _obj); + _InputOutputArray(MagicFlag _flags, void* _obj); _InputOutputArray(Mat& m); _InputOutputArray(std::vector& vec); _InputOutputArray(cuda::GpuMat& d_mat); @@ -466,10 +493,10 @@ class CV_EXPORTS MatAllocator virtual ~MatAllocator() {} // let's comment it off for now to detect and fix all the uses of allocator - //virtual void allocate(int dims, const int* sizes, int type, int*& refcount, + //virtual void allocate(int dims, const int* sizes, ElemType type, int*& refcount, // uchar*& datastart, uchar*& data, size_t* step) = 0; //virtual void deallocate(int* refcount, uchar* datastart, uchar* data) = 0; - virtual UMatData* allocate(int dims, const int* sizes, int type, + virtual UMatData* allocate(int dims, const int* sizes, ElemType type, void* data, size_t* step, AccessFlag flags, UMatUsageFlags usageFlags) const = 0; virtual bool allocate(UMatData* data, AccessFlag accessflags, UMatUsageFlags usageFlags) const = 0; virtual void deallocate(UMatData* data) const = 0; @@ -526,7 +553,8 @@ template class MatCommaInitializer_ // it should be explicitly initialized using init(). struct CV_EXPORTS UMatData { - enum MemoryFlag { COPY_ON_MAP=1, HOST_COPY_OBSOLETE=2, + enum MemoryFlag + { COPY_ON_MAP=1, HOST_COPY_OBSOLETE=2, DEVICE_COPY_OBSOLETE=4, TEMP_UMAT=8, TEMP_COPIED_UMAT=24, USER_ALLOCATED=32, DEVICE_MEM_MAPPED=64, ASYNC_CLEANUP=128 @@ -807,7 +835,7 @@ class CV_EXPORTS Mat @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. */ - Mat(int rows, int cols, int type); + Mat(int rows, int cols, ElemType type); /** @overload @param size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the @@ -815,7 +843,7 @@ class CV_EXPORTS Mat @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. */ - Mat(Size size, int type); + Mat(Size size, ElemType type); /** @overload @param rows Number of rows in a 2D array. @@ -826,7 +854,7 @@ class CV_EXPORTS Mat the particular value after the construction, use the assignment operator Mat::operator=(const Scalar& value) . */ - Mat(int rows, int cols, int type, const Scalar& s); + Mat(int rows, int cols, ElemType type, const Scalar& s); /** @overload @param size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the @@ -837,7 +865,7 @@ class CV_EXPORTS Mat the particular value after the construction, use the assignment operator Mat::operator=(const Scalar& value) . */ - Mat(Size size, int type, const Scalar& s); + Mat(Size size, ElemType type, const Scalar& s); /** @overload @param ndims Array dimensionality. @@ -845,14 +873,14 @@ class CV_EXPORTS Mat @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. */ - Mat(int ndims, const int* sizes, int type); + Mat(int ndims, const int* sizes, ElemType type); /** @overload @param sizes Array of integers specifying an n-dimensional array shape. @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. */ - Mat(const std::vector& sizes, int type); + Mat(const std::vector& sizes, ElemType type); /** @overload @param ndims Array dimensionality. @@ -863,7 +891,7 @@ class CV_EXPORTS Mat the particular value after the construction, use the assignment operator Mat::operator=(const Scalar& value) . */ - Mat(int ndims, const int* sizes, int type, const Scalar& s); + Mat(int ndims, const int* sizes, ElemType type, const Scalar& s); /** @overload @param sizes Array of integers specifying an n-dimensional array shape. @@ -873,7 +901,7 @@ class CV_EXPORTS Mat the particular value after the construction, use the assignment operator Mat::operator=(const Scalar& value) . */ - Mat(const std::vector& sizes, int type, const Scalar& s); + Mat(const std::vector& sizes, ElemType type, const Scalar& s); /** @overload @@ -899,7 +927,7 @@ class CV_EXPORTS Mat the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed and the actual step is calculated as cols*elemSize(). See Mat::elemSize. */ - Mat(int rows, int cols, int type, void* data, size_t step=AUTO_STEP); + Mat(int rows, int cols, ElemType type, void* data, size_t step = AUTO_STEP); /** @overload @param size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the @@ -915,7 +943,7 @@ class CV_EXPORTS Mat the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed and the actual step is calculated as cols*elemSize(). See Mat::elemSize. */ - Mat(Size size, int type, void* data, size_t step=AUTO_STEP); + Mat(Size size, ElemType type, void* data, size_t step = AUTO_STEP); /** @overload @param ndims Array dimensionality. @@ -930,7 +958,7 @@ class CV_EXPORTS Mat @param steps Array of ndims-1 steps in case of a multi-dimensional array (the last step is always set to the element size). If not specified, the matrix is assumed to be continuous. */ - Mat(int ndims, const int* sizes, int type, void* data, const size_t* steps=0); + Mat(int ndims, const int* sizes, ElemType type, void* data, const size_t* steps = 0); /** @overload @param sizes Array of integers specifying an n-dimensional array shape. @@ -944,7 +972,7 @@ class CV_EXPORTS Mat @param steps Array of ndims-1 steps in case of a multi-dimensional array (the last step is always set to the element size). If not specified, the matrix is assumed to be continuous. */ - Mat(const std::vector& sizes, int type, void* data, const size_t* steps=0); + Mat(const std::vector& sizes, ElemType type, void* data, const size_t* steps = 0); /** @overload @param m Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied @@ -1222,20 +1250,19 @@ class CV_EXPORTS Mat \f[m(x,y) = saturate \_ cast( \alpha (*this)(x,y) + \beta )\f] @param m output matrix; if it does not have a proper size or type before the operation, it is reallocated. - @param rtype desired output matrix type or, rather, the depth since the number of channels are the - same as the input has; if rtype is negative, the output matrix will have the same type as the input. + @param ddepth desired output matrix depth. @param alpha optional scale factor. @param beta optional delta added to the scaled values. */ - void convertTo( OutputArray m, int rtype, double alpha=1, double beta=0 ) const; + void convertTo(OutputArray m, ElemType ddepth, double alpha = 1, double beta = 0) const; /** @brief Provides a functional form of convertTo. This is an internally used method called by the @ref MatrixExpressions engine. @param m Destination array. - @param type Desired destination array depth (or -1 if it should be the same as the source type). + @param depth Desired destination array depth (or CV_TYPE_AUTO if it should be the same as the source type). */ - void assignTo( Mat& m, int type=-1 ) const; + void assignTo(Mat& m, ElemType depth = CV_TYPE_AUTO) const; /** @brief Sets all or some of the array elements to the specified value. @param s Assigned scalar converted to the actual array type. @@ -1351,20 +1378,20 @@ class CV_EXPORTS Mat @param cols Number of columns. @param type Created matrix type. */ - static MatExpr zeros(int rows, int cols, int type); + static MatExpr zeros(int rows, int cols, ElemType type); /** @overload @param size Alternative to the matrix size specification Size(cols, rows) . @param type Created matrix type. */ - static MatExpr zeros(Size size, int type); + static MatExpr zeros(Size size, ElemType type); /** @overload @param ndims Array dimensionality. @param sz Array of integers specifying the array shape. @param type Created matrix type. */ - static MatExpr zeros(int ndims, const int* sz, int type); + static MatExpr zeros(int ndims, const int* sz, ElemType type); /** @brief Returns an array of all 1's of the specified size and type. @@ -1382,20 +1409,20 @@ class CV_EXPORTS Mat @param cols Number of columns. @param type Created matrix type. */ - static MatExpr ones(int rows, int cols, int type); + static MatExpr ones(int rows, int cols, ElemType type); /** @overload @param size Alternative to the matrix size specification Size(cols, rows) . @param type Created matrix type. */ - static MatExpr ones(Size size, int type); + static MatExpr ones(Size size, ElemType type); /** @overload @param ndims Array dimensionality. @param sz Array of integers specifying the array shape. @param type Created matrix type. */ - static MatExpr ones(int ndims, const int* sz, int type); + static MatExpr ones(int ndims, const int* sz, ElemType type); /** @brief Returns an identity matrix of the specified size and type. @@ -1411,13 +1438,13 @@ class CV_EXPORTS Mat @param cols Number of columns. @param type Created matrix type. */ - static MatExpr eye(int rows, int cols, int type); + static MatExpr eye(int rows, int cols, ElemType type); /** @overload @param size Alternative matrix size specification as Size(cols, rows) . @param type Created matrix type. */ - static MatExpr eye(Size size, int type); + static MatExpr eye(Size size, ElemType type); /** @brief Allocates new array data if needed. @@ -1452,26 +1479,26 @@ class CV_EXPORTS Mat @param cols New number of columns. @param type New matrix type. */ - void create(int rows, int cols, int type); + void create(int rows, int cols, ElemType type); /** @overload @param size Alternative new matrix size specification: Size(cols, rows) @param type New matrix type. */ - void create(Size size, int type); + void create(Size size, ElemType type); /** @overload @param ndims New array dimensionality. @param sizes Array of integers specifying a new array shape. @param type New matrix type. */ - void create(int ndims, const int* sizes, int type); + void create(int ndims, const int* sizes, ElemType type); /** @overload @param sizes Array of integers specifying a new array shape. @param type New matrix type. */ - void create(const std::vector& sizes, int type); + void create(const std::vector& sizes, ElemType type); /** @brief Increments the reference counter. @@ -1752,7 +1779,7 @@ class CV_EXPORTS Mat The method returns a matrix element type. This is an identifier compatible with the CvMat type system, like CV_16SC3 or 16-bit signed 3-channel array, and so on. */ - int type() const; + ElemType type() const; /** @brief Returns the depth of a matrix element. @@ -1767,7 +1794,7 @@ class CV_EXPORTS Mat - CV_32F - 32-bit floating-point numbers ( -FLT_MAX..FLT_MAX, INF, NAN ) - CV_64F - 64-bit floating-point numbers ( -DBL_MAX..DBL_MAX, INF, NAN ) */ - int depth() const; + ElemType depth() const; /** @brief Returns the number of matrix channels. @@ -1811,7 +1838,7 @@ class CV_EXPORTS Mat * if the number of planes is not one, then the number of rows * within every plane has to be 1; if the number of rows within * every plane is not 1, then the number of planes has to be 1. - * @param depth The depth the matrix should have. Set it to -1 when any depth is fine. + * @param depth The depth the matrix should have. Set it to CV_TYPE_AUTO when any depth is fine. * @param requireContinuous Set it to true to require the matrix to be continuous * @return -1 if the requirement is not satisfied. * Otherwise, it returns the number of elements in the matrix. Note @@ -1823,7 +1850,7 @@ class CV_EXPORTS Mat * The following code demonstrates its usage for a 3-d matrix: * @snippet snippets/core_mat_checkVector.cpp example-3d */ - int checkVector(int elemChannels, int depth=-1, bool requireContinuous=true) const; + int checkVector(int elemChannels, ElemType depth = CV_TYPE_AUTO, bool requireContinuous = true) const; /** @brief Returns a pointer to the specified matrix row. @@ -2079,8 +2106,16 @@ class CV_EXPORTS Mat Mat(Mat&& m); Mat& operator = (Mat&& m); - enum { MAGIC_VAL = 0x42FF0000, AUTO_STEP = 0, CONTINUOUS_FLAG = CV_MAT_CONT_FLAG, SUBMATRIX_FLAG = CV_SUBMAT_FLAG }; - enum { MAGIC_MASK = 0xFFFF0000, TYPE_MASK = 0x00000FFF, DEPTH_MASK = 7 }; + enum + { + MAGIC_VAL = 0x42FF0000, + AUTO_STEP = 0, + CONTINUOUS_FLAG = CV_MAT_CONT_FLAG, + SUBMATRIX_FLAG = CV_SUBMAT_FLAG, + MAGIC_MASK = 0xFFFF0000, + TYPE_MASK = 0x00000FFF, + DEPTH_MASK = 7, + }; /*! includes several bit-fields: - the magic signature @@ -2088,7 +2123,7 @@ class CV_EXPORTS Mat - depth - number of channels */ - int flags; + MagicFlag flags; //! the matrix dimensionality, >= 2 int dims; //! the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions @@ -2275,8 +2310,8 @@ template class Mat_ : public Mat //! overridden forms of Mat::elemSize() etc. size_t elemSize() const; size_t elemSize1() const; - int type() const; - int depth() const; + ElemType type() const; + ElemType depth() const; int channels() const; size_t step1(int i=0) const; //! returns step()/sizeof(_Tp) @@ -2387,15 +2422,15 @@ class CV_EXPORTS UMat UMat(UMatUsageFlags usageFlags = USAGE_DEFAULT); //! constructs 2D matrix of the specified size and type // (_type is CV_8UC1, CV_64FC3, CV_32SC(12) etc.) - UMat(int rows, int cols, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); - UMat(Size size, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + UMat(int rows, int cols, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + UMat(Size size, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); //! constucts 2D matrix and fills it with the specified value _s. - UMat(int rows, int cols, int type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); - UMat(Size size, int type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); + UMat(int rows, int cols, ElemType type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); + UMat(Size size, ElemType type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); //! constructs n-dimensional matrix - UMat(int ndims, const int* sizes, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); - UMat(int ndims, const int* sizes, int type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); + UMat(int ndims, const int* sizes, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + UMat(int ndims, const int* sizes, ElemType type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); //! copy constructor UMat(const UMat& m); @@ -2452,9 +2487,9 @@ class CV_EXPORTS UMat //! copies those matrix elements to "m" that are marked with non-zero mask elements. void copyTo( OutputArray m, InputArray mask ) const; //! converts matrix to another datatype with optional scaling. See cvConvertScale. - void convertTo( OutputArray m, int rtype, double alpha=1, double beta=0 ) const; + void convertTo(OutputArray m, ElemType ddepth, double alpha = 1, double beta = 0) const; - void assignTo( UMat& m, int type=-1 ) const; + void assignTo(UMat& m, ElemType depth = CV_TYPE_AUTO) const; //! sets every matrix element to s UMat& operator = (const Scalar& s); @@ -2476,21 +2511,21 @@ class CV_EXPORTS UMat double dot(InputArray m) const; //! Matlab-style matrix initialization - static UMat zeros(int rows, int cols, int type); - static UMat zeros(Size size, int type); - static UMat zeros(int ndims, const int* sz, int type); - static UMat ones(int rows, int cols, int type); - static UMat ones(Size size, int type); - static UMat ones(int ndims, const int* sz, int type); - static UMat eye(int rows, int cols, int type); - static UMat eye(Size size, int type); + static UMat zeros(int rows, int cols, ElemType type); + static UMat zeros(Size size, ElemType type); + static UMat zeros(int ndims, const int* sz, ElemType type); + static UMat ones(int rows, int cols, ElemType type); + static UMat ones(Size size, ElemType type); + static UMat ones(int ndims, const int* sz, ElemType type); + static UMat eye(int rows, int cols, ElemType type); + static UMat eye(Size size, ElemType type); //! allocates new matrix data unless the matrix already has specified size and type. // previous data is unreferenced if needed. - void create(int rows, int cols, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); - void create(Size size, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); - void create(int ndims, const int* sizes, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); - void create(const std::vector& sizes, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + void create(int rows, int cols, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + void create(Size size, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + void create(int ndims, const int* sizes, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + void create(const std::vector& sizes, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); //! increases the reference counter; use with care to avoid memleaks void addref(); @@ -2528,9 +2563,9 @@ class CV_EXPORTS UMat //! returns the size of element channel in bytes. size_t elemSize1() const; //! returns element type, similar to CV_MAT_TYPE(cvmat->type) - int type() const; + ElemType type() const; //! returns element type, similar to CV_MAT_DEPTH(cvmat->type) - int depth() const; + ElemType depth() const; //! returns element type, similar to CV_MAT_CN(cvmat->type) int channels() const; //! returns step/elemSize1() @@ -2541,7 +2576,7 @@ class CV_EXPORTS UMat size_t total() const; //! returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel (1 x N) or (N x 1); negative number otherwise - int checkVector(int elemChannels, int depth=-1, bool requireContinuous=true) const; + int checkVector(int elemChannels, ElemType depth = CV_TYPE_AUTO, bool requireContinuous = true) const; UMat(UMat&& m); UMat& operator = (UMat&& m); @@ -2553,8 +2588,16 @@ class CV_EXPORTS UMat void* handle(AccessFlag accessFlags) const; void ndoffset(size_t* ofs) const; - enum { MAGIC_VAL = 0x42FF0000, AUTO_STEP = 0, CONTINUOUS_FLAG = CV_MAT_CONT_FLAG, SUBMATRIX_FLAG = CV_SUBMAT_FLAG }; - enum { MAGIC_MASK = 0xFFFF0000, TYPE_MASK = 0x00000FFF, DEPTH_MASK = 7 }; + enum + { + MAGIC_VAL = 0x42FF0000, + AUTO_STEP = 0, + CONTINUOUS_FLAG = CV_MAT_CONT_FLAG, + SUBMATRIX_FLAG = CV_SUBMAT_FLAG, + MAGIC_MASK = 0xFFFF0000, + TYPE_MASK = 0x00000FFF, + DEPTH_MASK = 7, + }; /*! includes several bit-fields: - the magic signature @@ -2562,7 +2605,7 @@ class CV_EXPORTS UMat - depth - number of channels */ - int flags; + MagicFlag flags; //! the matrix dimensionality, >= 2 int dims; //! the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions @@ -2590,6 +2633,7 @@ class CV_EXPORTS UMat }; + /////////////////////////// multi-dimensional sparse matrix ////////////////////////// /** @brief The class SparseMat represents multi-dimensional sparse numerical arrays. @@ -2677,12 +2721,18 @@ class CV_EXPORTS SparseMat typedef SparseMatIterator iterator; typedef SparseMatConstIterator const_iterator; - enum { MAGIC_VAL=0x42FD0000, MAX_DIM=32, HASH_SCALE=0x5bd1e995, HASH_BIT=0x80000000 }; + enum + { + MAGIC_VAL = 0x42FD0000, + MAX_DIM = 32, + HASH_SCALE = 0x5bd1e995, + HASH_BIT = 0x80000000, + }; //! the sparse matrix header struct CV_EXPORTS Hdr { - Hdr(int _dims, const int* _sizes, int _type); + Hdr(int _dims, const int* _sizes, ElemType _type); void clear(); int refcount; int dims; @@ -2715,7 +2765,7 @@ class CV_EXPORTS SparseMat @param _sizes Sparce matrix size on all dementions. @param _type Sparse matrix data type. */ - SparseMat(int dims, const int* _sizes, int _type); + SparseMat(int dims, const int* _sizes, ElemType _type); /** @overload @param m Source matrix for copy constructor. If m is dense matrix (ocvMat) then it will be converted @@ -2745,21 +2795,19 @@ class CV_EXPORTS SparseMat //! converts sparse matrix to dense matrix. void copyTo( Mat& m ) const; //! multiplies all the matrix elements by the specified scale factor alpha and converts the results to the specified data type - void convertTo( SparseMat& m, int rtype, double alpha=1 ) const; + void convertTo(SparseMat& m, ElemType ddepth, double alpha = 1) const; //! converts sparse matrix to dense n-dim matrix with optional type conversion and scaling. /*! @param [out] m - output matrix; if it does not have a proper size or type before the operation, it is reallocated - @param [in] rtype - desired output matrix type or, rather, the depth since the number of channels - are the same as the input has; if rtype is negative, the output matrix will have the - same type as the input. + @param [in] ddepth - desired output matrix depth. @param [in] alpha - optional scale factor @param [in] beta - optional delta added to the scaled values */ - void convertTo( Mat& m, int rtype, double alpha=1, double beta=0 ) const; + void convertTo(Mat& m, ElemType ddepth, double alpha = 1, double beta = 0) const; // not used now - void assignTo( SparseMat& m, int type=-1 ) const; + void assignTo(SparseMat& m, ElemType depth = CV_TYPE_AUTO) const; //! reallocates sparse matrix. /*! @@ -2767,7 +2815,7 @@ class CV_EXPORTS SparseMat it is simply cleared with clear(), otherwise, the old matrix is released (using release()) and the new one is allocated. */ - void create(int dims, const int* _sizes, int _type); + void create(int dims, const int* _sizes, ElemType _type); //! sets all the sparse matrix elements to 0, which means clearing the hash table. void clear(); //! manually increments the reference counter to the header. @@ -2783,9 +2831,9 @@ class CV_EXPORTS SparseMat size_t elemSize1() const; //! returns type of sparse matrix elements - int type() const; + ElemType type() const; //! returns the depth of sparse matrix elements - int depth() const; + ElemType depth() const; //! returns the number of channels int channels() const; @@ -2930,12 +2978,13 @@ class CV_EXPORTS SparseMat void removeNode(size_t hidx, size_t nidx, size_t previdx); void resizeHashTab(size_t newsize); - int flags; + MagicFlag flags; Hdr* hdr; }; + ///////////////////////////////// SparseMat_<_Tp> //////////////////////////////////// /** @brief Template sparse n-dimensional array class derived from SparseMat @@ -2982,9 +3031,9 @@ template class SparseMat_ : public SparseMat //operator CvSparseMat*() const; //! returns type of the matrix elements - int type() const; + ElemType type() const; //! returns depth of the matrix elements - int depth() const; + ElemType depth() const; //! returns the number of channels in each matrix element int channels() const; @@ -3442,7 +3491,7 @@ class CV_EXPORTS MatOp virtual ~MatOp(); virtual bool elementWise(const MatExpr& expr) const; - virtual void assign(const MatExpr& expr, Mat& m, int type=-1) const = 0; + virtual void assign(const MatExpr& expr, Mat& m, ElemType depth = CV_TYPE_AUTO) const = 0; virtual void roi(const MatExpr& expr, const Range& rowRange, const Range& colRange, MatExpr& res) const; virtual void diag(const MatExpr& expr, int d, MatExpr& res) const; @@ -3473,7 +3522,7 @@ class CV_EXPORTS MatOp virtual void invert(const MatExpr& expr, int method, MatExpr& res) const; virtual Size size(const MatExpr& expr) const; - virtual int type(const MatExpr& expr) const; + virtual ElemType type(const MatExpr& expr) const; }; /** @brief Matrix expression representation @@ -3535,7 +3584,7 @@ class CV_EXPORTS MatExpr template operator Mat_<_Tp>() const; Size size() const; - int type() const; + ElemType type() const; MatExpr row(int y) const; MatExpr col(int x) const; diff --git a/modules/core/include/opencv2/core/mat.inl.hpp b/modules/core/include/opencv2/core/mat.inl.hpp index 0ef6405bb9e6..bb800ddce4b5 100644 --- a/modules/core/include/opencv2/core/mat.inl.hpp +++ b/modules/core/include/opencv2/core/mat.inl.hpp @@ -64,91 +64,91 @@ CV__DEBUG_NS_BEGIN ////////////////////////// Custom (raw) type wrapper ////////////////////////// template static inline -int rawType() +ElemType rawType() { CV_StaticAssert(sizeof(_Tp) <= CV_CN_MAX, "sizeof(_Tp) is too large"); const int elemSize = sizeof(_Tp); - return (int)CV_MAKETYPE(CV_8U, elemSize); + return CV_MAKETYPE(CV_8U, elemSize); } //////////////////////// Input/Output Arrays //////////////////////// -inline void _InputArray::init(int _flags, const void* _obj) +inline void _InputArray::init(MagicFlag _flags, const void* _obj) { flags = _flags; obj = (void*)_obj; } -inline void _InputArray::init(int _flags, const void* _obj, Size _sz) +inline void _InputArray::init(MagicFlag _flags, const void* _obj, Size _sz) { flags = _flags; obj = (void*)_obj; sz = _sz; } inline void* _InputArray::getObj() const { return obj; } -inline int _InputArray::getFlags() const { return flags; } +inline MagicFlag _InputArray::getFlags() const { return flags; } inline Size _InputArray::getSz() const { return sz; } -inline _InputArray::_InputArray() { init(0 + NONE, 0); } -inline _InputArray::_InputArray(int _flags, void* _obj) { init(_flags, _obj); } -inline _InputArray::_InputArray(const Mat& m) { init(MAT+ACCESS_READ, &m); } -inline _InputArray::_InputArray(const std::vector& vec) { init(STD_VECTOR_MAT+ACCESS_READ, &vec); } -inline _InputArray::_InputArray(const UMat& m) { init(UMAT+ACCESS_READ, &m); } -inline _InputArray::_InputArray(const std::vector& vec) { init(STD_VECTOR_UMAT+ACCESS_READ, &vec); } +inline _InputArray::_InputArray() { init(static_cast(NONE), 0); } +inline _InputArray::_InputArray(MagicFlag _flags, void* _obj) { init(_flags, _obj); } +inline _InputArray::_InputArray(const Mat& m) { init(MAT | ACCESS_READ, &m); } +inline _InputArray::_InputArray(const std::vector& vec) { init(STD_VECTOR_MAT | ACCESS_READ, &vec); } +inline _InputArray::_InputArray(const UMat& m) { init(UMAT | ACCESS_READ, &m); } +inline _InputArray::_InputArray(const std::vector& vec) { init(STD_VECTOR_UMAT | ACCESS_READ, &vec); } template inline _InputArray::_InputArray(const std::vector<_Tp>& vec) -{ init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_READ, &vec); } +{ init(FIXED_TYPE | STD_VECTOR | static_cast(traits::Type<_Tp>::value) | ACCESS_READ, &vec); } template inline _InputArray::_InputArray(const std::array<_Tp, _Nm>& arr) -{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_READ, arr.data(), Size(1, _Nm)); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_ARRAY | static_cast(traits::Type<_Tp>::value) | ACCESS_READ, arr.data(), Size(1, _Nm)); } template inline _InputArray::_InputArray(const std::array& arr) -{ init(STD_ARRAY_MAT + ACCESS_READ, arr.data(), Size(1, _Nm)); } +{ init(STD_ARRAY_MAT | ACCESS_READ, arr.data(), Size(1, _Nm)); } inline _InputArray::_InputArray(const std::vector& vec) -{ init(FIXED_TYPE + STD_BOOL_VECTOR + traits::Type::value + ACCESS_READ, &vec); } +{ init(FIXED_TYPE | STD_BOOL_VECTOR | traits::Type::value | ACCESS_READ, &vec); } template inline _InputArray::_InputArray(const std::vector >& vec) -{ init(FIXED_TYPE + STD_VECTOR_VECTOR + traits::Type<_Tp>::value + ACCESS_READ, &vec); } +{ init(FIXED_TYPE | STD_VECTOR_VECTOR | static_cast(traits::Type<_Tp>::value) | ACCESS_READ, &vec); } template inline _InputArray::_InputArray(const std::vector >& vec) -{ init(FIXED_TYPE + STD_VECTOR_MAT + traits::Type<_Tp>::value + ACCESS_READ, &vec); } +{ init(FIXED_TYPE | STD_VECTOR_MAT | static_cast(traits::Type<_Tp>::value) | ACCESS_READ, &vec); } template inline _InputArray::_InputArray(const Matx<_Tp, m, n>& mtx) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_READ, &mtx, Size(n, m)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | static_cast(traits::Type<_Tp>::value) | ACCESS_READ, &mtx, Size(n, m)); } template inline _InputArray::_InputArray(const _Tp* vec, int n) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_READ, vec, Size(n, 1)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | static_cast(traits::Type<_Tp>::value) | ACCESS_READ, vec, Size(n, 1)); } template inline _InputArray::_InputArray(const Mat_<_Tp>& m) -{ init(FIXED_TYPE + MAT + traits::Type<_Tp>::value + ACCESS_READ, &m); } +{ init(FIXED_TYPE | MAT | static_cast(traits::Type<_Tp>::value) | ACCESS_READ, &m); } inline _InputArray::_InputArray(const double& val) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + CV_64F + ACCESS_READ, &val, Size(1,1)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | CV_64FC1 | ACCESS_READ, &val, Size(1,1)); } inline _InputArray::_InputArray(const MatExpr& expr) -{ init(FIXED_TYPE + FIXED_SIZE + EXPR + ACCESS_READ, &expr); } +{ init(FIXED_TYPE | FIXED_SIZE | EXPR | ACCESS_READ, &expr); } inline _InputArray::_InputArray(const cuda::GpuMat& d_mat) -{ init(CUDA_GPU_MAT + ACCESS_READ, &d_mat); } +{ init(CUDA_GPU_MAT | ACCESS_READ, &d_mat); } inline _InputArray::_InputArray(const std::vector& d_mat) -{ init(STD_VECTOR_CUDA_GPU_MAT + ACCESS_READ, &d_mat);} +{ init(STD_VECTOR_CUDA_GPU_MAT | ACCESS_READ, &d_mat);} inline _InputArray::_InputArray(const ogl::Buffer& buf) -{ init(OPENGL_BUFFER + ACCESS_READ, &buf); } +{ init(OPENGL_BUFFER | ACCESS_READ, &buf); } inline _InputArray::_InputArray(const cuda::HostMem& cuda_mem) -{ init(CUDA_HOST_MEM + ACCESS_READ, &cuda_mem); } +{ init(CUDA_HOST_MEM | ACCESS_READ, &cuda_mem); } template inline _InputArray _InputArray::rawIn(const std::vector<_Tp>& vec) { _InputArray v; - v.flags = _InputArray::FIXED_TYPE + _InputArray::STD_VECTOR + rawType<_Tp>() + ACCESS_READ; + v.flags = _InputArray::FIXED_TYPE | _InputArray::STD_VECTOR | rawType<_Tp>() | ACCESS_READ; v.obj = (void*)&vec; return v; } @@ -157,7 +157,7 @@ template inline _InputArray _InputArray::rawIn(const std::array<_Tp, _Nm>& arr) { _InputArray v; - v.flags = FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_READ; + v.flags = FIXED_TYPE | FIXED_SIZE | STD_ARRAY | static_cast(traits::Type<_Tp>::value) | ACCESS_READ; v.obj = (void*)arr.data(); v.sz = Size(1, _Nm); return v; @@ -185,116 +185,116 @@ inline bool _InputArray::isGpuMatVector() const { return kind() == _InputArray:: //////////////////////////////////////////////////////////////////////////////////////// -inline _OutputArray::_OutputArray() { init(NONE + ACCESS_WRITE, 0); } -inline _OutputArray::_OutputArray(int _flags, void* _obj) { init(_flags + ACCESS_WRITE, _obj); } -inline _OutputArray::_OutputArray(Mat& m) { init(MAT+ACCESS_WRITE, &m); } -inline _OutputArray::_OutputArray(std::vector& vec) { init(STD_VECTOR_MAT + ACCESS_WRITE, &vec); } -inline _OutputArray::_OutputArray(UMat& m) { init(UMAT + ACCESS_WRITE, &m); } -inline _OutputArray::_OutputArray(std::vector& vec) { init(STD_VECTOR_UMAT + ACCESS_WRITE, &vec); } +inline _OutputArray::_OutputArray() { init(NONE | ACCESS_WRITE, 0); } +inline _OutputArray::_OutputArray(MagicFlag _flags, void* _obj) { init(_flags | ACCESS_WRITE, _obj); } +inline _OutputArray::_OutputArray(Mat& m) { init(MAT | ACCESS_WRITE, &m); } +inline _OutputArray::_OutputArray(std::vector& vec) { init(STD_VECTOR_MAT | ACCESS_WRITE, &vec); } +inline _OutputArray::_OutputArray(UMat& m) { init(UMAT | ACCESS_WRITE, &m); } +inline _OutputArray::_OutputArray(std::vector& vec) { init(STD_VECTOR_UMAT | ACCESS_WRITE, &vec); } template inline _OutputArray::_OutputArray(std::vector<_Tp>& vec) -{ init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } +{ init(FIXED_TYPE | STD_VECTOR | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, &vec); } template inline _OutputArray::_OutputArray(std::array<_Tp, _Nm>& arr) -{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_WRITE, arr.data(), Size(1, _Nm)); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_ARRAY | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, arr.data(), Size(1, _Nm)); } template inline _OutputArray::_OutputArray(std::array& arr) -{ init(STD_ARRAY_MAT + ACCESS_WRITE, arr.data(), Size(1, _Nm)); } +{ init(STD_ARRAY_MAT | ACCESS_WRITE, arr.data(), Size(1, _Nm)); } template inline _OutputArray::_OutputArray(std::vector >& vec) -{ init(FIXED_TYPE + STD_VECTOR_VECTOR + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } +{ init(FIXED_TYPE | STD_VECTOR_VECTOR | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, &vec); } template inline _OutputArray::_OutputArray(std::vector >& vec) -{ init(FIXED_TYPE + STD_VECTOR_MAT + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } +{ init(FIXED_TYPE | STD_VECTOR_MAT | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, &vec); } template inline _OutputArray::_OutputArray(Mat_<_Tp>& m) -{ init(FIXED_TYPE + MAT + traits::Type<_Tp>::value + ACCESS_WRITE, &m); } +{ init(FIXED_TYPE | MAT | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, &m); } template inline _OutputArray::_OutputArray(Matx<_Tp, m, n>& mtx) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, &mtx, Size(n, m)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, &mtx, Size(n, m)); } template inline _OutputArray::_OutputArray(_Tp* vec, int n) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, vec, Size(n, 1)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, vec, Size(n, 1)); } template inline _OutputArray::_OutputArray(const std::vector<_Tp>& vec) -{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_VECTOR | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, &vec); } template inline _OutputArray::_OutputArray(const std::array<_Tp, _Nm>& arr) -{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_WRITE, arr.data(), Size(1, _Nm)); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_ARRAY | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, arr.data(), Size(1, _Nm)); } template inline _OutputArray::_OutputArray(const std::array& arr) -{ init(FIXED_SIZE + STD_ARRAY_MAT + ACCESS_WRITE, arr.data(), Size(1, _Nm)); } +{ init(FIXED_SIZE | STD_ARRAY_MAT | ACCESS_WRITE, arr.data(), Size(1, _Nm)); } template inline _OutputArray::_OutputArray(const std::vector >& vec) -{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_VECTOR + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_VECTOR_VECTOR | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, &vec); } template inline _OutputArray::_OutputArray(const std::vector >& vec) -{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_MAT + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_VECTOR_MAT | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, &vec); } template inline _OutputArray::_OutputArray(const Mat_<_Tp>& m) -{ init(FIXED_TYPE + FIXED_SIZE + MAT + traits::Type<_Tp>::value + ACCESS_WRITE, &m); } +{ init(FIXED_TYPE | FIXED_SIZE | MAT | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, &m); } template inline _OutputArray::_OutputArray(const Matx<_Tp, m, n>& mtx) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, &mtx, Size(n, m)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, &mtx, Size(n, m)); } template inline _OutputArray::_OutputArray(const _Tp* vec, int n) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, vec, Size(n, 1)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, vec, Size(n, 1)); } inline _OutputArray::_OutputArray(cuda::GpuMat& d_mat) -{ init(CUDA_GPU_MAT + ACCESS_WRITE, &d_mat); } +{ init(CUDA_GPU_MAT | ACCESS_WRITE, &d_mat); } inline _OutputArray::_OutputArray(std::vector& d_mat) -{ init(STD_VECTOR_CUDA_GPU_MAT + ACCESS_WRITE, &d_mat);} +{ init(STD_VECTOR_CUDA_GPU_MAT | ACCESS_WRITE, &d_mat);} inline _OutputArray::_OutputArray(ogl::Buffer& buf) -{ init(OPENGL_BUFFER + ACCESS_WRITE, &buf); } +{ init(OPENGL_BUFFER | ACCESS_WRITE, &buf); } inline _OutputArray::_OutputArray(cuda::HostMem& cuda_mem) -{ init(CUDA_HOST_MEM + ACCESS_WRITE, &cuda_mem); } +{ init(CUDA_HOST_MEM | ACCESS_WRITE, &cuda_mem); } inline _OutputArray::_OutputArray(const Mat& m) -{ init(FIXED_TYPE + FIXED_SIZE + MAT + ACCESS_WRITE, &m); } +{ init(FIXED_TYPE | FIXED_SIZE | MAT | ACCESS_WRITE, &m); } inline _OutputArray::_OutputArray(const std::vector& vec) -{ init(FIXED_SIZE + STD_VECTOR_MAT + ACCESS_WRITE, &vec); } +{ init(FIXED_SIZE | STD_VECTOR_MAT | ACCESS_WRITE, &vec); } inline _OutputArray::_OutputArray(const UMat& m) -{ init(FIXED_TYPE + FIXED_SIZE + UMAT + ACCESS_WRITE, &m); } +{ init(FIXED_TYPE | FIXED_SIZE | UMAT | ACCESS_WRITE, &m); } inline _OutputArray::_OutputArray(const std::vector& vec) -{ init(FIXED_SIZE + STD_VECTOR_UMAT + ACCESS_WRITE, &vec); } +{ init(FIXED_SIZE | STD_VECTOR_UMAT | ACCESS_WRITE, &vec); } inline _OutputArray::_OutputArray(const cuda::GpuMat& d_mat) -{ init(FIXED_TYPE + FIXED_SIZE + CUDA_GPU_MAT + ACCESS_WRITE, &d_mat); } +{ init(FIXED_TYPE | FIXED_SIZE | CUDA_GPU_MAT | ACCESS_WRITE, &d_mat); } inline _OutputArray::_OutputArray(const ogl::Buffer& buf) -{ init(FIXED_TYPE + FIXED_SIZE + OPENGL_BUFFER + ACCESS_WRITE, &buf); } +{ init(FIXED_TYPE | FIXED_SIZE | OPENGL_BUFFER | ACCESS_WRITE, &buf); } inline _OutputArray::_OutputArray(const cuda::HostMem& cuda_mem) -{ init(FIXED_TYPE + FIXED_SIZE + CUDA_HOST_MEM + ACCESS_WRITE, &cuda_mem); } +{ init(FIXED_TYPE | FIXED_SIZE | CUDA_HOST_MEM | ACCESS_WRITE, &cuda_mem); } template inline _OutputArray _OutputArray::rawOut(std::vector<_Tp>& vec) { _OutputArray v; - v.flags = _InputArray::FIXED_TYPE + _InputArray::STD_VECTOR + rawType<_Tp>() + ACCESS_WRITE; + v.flags = _InputArray::FIXED_TYPE | _InputArray::STD_VECTOR | rawType<_Tp>() | ACCESS_WRITE; v.obj = (void*)&vec; return v; } @@ -303,7 +303,7 @@ template inline _OutputArray _OutputArray::rawOut(std::array<_Tp, _Nm>& arr) { _OutputArray v; - v.flags = FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_WRITE; + v.flags = FIXED_TYPE | FIXED_SIZE | STD_ARRAY | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE; v.obj = (void*)arr.data(); v.sz = Size(1, _Nm); return v; @@ -311,112 +311,112 @@ _OutputArray _OutputArray::rawOut(std::array<_Tp, _Nm>& arr) /////////////////////////////////////////////////////////////////////////////////////////// -inline _InputOutputArray::_InputOutputArray() { init(0+ACCESS_RW, 0); } -inline _InputOutputArray::_InputOutputArray(int _flags, void* _obj) { init(_flags+ACCESS_RW, _obj); } -inline _InputOutputArray::_InputOutputArray(Mat& m) { init(MAT+ACCESS_RW, &m); } -inline _InputOutputArray::_InputOutputArray(std::vector& vec) { init(STD_VECTOR_MAT+ACCESS_RW, &vec); } -inline _InputOutputArray::_InputOutputArray(UMat& m) { init(UMAT+ACCESS_RW, &m); } -inline _InputOutputArray::_InputOutputArray(std::vector& vec) { init(STD_VECTOR_UMAT+ACCESS_RW, &vec); } +inline _InputOutputArray::_InputOutputArray() { init(_InputArray::NONE | ACCESS_RW, 0); } +inline _InputOutputArray::_InputOutputArray(MagicFlag _flags, void* _obj) { init(_flags | ACCESS_RW, _obj); } +inline _InputOutputArray::_InputOutputArray(Mat& m) { init(MAT | ACCESS_RW, &m); } +inline _InputOutputArray::_InputOutputArray(std::vector& vec) { init(STD_VECTOR_MAT | ACCESS_RW, &vec); } +inline _InputOutputArray::_InputOutputArray(UMat& m) { init(UMAT | ACCESS_RW, &m); } +inline _InputOutputArray::_InputOutputArray(std::vector& vec) { init(STD_VECTOR_UMAT | ACCESS_RW, &vec); } template inline _InputOutputArray::_InputOutputArray(std::vector<_Tp>& vec) -{ init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_RW, &vec); } +{ init(FIXED_TYPE | STD_VECTOR | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, &vec); } template inline _InputOutputArray::_InputOutputArray(std::array<_Tp, _Nm>& arr) -{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_RW, arr.data(), Size(1, _Nm)); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_ARRAY | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, arr.data(), Size(1, _Nm)); } template inline _InputOutputArray::_InputOutputArray(std::array& arr) -{ init(STD_ARRAY_MAT + ACCESS_RW, arr.data(), Size(1, _Nm)); } +{ init(STD_ARRAY_MAT | ACCESS_RW, arr.data(), Size(1, _Nm)); } template inline _InputOutputArray::_InputOutputArray(std::vector >& vec) -{ init(FIXED_TYPE + STD_VECTOR_VECTOR + traits::Type<_Tp>::value + ACCESS_RW, &vec); } +{ init(FIXED_TYPE | STD_VECTOR_VECTOR | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, &vec); } template inline _InputOutputArray::_InputOutputArray(std::vector >& vec) -{ init(FIXED_TYPE + STD_VECTOR_MAT + traits::Type<_Tp>::value + ACCESS_RW, &vec); } +{ init(FIXED_TYPE | STD_VECTOR_MAT | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, &vec); } template inline _InputOutputArray::_InputOutputArray(Mat_<_Tp>& m) -{ init(FIXED_TYPE + MAT + traits::Type<_Tp>::value + ACCESS_RW, &m); } +{ init(FIXED_TYPE | MAT | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, &m); } template inline _InputOutputArray::_InputOutputArray(Matx<_Tp, m, n>& mtx) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, &mtx, Size(n, m)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, &mtx, Size(n, m)); } template inline _InputOutputArray::_InputOutputArray(_Tp* vec, int n) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, vec, Size(n, 1)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, vec, Size(n, 1)); } template inline _InputOutputArray::_InputOutputArray(const std::vector<_Tp>& vec) -{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_RW, &vec); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_VECTOR | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, &vec); } template inline _InputOutputArray::_InputOutputArray(const std::array<_Tp, _Nm>& arr) -{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_RW, arr.data(), Size(1, _Nm)); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_ARRAY | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, arr.data(), Size(1, _Nm)); } template inline _InputOutputArray::_InputOutputArray(const std::array& arr) -{ init(FIXED_SIZE + STD_ARRAY_MAT + ACCESS_RW, arr.data(), Size(1, _Nm)); } +{ init(FIXED_SIZE | STD_ARRAY_MAT | ACCESS_RW, arr.data(), Size(1, _Nm)); } template inline _InputOutputArray::_InputOutputArray(const std::vector >& vec) -{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_VECTOR + traits::Type<_Tp>::value + ACCESS_RW, &vec); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_VECTOR_VECTOR | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, &vec); } template inline _InputOutputArray::_InputOutputArray(const std::vector >& vec) -{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_MAT + traits::Type<_Tp>::value + ACCESS_RW, &vec); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_VECTOR_MAT | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, &vec); } template inline _InputOutputArray::_InputOutputArray(const Mat_<_Tp>& m) -{ init(FIXED_TYPE + FIXED_SIZE + MAT + traits::Type<_Tp>::value + ACCESS_RW, &m); } +{ init(FIXED_TYPE | FIXED_SIZE | MAT | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, &m); } template inline _InputOutputArray::_InputOutputArray(const Matx<_Tp, m, n>& mtx) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, &mtx, Size(n, m)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, &mtx, Size(n, m)); } template inline _InputOutputArray::_InputOutputArray(const _Tp* vec, int n) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, vec, Size(n, 1)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, vec, Size(n, 1)); } inline _InputOutputArray::_InputOutputArray(cuda::GpuMat& d_mat) -{ init(CUDA_GPU_MAT + ACCESS_RW, &d_mat); } +{ init(CUDA_GPU_MAT | ACCESS_RW, &d_mat); } inline _InputOutputArray::_InputOutputArray(ogl::Buffer& buf) -{ init(OPENGL_BUFFER + ACCESS_RW, &buf); } +{ init(OPENGL_BUFFER | ACCESS_RW, &buf); } inline _InputOutputArray::_InputOutputArray(cuda::HostMem& cuda_mem) -{ init(CUDA_HOST_MEM + ACCESS_RW, &cuda_mem); } +{ init(CUDA_HOST_MEM | ACCESS_RW, &cuda_mem); } inline _InputOutputArray::_InputOutputArray(const Mat& m) -{ init(FIXED_TYPE + FIXED_SIZE + MAT + ACCESS_RW, &m); } +{ init(FIXED_TYPE | FIXED_SIZE | MAT | ACCESS_RW, &m); } inline _InputOutputArray::_InputOutputArray(const std::vector& vec) -{ init(FIXED_SIZE + STD_VECTOR_MAT + ACCESS_RW, &vec); } +{ init(FIXED_SIZE | STD_VECTOR_MAT | ACCESS_RW, &vec); } inline _InputOutputArray::_InputOutputArray(const UMat& m) -{ init(FIXED_TYPE + FIXED_SIZE + UMAT + ACCESS_RW, &m); } +{ init(FIXED_TYPE | FIXED_SIZE | UMAT | ACCESS_RW, &m); } inline _InputOutputArray::_InputOutputArray(const std::vector& vec) -{ init(FIXED_SIZE + STD_VECTOR_UMAT + ACCESS_RW, &vec); } +{ init(FIXED_SIZE | STD_VECTOR_UMAT | ACCESS_RW, &vec); } inline _InputOutputArray::_InputOutputArray(const cuda::GpuMat& d_mat) -{ init(FIXED_TYPE + FIXED_SIZE + CUDA_GPU_MAT + ACCESS_RW, &d_mat); } +{ init(FIXED_TYPE | FIXED_SIZE | CUDA_GPU_MAT | ACCESS_RW, &d_mat); } inline _InputOutputArray::_InputOutputArray(const std::vector& d_mat) -{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_CUDA_GPU_MAT + ACCESS_RW, &d_mat);} +{ init(FIXED_TYPE | FIXED_SIZE | STD_VECTOR_CUDA_GPU_MAT | ACCESS_RW, &d_mat);} template<> inline _InputOutputArray::_InputOutputArray(std::vector& d_mat) -{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_CUDA_GPU_MAT + ACCESS_RW, &d_mat);} +{ init(FIXED_TYPE | FIXED_SIZE | STD_VECTOR_CUDA_GPU_MAT | ACCESS_RW, &d_mat);} inline _InputOutputArray::_InputOutputArray(const ogl::Buffer& buf) -{ init(FIXED_TYPE + FIXED_SIZE + OPENGL_BUFFER + ACCESS_RW, &buf); } +{ init(FIXED_TYPE | FIXED_SIZE | OPENGL_BUFFER | ACCESS_RW, &buf); } inline _InputOutputArray::_InputOutputArray(const cuda::HostMem& cuda_mem) -{ init(FIXED_TYPE + FIXED_SIZE + CUDA_HOST_MEM + ACCESS_RW, &cuda_mem); } +{ init(FIXED_TYPE | FIXED_SIZE | CUDA_HOST_MEM | ACCESS_RW, &cuda_mem); } template inline _InputOutputArray _InputOutputArray::rawInOut(std::vector<_Tp>& vec) @@ -431,7 +431,7 @@ template inline _InputOutputArray _InputOutputArray::rawInOut(std::array<_Tp, _Nm>& arr) { _InputOutputArray v; - v.flags = FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_RW; + v.flags = FIXED_TYPE | FIXED_SIZE | STD_ARRAY | static_cast(traits::Type<_Tp>::value) | ACCESS_RW; v.obj = (void*)arr.data(); v.sz = Size(1, _Nm); return v; @@ -448,21 +448,21 @@ CV__DEBUG_NS_END inline Mat::Mat() - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) {} inline -Mat::Mat(int _rows, int _cols, int _type) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), +Mat::Mat(int _rows, int _cols, ElemType _type) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { create(_rows, _cols, _type); } inline -Mat::Mat(int _rows, int _cols, int _type, const Scalar& _s) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), +Mat::Mat(int _rows, int _cols, ElemType _type, const Scalar& _s) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { create(_rows, _cols, _type); @@ -470,16 +470,16 @@ Mat::Mat(int _rows, int _cols, int _type, const Scalar& _s) } inline -Mat::Mat(Size _sz, int _type) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), +Mat::Mat(Size _sz, ElemType _type) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { create( _sz.height, _sz.width, _type ); } inline -Mat::Mat(Size _sz, int _type, const Scalar& _s) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), +Mat::Mat(Size _sz, ElemType _type, const Scalar& _s) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { create(_sz.height, _sz.width, _type); @@ -487,16 +487,16 @@ Mat::Mat(Size _sz, int _type, const Scalar& _s) } inline -Mat::Mat(int _dims, const int* _sz, int _type) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), +Mat::Mat(int _dims, const int* _sz, ElemType _type) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { create(_dims, _sz, _type); } inline -Mat::Mat(int _dims, const int* _sz, int _type, const Scalar& _s) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), +Mat::Mat(int _dims, const int* _sz, ElemType _type, const Scalar& _s) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { create(_dims, _sz, _type); @@ -504,16 +504,16 @@ Mat::Mat(int _dims, const int* _sz, int _type, const Scalar& _s) } inline -Mat::Mat(const std::vector& _sz, int _type) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), +Mat::Mat(const std::vector& _sz, ElemType _type) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { create(_sz, _type); } inline -Mat::Mat(const std::vector& _sz, int _type, const Scalar& _s) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), +Mat::Mat(const std::vector& _sz, ElemType _type, const Scalar& _s) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { create(_sz, _type); @@ -540,8 +540,8 @@ Mat::Mat(const Mat& m) } inline -Mat::Mat(int _rows, int _cols, int _type, void* _data, size_t _step) - : flags(MAGIC_VAL + (_type & TYPE_MASK)), dims(2), rows(_rows), cols(_cols), +Mat::Mat(int _rows, int _cols, ElemType _type, void* _data, size_t _step) + : flags(static_cast(MAGIC_VAL | (_type & TYPE_MASK))), dims(2), rows(_rows), cols(_cols), data((uchar*)_data), datastart((uchar*)_data), dataend(0), datalimit(0), allocator(0), u(0), size(&rows) { @@ -569,8 +569,8 @@ Mat::Mat(int _rows, int _cols, int _type, void* _data, size_t _step) } inline -Mat::Mat(Size _sz, int _type, void* _data, size_t _step) - : flags(MAGIC_VAL + (_type & TYPE_MASK)), dims(2), rows(_sz.height), cols(_sz.width), +Mat::Mat(Size _sz, ElemType _type, void* _data, size_t _step) + : flags(static_cast(MAGIC_VAL | (_type & TYPE_MASK))), dims(2), rows(_sz.height), cols(_sz.width), data((uchar*)_data), datastart((uchar*)_data), dataend(0), datalimit(0), allocator(0), u(0), size(&rows) { @@ -600,7 +600,7 @@ Mat::Mat(Size _sz, int _type, void* _data, size_t _step) template inline Mat::Mat(const std::vector<_Tp>& vec, bool copyData) - : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()), + : flags(static_cast(MAGIC_VAL) | static_cast(traits::Type<_Tp>::value) | CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()), cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { if(vec.empty()) @@ -637,7 +637,7 @@ Mat::Mat(const std::initializer_list sizes, const std::initializer_list<_Tp template inline Mat::Mat(const std::array<_Tp, _Nm>& arr, bool copyData) - : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)arr.size()), + : flags(static_cast(MAGIC_VAL) | static_cast(traits::Type<_Tp>::value) | CV_MAT_CONT_FLAG), dims(2), rows((int)arr.size()), cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { if(arr.empty()) @@ -654,7 +654,7 @@ Mat::Mat(const std::array<_Tp, _Nm>& arr, bool copyData) template inline Mat::Mat(const Vec<_Tp, n>& vec, bool copyData) - : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(n), cols(1), data(0), + : flags(static_cast(MAGIC_VAL) | static_cast(traits::Type<_Tp>::value) | CV_MAT_CONT_FLAG), dims(2), rows(n), cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { if( !copyData ) @@ -670,7 +670,7 @@ Mat::Mat(const Vec<_Tp, n>& vec, bool copyData) template inline Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData) - : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(m), cols(n), data(0), + : flags(static_cast(MAGIC_VAL) | static_cast(traits::Type<_Tp>::value) | CV_MAT_CONT_FLAG), dims(2), rows(m), cols(n), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { if( !copyData ) @@ -686,7 +686,7 @@ Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData) template inline Mat::Mat(const Point_<_Tp>& pt, bool copyData) - : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(2), cols(1), data(0), + : flags(static_cast(MAGIC_VAL) | static_cast(traits::Type<_Tp>::value) | CV_MAT_CONT_FLAG), dims(2), rows(2), cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { if( !copyData ) @@ -705,7 +705,7 @@ Mat::Mat(const Point_<_Tp>& pt, bool copyData) template inline Mat::Mat(const Point3_<_Tp>& pt, bool copyData) - : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(3), cols(1), data(0), + : flags(static_cast(MAGIC_VAL) | static_cast(traits::Type<_Tp>::value) | CV_MAT_CONT_FLAG), dims(2), rows(3), cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { if( !copyData ) @@ -725,7 +725,7 @@ Mat::Mat(const Point3_<_Tp>& pt, bool copyData) template inline Mat::Mat(const MatCommaInitializer_<_Tp>& commaInitializer) - : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(0), rows(0), cols(0), data(0), + : flags(static_cast(MAGIC_VAL) | static_cast(traits::Type<_Tp>::value) | CV_MAT_CONT_FLAG), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), allocator(0), u(0), size(&rows) { *this = commaInitializer.operator Mat_<_Tp>(); @@ -813,18 +813,18 @@ Mat Mat::clone() const } inline -void Mat::assignTo( Mat& m, int _type ) const +void Mat::assignTo(Mat& m, ElemType _depth) const { - if( _type < 0 ) + if (_depth == CV_TYPE_AUTO) m = *this; else - convertTo(m, _type); + convertTo(m, _depth); } inline -void Mat::create(int _rows, int _cols, int _type) +void Mat::create(int _rows, int _cols, ElemType _type) { - _type &= TYPE_MASK; + _type &= static_cast(TYPE_MASK); if( dims <= 2 && rows == _rows && cols == _cols && type() == _type && data ) return; int sz[] = {_rows, _cols}; @@ -832,7 +832,7 @@ void Mat::create(int _rows, int _cols, int _type) } inline -void Mat::create(Size _sz, int _type) +void Mat::create(Size _sz, ElemType _type) { create(_sz.height, _sz.width, _type); } @@ -854,7 +854,7 @@ void Mat::release() for(int i = 0; i < dims; i++) size.p[i] = 0; #ifdef _DEBUG - flags = MAGIC_VAL; + flags = static_cast(MAGIC_VAL); dims = rows = cols = 0; if(step.p != step.buf) { @@ -892,13 +892,13 @@ Mat Mat::operator()(const std::vector& ranges) const inline bool Mat::isContinuous() const { - return (flags & CONTINUOUS_FLAG) != 0; + return !!(flags & static_cast(CONTINUOUS_FLAG)); } inline bool Mat::isSubmatrix() const { - return (flags & SUBMATRIX_FLAG) != 0; + return !!(flags & static_cast(SUBMATRIX_FLAG)); } inline @@ -916,13 +916,13 @@ size_t Mat::elemSize1() const } inline -int Mat::type() const +ElemType Mat::type() const { return CV_MAT_TYPE(flags); } inline -int Mat::depth() const +ElemType Mat::depth() const { return CV_MAT_DEPTH(flags); } @@ -1395,7 +1395,7 @@ Mat::Mat(Mat&& m) m.step.p = m.step.buf; m.size.p = &m.rows; } - m.flags = MAGIC_VAL; m.dims = m.rows = m.cols = 0; + m.flags = static_cast(MAGIC_VAL); m.dims = m.rows = m.cols = 0; m.data = NULL; m.datastart = NULL; m.dataend = NULL; m.datalimit = NULL; m.allocator = NULL; m.u = NULL; @@ -1430,7 +1430,7 @@ Mat& Mat::operator = (Mat&& m) m.step.p = m.step.buf; m.size.p = &m.rows; } - m.flags = MAGIC_VAL; m.dims = m.rows = m.cols = 0; + m.flags = static_cast(MAGIC_VAL); m.dims = m.rows = m.cols = 0; m.data = NULL; m.datastart = NULL; m.dataend = NULL; m.datalimit = NULL; m.allocator = NULL; m.u = NULL; @@ -1554,7 +1554,7 @@ template inline Mat_<_Tp>::Mat_() : Mat() { - flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value; + flags = static_cast((flags & ~CV_MAT_TYPE_MASK) | static_cast(traits::Type<_Tp>::value)); } template inline @@ -1611,7 +1611,7 @@ template inline Mat_<_Tp>::Mat_(const Mat& m) : Mat() { - flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value; + flags = static_cast((flags & ~CV_MAT_TYPE_MASK) | static_cast(traits::Type<_Tp>::value)); *this = m; } @@ -1751,7 +1751,7 @@ void Mat_<_Tp>::release() { Mat::release(); #ifdef _DEBUG - flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value; + flags = static_cast((flags & ~CV_MAT_TYPE_MASK) | static_cast(traits::Type<_Tp>::value)); #endif } @@ -1806,14 +1806,14 @@ size_t Mat_<_Tp>::elemSize1() const } template inline -int Mat_<_Tp>::type() const +ElemType Mat_<_Tp>::type() const { CV_DbgAssert( Mat::type() == traits::Type<_Tp>::value ); return traits::Type<_Tp>::value; } template inline -int Mat_<_Tp>::depth() const +ElemType Mat_<_Tp>::depth() const { CV_DbgAssert( Mat::depth() == traits::Depth<_Tp>::value ); return traits::Depth<_Tp>::value; @@ -2069,7 +2069,7 @@ template inline Mat_<_Tp>::Mat_(Mat&& m) : Mat() { - flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value; + flags = static_cast((flags & ~CV_MAT_TYPE_MASK) | static_cast(traits::Type<_Tp>::value)); *this = m; } @@ -2095,7 +2095,7 @@ template inline Mat_<_Tp>::Mat_(MatExpr&& e) : Mat() { - flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value; + flags = static_cast((flags & ~CV_MAT_TYPE_MASK) | static_cast(traits::Type<_Tp>::value)); *this = Mat(e); } @@ -2104,12 +2104,12 @@ Mat_<_Tp>::Mat_(MatExpr&& e) inline SparseMat::SparseMat() - : flags(MAGIC_VAL), hdr(0) + : flags(static_cast(MAGIC_VAL)), hdr(0) {} inline -SparseMat::SparseMat(int _dims, const int* _sizes, int _type) - : flags(MAGIC_VAL), hdr(0) +SparseMat::SparseMat(int _dims, const int* _sizes, ElemType _type) + : flags(static_cast(MAGIC_VAL)), hdr(0) { create(_dims, _sizes, _type); } @@ -2156,12 +2156,12 @@ SparseMat SparseMat::clone() const } inline -void SparseMat::assignTo( SparseMat& m, int _type ) const +void SparseMat::assignTo(SparseMat& m, ElemType _depth) const { - if( _type < 0 ) + if (_depth == CV_TYPE_AUTO) m = *this; else - convertTo(m, _type); + convertTo(m, _depth); } inline @@ -2192,13 +2192,13 @@ size_t SparseMat::elemSize1() const } inline -int SparseMat::type() const +ElemType SparseMat::type() const { return CV_MAT_TYPE(flags); } inline -int SparseMat::depth() const +ElemType SparseMat::depth() const { return CV_MAT_DEPTH(flags); } @@ -2431,7 +2431,7 @@ SparseMatConstIterator_<_Tp> SparseMat::end() const template inline SparseMat_<_Tp>::SparseMat_() { - flags = MAGIC_VAL + traits::Type<_Tp>::value; + flags = static_cast(MAGIC_VAL) | static_cast(traits::Type<_Tp>::value); } template inline @@ -2507,13 +2507,13 @@ void SparseMat_<_Tp>::create(int _dims, const int* _sizes) } template inline -int SparseMat_<_Tp>::type() const +ElemType SparseMat_<_Tp>::type() const { return traits::Type<_Tp>::value; } template inline -int SparseMat_<_Tp>::depth() const +ElemType SparseMat_<_Tp>::depth() const { return traits::Depth<_Tp>::value; } @@ -3352,13 +3352,13 @@ Mat& Mat::operator = (const MatExpr& e) template inline Mat_<_Tp>::Mat_(const MatExpr& e) { - e.op->assign(e, *this, traits::Type<_Tp>::value); + e.op->assign(e, *this, traits::Depth<_Tp>::value); } template inline Mat_<_Tp>& Mat_<_Tp>::operator = (const MatExpr& e) { - e.op->assign(e, *this, traits::Type<_Tp>::value); + e.op->assign(e, *this, traits::Depth<_Tp>::value); return *this; } @@ -3421,7 +3421,7 @@ template inline MatExpr::operator Mat_<_Tp>() const { Mat_<_Tp> m; - op->assign(*this, m, traits::Type<_Tp>::value); + op->assign(*this, m, traits::Depth<_Tp>::value); return m; } @@ -3586,49 +3586,49 @@ const Mat_<_Tp>& operator /= (const Mat_<_Tp>& a, const MatExpr& b) inline UMat::UMat(UMatUsageFlags _usageFlags) -: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) +: flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) {} inline -UMat::UMat(int _rows, int _cols, int _type, UMatUsageFlags _usageFlags) -: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) +UMat::UMat(int _rows, int _cols, ElemType _type, UMatUsageFlags _usageFlags) +: flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) { create(_rows, _cols, _type); } inline -UMat::UMat(int _rows, int _cols, int _type, const Scalar& _s, UMatUsageFlags _usageFlags) -: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) +UMat::UMat(int _rows, int _cols, ElemType _type, const Scalar& _s, UMatUsageFlags _usageFlags) +: flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) { create(_rows, _cols, _type); *this = _s; } inline -UMat::UMat(Size _sz, int _type, UMatUsageFlags _usageFlags) -: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) +UMat::UMat(Size _sz, ElemType _type, UMatUsageFlags _usageFlags) +: flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) { create( _sz.height, _sz.width, _type ); } inline -UMat::UMat(Size _sz, int _type, const Scalar& _s, UMatUsageFlags _usageFlags) -: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) +UMat::UMat(Size _sz, ElemType _type, const Scalar& _s, UMatUsageFlags _usageFlags) +: flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) { create(_sz.height, _sz.width, _type); *this = _s; } inline -UMat::UMat(int _dims, const int* _sz, int _type, UMatUsageFlags _usageFlags) -: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) +UMat::UMat(int _dims, const int* _sz, ElemType _type, UMatUsageFlags _usageFlags) +: flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) { create(_dims, _sz, _type); } inline -UMat::UMat(int _dims, const int* _sz, int _type, const Scalar& _s, UMatUsageFlags _usageFlags) -: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) +UMat::UMat(int _dims, const int* _sz, ElemType _type, const Scalar& _s, UMatUsageFlags _usageFlags) +: flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) { create(_dims, _sz, _type); *this = _s; @@ -3654,7 +3654,7 @@ UMat::UMat(const UMat& m) template inline UMat::UMat(const std::vector<_Tp>& vec, bool copyData) -: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()), +: flags(static_cast(MAGIC_VAL) | static_cast(traits::Type<_Tp>::value) | CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()), cols(1), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows) { if(vec.empty()) @@ -3740,18 +3740,18 @@ UMat UMat::clone() const } inline -void UMat::assignTo( UMat& m, int _type ) const +void UMat::assignTo(UMat& m, ElemType _depth) const { - if( _type < 0 ) + if (_depth == CV_TYPE_AUTO) m = *this; else - convertTo(m, _type); + convertTo(m, _depth); } inline -void UMat::create(int _rows, int _cols, int _type, UMatUsageFlags _usageFlags) +void UMat::create(int _rows, int _cols, ElemType _type, UMatUsageFlags _usageFlags) { - _type &= TYPE_MASK; + _type &= static_cast(TYPE_MASK); if( dims <= 2 && rows == _rows && cols == _cols && type() == _type && u ) return; int sz[] = {_rows, _cols}; @@ -3759,7 +3759,7 @@ void UMat::create(int _rows, int _cols, int _type, UMatUsageFlags _usageFlags) } inline -void UMat::create(Size _sz, int _type, UMatUsageFlags _usageFlags) +void UMat::create(Size _sz, ElemType _type, UMatUsageFlags _usageFlags) { create(_sz.height, _sz.width, _type, _usageFlags); } @@ -3807,13 +3807,13 @@ UMat UMat::operator()(const std::vector& ranges) const inline bool UMat::isContinuous() const { - return (flags & CONTINUOUS_FLAG) != 0; + return !!(flags & static_cast(CONTINUOUS_FLAG)); } inline bool UMat::isSubmatrix() const { - return (flags & SUBMATRIX_FLAG) != 0; + return !!(flags & static_cast(SUBMATRIX_FLAG)); } inline @@ -3831,13 +3831,13 @@ size_t UMat::elemSize1() const } inline -int UMat::type() const +ElemType UMat::type() const { return CV_MAT_TYPE(flags); } inline -int UMat::depth() const +ElemType UMat::depth() const { return CV_MAT_DEPTH(flags); } @@ -3889,7 +3889,7 @@ UMat::UMat(UMat&& m) m.step.p = m.step.buf; m.size.p = &m.rows; } - m.flags = MAGIC_VAL; m.dims = m.rows = m.cols = 0; + m.flags = static_cast(MAGIC_VAL); m.dims = m.rows = m.cols = 0; m.allocator = NULL; m.u = NULL; m.offset = 0; @@ -3924,7 +3924,7 @@ UMat& UMat::operator = (UMat&& m) m.step.p = m.step.buf; m.size.p = &m.rows; } - m.flags = MAGIC_VAL; m.dims = m.rows = m.cols = 0; + m.flags = static_cast(MAGIC_VAL); m.dims = m.rows = m.cols = 0; m.allocator = NULL; m.u = NULL; m.offset = 0; @@ -3932,11 +3932,11 @@ UMat& UMat::operator = (UMat&& m) } -inline bool UMatData::hostCopyObsolete() const { return (flags & HOST_COPY_OBSOLETE) != 0; } -inline bool UMatData::deviceCopyObsolete() const { return (flags & DEVICE_COPY_OBSOLETE) != 0; } -inline bool UMatData::deviceMemMapped() const { return (flags & DEVICE_MEM_MAPPED) != 0; } -inline bool UMatData::copyOnMap() const { return (flags & COPY_ON_MAP) != 0; } -inline bool UMatData::tempUMat() const { return (flags & TEMP_UMAT) != 0; } +inline bool UMatData::hostCopyObsolete() const { return !!(flags & HOST_COPY_OBSOLETE); } +inline bool UMatData::deviceCopyObsolete() const { return !!(flags & DEVICE_COPY_OBSOLETE); } +inline bool UMatData::deviceMemMapped() const { return !!(flags & DEVICE_MEM_MAPPED); } +inline bool UMatData::copyOnMap() const { return !!(flags & COPY_ON_MAP); } +inline bool UMatData::tempUMat() const { return !!(flags & TEMP_UMAT); } inline bool UMatData::tempCopiedUMat() const { return (flags & TEMP_COPIED_UMAT) == TEMP_COPIED_UMAT; } inline void UMatData::markDeviceMemMapped(bool flag) diff --git a/modules/core/include/opencv2/core/matx.hpp b/modules/core/include/opencv2/core/matx.hpp index 82de1f88d83f..3fcd73b17436 100644 --- a/modules/core/include/opencv2/core/matx.hpp +++ b/modules/core/include/opencv2/core/matx.hpp @@ -99,16 +99,14 @@ In case if C++11 features are available, std::initializer_list can be also used template class Matx { public: - enum { - rows = m, - cols = n, - channels = rows*cols, + static const int rows = m; + static const int cols = n; + static const int channels = rows*cols; + static const int shortdim = (m < n ? m : n); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - depth = traits::Type<_Tp>::value, - type = CV_MAKETYPE(depth, channels), + static const ElemType depth = traits::Depth<_Tp>::value; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - shortdim = (m < n ? m : n) - }; typedef _Tp value_type; typedef Matx<_Tp, m, n> mat_type; @@ -258,21 +256,20 @@ template class DataType< Matx<_Tp, m, n> > typedef _Tp channel_type; typedef value_type vec_type; - enum { generic_type = 0, - channels = m * n, - fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = m * n; + static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemType depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; }; namespace traits { template -struct Depth< Matx<_Tp, m, n> > { enum { value = Depth<_Tp>::value }; }; +struct Depth< Matx<_Tp, m, n> > { static const ElemType value = Depth<_Tp>::value; }; template -struct Type< Matx<_Tp, m, n> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, n*m) }; }; +struct Type< Matx<_Tp, m, n> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, n*m); }; } // namespace @@ -333,14 +330,11 @@ template class Vec : public Matx<_Tp, cn, 1> { public: typedef _Tp value_type; - enum { - channels = cn, + static const int channels = cn; #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - depth = Matx<_Tp, cn, 1>::depth, - type = CV_MAKETYPE(depth, channels), + static const ElemType depth = Matx<_Tp, cn, 1>::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - _dummy_enum_finalizer = 0 - }; //! default constructor Vec(); @@ -433,22 +427,20 @@ template class DataType< Vec<_Tp, cn> > typedef _Tp channel_type; typedef value_type vec_type; - enum { generic_type = 0, - channels = cn, - fmt = DataType::fmt + ((channels - 1) << 8), + static const bool generic_type = false; + static const int channels = cn; + static const int fmt = DataType::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - depth = DataType::depth, - type = CV_MAKETYPE(depth, channels), + static const ElemType depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - _dummy_enum_finalizer = 0 - }; }; namespace traits { template -struct Depth< Vec<_Tp, cn> > { enum { value = Depth<_Tp>::value }; }; +struct Depth< Vec<_Tp, cn> > { static const ElemType value = Depth<_Tp>::value; }; template -struct Type< Vec<_Tp, cn> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, cn) }; }; +struct Type< Vec<_Tp, cn> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, cn); }; } // namespace diff --git a/modules/core/include/opencv2/core/ocl.hpp b/modules/core/include/opencv2/core/ocl.hpp index 888477e15440..eca391902af8 100644 --- a/modules/core/include/opencv2/core/ocl.hpp +++ b/modules/core/include/opencv2/core/ocl.hpp @@ -307,7 +307,7 @@ CV_EXPORTS void attachContext(const String& platformName, void* platformID, void @param type OpenCV type of image @param dst destination UMat */ -CV_EXPORTS void convertFromBuffer(void* cl_mem_buffer, size_t step, int rows, int cols, int type, UMat& dst); +CV_EXPORTS void convertFromBuffer(void* cl_mem_buffer, size_t step, int rows, int cols, ElemType type, UMat& dst); /** @brief Convert OpenCL image2d_t to UMat @note @@ -728,12 +728,12 @@ class CV_EXPORTS PlatformInfo Impl* p; }; -CV_EXPORTS const char* convertTypeStr(int sdepth, int ddepth, int cn, char* buf); +CV_EXPORTS const char* convertTypeStr(ElemType sdepth, ElemType ddepth, int cn, char* buf); CV_EXPORTS const char* typeToStr(int t); CV_EXPORTS const char* memopTypeToStr(int t); CV_EXPORTS const char* vecopTypeToStr(int t); CV_EXPORTS const char* getOpenCLErrorString(int errorCode); -CV_EXPORTS String kernelToStr(InputArray _kernel, int ddepth = -1, const char * name = NULL); +CV_EXPORTS String kernelToStr(InputArray _kernel, ElemType ddepth = CV_TYPE_AUTO, const char * name = NULL); CV_EXPORTS void getPlatfomsInfo(std::vector& platform_info); @@ -791,7 +791,7 @@ class CV_EXPORTS Image2D /** Indicates if the image format is supported. */ - static bool isFormatSupported(int depth, int cn, bool norm); + static bool isFormatSupported(ElemType depth, int cn, bool norm); void* ptr() const; protected: diff --git a/modules/core/include/opencv2/core/opengl.hpp b/modules/core/include/opencv2/core/opengl.hpp index ddc0db6943c5..883afa8813d2 100644 --- a/modules/core/include/opencv2/core/opengl.hpp +++ b/modules/core/include/opencv2/core/opengl.hpp @@ -110,7 +110,7 @@ class CV_EXPORTS Buffer @param abufId Buffer object name. @param autoRelease Auto release mode (if true, release will be called in object's destructor). */ - Buffer(int arows, int acols, int atype, unsigned int abufId, bool autoRelease = false); + Buffer(int arows, int acols, ElemType atype, unsigned int abufId, bool autoRelease = false); /** @overload @param asize 2D array size. @@ -118,7 +118,7 @@ class CV_EXPORTS Buffer @param abufId Buffer object name. @param autoRelease Auto release mode (if true, release will be called in object's destructor). */ - Buffer(Size asize, int atype, unsigned int abufId, bool autoRelease = false); + Buffer(Size asize, ElemType atype, unsigned int abufId, bool autoRelease = false); /** @overload @param arows Number of rows in a 2D array. @@ -127,7 +127,7 @@ class CV_EXPORTS Buffer @param target Buffer usage. See cv::ogl::Buffer::Target . @param autoRelease Auto release mode (if true, release will be called in object's destructor). */ - Buffer(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false); + Buffer(int arows, int acols, ElemType atype, Target target = ARRAY_BUFFER, bool autoRelease = false); /** @overload @param asize 2D array size. @@ -135,7 +135,7 @@ class CV_EXPORTS Buffer @param target Buffer usage. See cv::ogl::Buffer::Target . @param autoRelease Auto release mode (if true, release will be called in object's destructor). */ - Buffer(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false); + Buffer(Size asize, ElemType atype, Target target = ARRAY_BUFFER, bool autoRelease = false); /** @overload @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ). @@ -152,7 +152,7 @@ class CV_EXPORTS Buffer @param target Buffer usage. See cv::ogl::Buffer::Target . @param autoRelease Auto release mode (if true, release will be called in object's destructor). */ - void create(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false); + void create(int arows, int acols, ElemType atype, Target target = ARRAY_BUFFER, bool autoRelease = false); /** @overload @param asize 2D array size. @@ -160,7 +160,7 @@ class CV_EXPORTS Buffer @param target Buffer usage. See cv::ogl::Buffer::Target . @param autoRelease Auto release mode (if true, release will be called in object's destructor). */ - void create(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false); + void create(Size asize, ElemType atype, Target target = ARRAY_BUFFER, bool autoRelease = false); /** @brief Decrements the reference counter and destroys the buffer object if needed. @@ -260,8 +260,8 @@ class CV_EXPORTS Buffer Size size() const; bool empty() const; - int type() const; - int depth() const; + ElemType type() const; + ElemType depth() const; int channels() const; int elemSize() const; int elemSize1() const; @@ -275,7 +275,7 @@ class CV_EXPORTS Buffer Ptr impl_; int rows_; int cols_; - int type_; + ElemType type_; }; /** @brief Smart pointer for OpenGL 2D texture memory with reference counting. @@ -374,7 +374,7 @@ class CV_EXPORTS Texture2D @param ddepth Destination depth. @param autoRelease Auto release mode for destination buffer (if arr is OpenGL buffer or texture). */ - void copyTo(OutputArray arr, int ddepth = CV_32F, bool autoRelease = false) const; + void copyTo(OutputArray arr, ElemType ddepth = CV_32F, bool autoRelease = false) const; /** @brief Binds texture to current active texture unit for GL_TEXTURE_2D target. */ @@ -584,19 +584,19 @@ CV_EXPORTS void setGlDevice(int device = 0); //////////////////////////////////////////////////////////////////////// inline -cv::ogl::Buffer::Buffer(int arows, int acols, int atype, Target target, bool autoRelease) : rows_(0), cols_(0), type_(0) +cv::ogl::Buffer::Buffer(int arows, int acols, ElemType atype, Target target, bool autoRelease) : rows_(0), cols_(0), type_(static_cast(0)) { create(arows, acols, atype, target, autoRelease); } inline -cv::ogl::Buffer::Buffer(Size asize, int atype, Target target, bool autoRelease) : rows_(0), cols_(0), type_(0) +cv::ogl::Buffer::Buffer(Size asize, ElemType atype, Target target, bool autoRelease) : rows_(0), cols_(0), type_(static_cast(0)) { create(asize, atype, target, autoRelease); } inline -void cv::ogl::Buffer::create(Size asize, int atype, Target target, bool autoRelease) +void cv::ogl::Buffer::create(Size asize, ElemType atype, Target target, bool autoRelease) { create(asize.height, asize.width, atype, target, autoRelease); } @@ -626,13 +626,13 @@ bool cv::ogl::Buffer::empty() const } inline -int cv::ogl::Buffer::type() const +ElemType cv::ogl::Buffer::type() const { return type_; } inline -int cv::ogl::Buffer::depth() const +ElemType cv::ogl::Buffer::depth() const { return CV_MAT_DEPTH(type_); } diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index 0d28b6c9440c..6481fb953445 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -267,14 +267,14 @@ CV_MAT_AUG_OPERATOR_T(-=, cv::subtract(a,b,a), Mat_<_Tp>, Mat_<_Tp>) CV_MAT_AUG_OPERATOR (*=, cv::gemm(a, b, 1, Mat(), 0, a, 0), Mat, Mat) CV_MAT_AUG_OPERATOR_T(*=, cv::gemm(a, b, 1, Mat(), 0, a, 0), Mat_<_Tp>, Mat) CV_MAT_AUG_OPERATOR_T(*=, cv::gemm(a, b, 1, Mat(), 0, a, 0), Mat_<_Tp>, Mat_<_Tp>) -CV_MAT_AUG_OPERATOR (*=, a.convertTo(a, -1, b), Mat, double) -CV_MAT_AUG_OPERATOR_T(*=, a.convertTo(a, -1, b), Mat_<_Tp>, double) +CV_MAT_AUG_OPERATOR (*=, a.convertTo(a, CV_TYPE_AUTO, b), Mat, double) +CV_MAT_AUG_OPERATOR_T(*= , a.convertTo(a, CV_TYPE_AUTO, b), Mat_<_Tp>, double) CV_MAT_AUG_OPERATOR (/=, cv::divide(a,b,a), Mat, Mat) CV_MAT_AUG_OPERATOR_T(/=, cv::divide(a,b,a), Mat_<_Tp>, Mat) CV_MAT_AUG_OPERATOR_T(/=, cv::divide(a,b,a), Mat_<_Tp>, Mat_<_Tp>) -CV_MAT_AUG_OPERATOR (/=, a.convertTo((Mat&)a, -1, 1./b), Mat, double) -CV_MAT_AUG_OPERATOR_T(/=, a.convertTo((Mat&)a, -1, 1./b), Mat_<_Tp>, double) +CV_MAT_AUG_OPERATOR(/= , a.convertTo((Mat&)a, CV_TYPE_AUTO, 1. / b), Mat, double) +CV_MAT_AUG_OPERATOR_T(/= , a.convertTo((Mat&)a, CV_TYPE_AUTO, 1. / b), Mat_<_Tp>, double) CV_MAT_AUG_OPERATOR (&=, cv::bitwise_and(a,b,a), Mat, Mat) CV_MAT_AUG_OPERATOR (&=, cv::bitwise_and(a,b,a), Mat, Scalar) diff --git a/modules/core/include/opencv2/core/private.cuda.hpp b/modules/core/include/opencv2/core/private.cuda.hpp index cda6cbc4aed1..7fd419616014 100644 --- a/modules/core/include/opencv2/core/private.cuda.hpp +++ b/modules/core/include/opencv2/core/private.cuda.hpp @@ -93,8 +93,8 @@ namespace cv { namespace cuda { CV_EXPORTS GpuMat getInputMat(InputArray _src, Stream& stream); - CV_EXPORTS GpuMat getOutputMat(OutputArray _dst, int rows, int cols, int type, Stream& stream); - static inline GpuMat getOutputMat(OutputArray _dst, Size size, int type, Stream& stream) + CV_EXPORTS GpuMat getOutputMat(OutputArray _dst, int rows, int cols, ElemType type, Stream& stream); + static inline GpuMat getOutputMat(OutputArray _dst, Size size, ElemType type, Stream& stream) { return getOutputMat(_dst, size.height, size.width, type, stream); } diff --git a/modules/core/include/opencv2/core/private.hpp b/modules/core/include/opencv2/core/private.hpp index 05c486f4edef..ab9971b230dd 100644 --- a/modules/core/include/opencv2/core/private.hpp +++ b/modules/core/include/opencv2/core/private.hpp @@ -313,7 +313,7 @@ static inline IppiMaskSize ippiGetMaskSize(int kx, int ky) (IppiMaskSize)-1; } -static inline IppDataType ippiGetDataType(int depth) +static inline IppDataType ippiGetDataType(ElemType depth) { depth = CV_MAT_DEPTH(depth); return depth == CV_8U ? ipp8u : diff --git a/modules/core/include/opencv2/core/traits.hpp b/modules/core/include/opencv2/core/traits.hpp index 52ab083ca43d..73c0ad33cae7 100644 --- a/modules/core/include/opencv2/core/traits.hpp +++ b/modules/core/include/opencv2/core/traits.hpp @@ -77,7 +77,11 @@ DataType itself that is used but its specialized versions, such as: typedef uchar value_type; typedef int work_type; typedef uchar channel_type; - enum { channel_type = CV_8U, channels = 1, fmt='u', type = CV_8U }; + + static const int channel_type = CV_8U; + static const int channels = 1; + static const int fmt = 'u'; + static const ElemType type = CV_8UC1; }; ... template DataType > @@ -86,9 +90,11 @@ DataType itself that is used but its specialized versions, such as: typedef std::complex<_Tp> work_type; typedef _Tp channel_type; // DataDepth is another helper trait class - enum { depth = DataDepth<_Tp>::value, channels=2, - fmt=(channels-1)*256+DataDepth<_Tp>::fmt, - type=CV_MAKETYPE(depth, channels) }; + + static const ElemType depth = DataDepth<_Tp>::value; + static const int channels = 2; + static const int fmt = (channels-1)*256 + DataDepth<_Tp>::fmt; + static const ElemType type = CV_MAKETYPE(depth, channels); }; ... @endcode @@ -117,12 +123,12 @@ template class DataType typedef value_type work_type; typedef value_type channel_type; typedef value_type vec_type; - enum { generic_type = 1, - depth = -1, - channels = 1, - fmt = 0, - type = CV_MAKETYPE(depth, channels) - }; + + static const bool generic_type = true; + static const ElemType depth = CV_TYPE_AUTO; + static const int channels = 1; + static const int fmt = 0; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif }; @@ -133,12 +139,12 @@ template<> class DataType typedef int work_type; typedef value_type channel_type; typedef value_type vec_type; - enum { generic_type = 0, - depth = CV_8U, - channels = 1, - fmt = (int)'u', - type = CV_MAKETYPE(depth, channels) - }; + + static const bool generic_type = false; + static const ElemType depth = CV_8U; + static const int channels = 1; + static const int fmt = (int)'u'; + static const ElemType type = CV_MAKETYPE(depth, channels); }; template<> class DataType @@ -148,12 +154,12 @@ template<> class DataType typedef int work_type; typedef value_type channel_type; typedef value_type vec_type; - enum { generic_type = 0, - depth = CV_8U, - channels = 1, - fmt = (int)'u', - type = CV_MAKETYPE(depth, channels) - }; + + static const bool generic_type = false; + static const ElemType depth = CV_8U; + static const int channels = 1; + static const int fmt = (int)'u'; + static const ElemType type = CV_MAKETYPE(depth, channels); }; template<> class DataType @@ -163,12 +169,12 @@ template<> class DataType typedef int work_type; typedef value_type channel_type; typedef value_type vec_type; - enum { generic_type = 0, - depth = CV_8S, - channels = 1, - fmt = (int)'c', - type = CV_MAKETYPE(depth, channels) - }; + + static const bool generic_type = false; + static const ElemType depth = CV_8S; + static const int channels = 1; + static const int fmt = (int)'c'; + static const ElemType type = CV_MAKETYPE(depth, channels); }; template<> class DataType @@ -178,12 +184,12 @@ template<> class DataType typedef int work_type; typedef value_type channel_type; typedef value_type vec_type; - enum { generic_type = 0, - depth = CV_8S, - channels = 1, - fmt = (int)'c', - type = CV_MAKETYPE(depth, channels) - }; + + static const bool generic_type = false; + static const ElemType depth = CV_8S; + static const int channels = 1; + static const int fmt = (int)'c'; + static const ElemType type = CV_MAKETYPE(depth, channels); }; template<> class DataType @@ -193,12 +199,12 @@ template<> class DataType typedef int work_type; typedef value_type channel_type; typedef value_type vec_type; - enum { generic_type = 0, - depth = CV_16U, - channels = 1, - fmt = (int)'w', - type = CV_MAKETYPE(depth, channels) - }; + + static const bool generic_type = false; + static const ElemType depth = CV_16U; + static const int channels = 1; + static const int fmt = (int)'w'; + static const ElemType type = CV_MAKETYPE(depth, channels); }; template<> class DataType @@ -208,12 +214,12 @@ template<> class DataType typedef int work_type; typedef value_type channel_type; typedef value_type vec_type; - enum { generic_type = 0, - depth = CV_16S, - channels = 1, - fmt = (int)'s', - type = CV_MAKETYPE(depth, channels) - }; + + static const bool generic_type = false; + static const ElemType depth = CV_16S; + static const int channels = 1; + static const int fmt = (int)'s'; + static const ElemType type = CV_MAKETYPE(depth, channels); }; template<> class DataType @@ -223,12 +229,12 @@ template<> class DataType typedef value_type work_type; typedef value_type channel_type; typedef value_type vec_type; - enum { generic_type = 0, - depth = CV_32S, - channels = 1, - fmt = (int)'i', - type = CV_MAKETYPE(depth, channels) - }; + + static const bool generic_type = false; + static const ElemType depth = CV_32S; + static const int channels = 1; + static const int fmt = (int)'i'; + static const ElemType type = CV_MAKETYPE(depth, channels); }; template<> class DataType @@ -238,12 +244,12 @@ template<> class DataType typedef value_type work_type; typedef value_type channel_type; typedef value_type vec_type; - enum { generic_type = 0, - depth = CV_32F, - channels = 1, - fmt = (int)'f', - type = CV_MAKETYPE(depth, channels) - }; + + static const bool generic_type = false; + static const ElemType depth = CV_32F; + static const int channels = 1; + static const int fmt = (int)'f'; + static const ElemType type = CV_MAKETYPE(depth, channels); }; template<> class DataType @@ -253,12 +259,12 @@ template<> class DataType typedef value_type work_type; typedef value_type channel_type; typedef value_type vec_type; - enum { generic_type = 0, - depth = CV_64F, - channels = 1, - fmt = (int)'d', - type = CV_MAKETYPE(depth, channels) - }; + + static const bool generic_type = false; + static const ElemType depth = CV_64F; + static const int channels = 1; + static const int fmt = (int)'d'; + static const ElemType type = CV_MAKETYPE(depth, channels); }; template<> class DataType @@ -284,11 +290,8 @@ DataDepth::value constant. template class DataDepth { public: - enum - { - value = DataType<_Tp>::depth, - fmt = DataType<_Tp>::fmt - }; + static const ElemType value = DataType<_Tp>::depth; + static const int fmt = DataType<_Tp>::fmt; }; @@ -379,11 +382,11 @@ CV_CREATE_MEMBER_CHECK(type) template struct Depth -{ enum { value = DataType::depth }; }; +{ static const ElemType value = DataType::depth; }; template struct Type -{ enum { value = DataType::type }; }; +{ static const ElemType value = DataType::type; }; /** Similar to traits::Type but has value = -1 in case of unknown type (instead of compiler error) */ template >::value > diff --git a/modules/core/include/opencv2/core/types.hpp b/modules/core/include/opencv2/core/types.hpp index 3aabfa138df3..048100bdedda 100644 --- a/modules/core/include/opencv2/core/types.hpp +++ b/modules/core/include/opencv2/core/types.hpp @@ -97,23 +97,22 @@ template class DataType< Complex<_Tp> > typedef value_type work_type; typedef _Tp channel_type; - enum { generic_type = 0, - channels = 2, - fmt = DataType::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = 2; + static const int fmt = DataType::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemType depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; typedef Vec vec_type; }; namespace traits { template -struct Depth< Complex<_Tp> > { enum { value = Depth<_Tp>::value }; }; +struct Depth< Complex<_Tp> > { static const ElemType value = Depth<_Tp>::value; }; template -struct Type< Complex<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 2) }; }; +struct Type< Complex<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 2); }; } // namespace @@ -200,23 +199,22 @@ template class DataType< Point_<_Tp> > typedef Point_::work_type> work_type; typedef _Tp channel_type; - enum { generic_type = 0, - channels = 2, - fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = 2; + static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemType depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; typedef Vec vec_type; }; namespace traits { template -struct Depth< Point_<_Tp> > { enum { value = Depth<_Tp>::value }; }; +struct Depth< Point_<_Tp> > { static const ElemType value = Depth<_Tp>::value; }; template -struct Type< Point_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 2) }; }; +struct Type< Point_<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 2); }; } // namespace @@ -278,23 +276,22 @@ template class DataType< Point3_<_Tp> > typedef Point3_::work_type> work_type; typedef _Tp channel_type; - enum { generic_type = 0, - channels = 3, - fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = 3; + static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemType depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; typedef Vec vec_type; }; namespace traits { template -struct Depth< Point3_<_Tp> > { enum { value = Depth<_Tp>::value }; }; +struct Depth< Point3_<_Tp> > { static const ElemType value = Depth<_Tp>::value; }; template -struct Type< Point3_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 3) }; }; +struct Type< Point3_<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 3); }; } // namespace //////////////////////////////// Size_ //////////////////////////////// @@ -353,23 +350,22 @@ template class DataType< Size_<_Tp> > typedef Size_::work_type> work_type; typedef _Tp channel_type; - enum { generic_type = 0, - channels = 2, - fmt = DataType::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = 2; + static const int fmt = DataType::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemType depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; typedef Vec vec_type; }; namespace traits { template -struct Depth< Size_<_Tp> > { enum { value = Depth<_Tp>::value }; }; +struct Depth< Size_<_Tp> > { static const ElemType value = Depth<_Tp>::value; }; template -struct Type< Size_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 2) }; }; +struct Type< Size_<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 2); }; } // namespace //////////////////////////////// Rect_ //////////////////////////////// @@ -468,23 +464,22 @@ template class DataType< Rect_<_Tp> > typedef Rect_::work_type> work_type; typedef _Tp channel_type; - enum { generic_type = 0, - channels = 4, - fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = 4; + static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemType depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; typedef Vec vec_type; }; namespace traits { template -struct Depth< Rect_<_Tp> > { enum { value = Depth<_Tp>::value }; }; +struct Depth< Rect_<_Tp> > { static const ElemType value = Depth<_Tp>::value; }; template -struct Type< Rect_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 4) }; }; +struct Type< Rect_<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 4); }; } // namespace ///////////////////////////// RotatedRect ///////////////////////////// @@ -541,23 +536,22 @@ template<> class DataType< RotatedRect > typedef value_type work_type; typedef float channel_type; - enum { generic_type = 0, - channels = (int)sizeof(value_type)/sizeof(channel_type), // 5 - fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = (int)sizeof(value_type) / sizeof(channel_type); // 5 + static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemType depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; typedef Vec vec_type; }; namespace traits { template<> -struct Depth< RotatedRect > { enum { value = Depth::value }; }; +struct Depth< RotatedRect > { static const ElemType value = Depth::value; }; template<> -struct Type< RotatedRect > { enum { value = CV_MAKETYPE(Depth::value, (int)sizeof(RotatedRect)/sizeof(float)) }; }; +struct Type< RotatedRect > { static const ElemType value = CV_MAKETYPE(Depth::value, (int)sizeof(RotatedRect)/sizeof(float)); }; } // namespace @@ -605,23 +599,22 @@ template<> class DataType typedef value_type work_type; typedef int channel_type; - enum { generic_type = 0, - channels = 2, - fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = 2; + static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemType depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; typedef Vec vec_type; }; namespace traits { template<> -struct Depth< Range > { enum { value = Depth::value }; }; +struct Depth< Range > { static const ElemType value = Depth::value; }; template<> -struct Type< Range > { enum { value = CV_MAKETYPE(Depth::value, 2) }; }; +struct Type< Range > { static const ElemType value = CV_MAKETYPE(Depth::value, 2); }; } // namespace @@ -675,23 +668,22 @@ template class DataType< Scalar_<_Tp> > typedef Scalar_::work_type> work_type; typedef _Tp channel_type; - enum { generic_type = 0, - channels = 4, - fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = 4; + static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemType depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; typedef Vec vec_type; }; namespace traits { template -struct Depth< Scalar_<_Tp> > { enum { value = Depth<_Tp>::value }; }; +struct Depth< Scalar_<_Tp> > { static const ElemType value = Depth<_Tp>::value; }; template -struct Type< Scalar_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 4) }; }; +struct Type< Scalar_<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 4); }; } // namespace @@ -786,12 +778,11 @@ template<> class DataType typedef float work_type; typedef float channel_type; - enum { generic_type = 0, - depth = DataType::depth, - channels = (int)(sizeof(value_type)/sizeof(channel_type)), // 7 - fmt = DataType::fmt + ((channels - 1) << 8), - type = CV_MAKETYPE(depth, channels) - }; + static const bool generic_type = false; + static const ElemType depth = DataType::depth; + static const int channels = (int)(sizeof(value_type)/sizeof(channel_type)); // 7 + static const int fmt = DataType::fmt + ((channels - 1) << 8); + static const ElemType type = CV_MAKETYPE(depth, channels); typedef Vec vec_type; }; @@ -830,12 +821,11 @@ template<> class DataType typedef int work_type; typedef int channel_type; - enum { generic_type = 0, - depth = DataType::depth, - channels = (int)(sizeof(value_type)/sizeof(channel_type)), // 4 - fmt = DataType::fmt + ((channels - 1) << 8), - type = CV_MAKETYPE(depth, channels) - }; + static const bool generic_type = false; + static const ElemType depth = DataType::depth; + static const int channels = (int)(sizeof(value_type)/sizeof(channel_type)); // 4 + static const int fmt = DataType::fmt + ((channels - 1) << 8); + static const ElemType type = CV_MAKETYPE(depth, channels); typedef Vec vec_type; }; @@ -959,23 +949,22 @@ template<> class DataType typedef double work_type; typedef double channel_type; - enum { generic_type = 0, - channels = (int)(sizeof(value_type)/sizeof(channel_type)), // 24 - fmt = DataType::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = (int)(sizeof(value_type) / sizeof(channel_type)); // 24 + static const int fmt = DataType::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemType depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; typedef Vec vec_type; }; namespace traits { template<> -struct Depth< Moments > { enum { value = Depth::value }; }; +struct Depth< Moments > { static const ElemType value = Depth::value; }; template<> -struct Type< Moments > { enum { value = CV_MAKETYPE(Depth::value, (int)(sizeof(Moments)/sizeof(double))) }; }; +struct Type< Moments > { static const ElemType value = CV_MAKETYPE(Depth::value, (int)(sizeof(Moments)/sizeof(double))); }; } // namespace //! @} imgproc_shape diff --git a/modules/core/include/opencv2/core/types_c.h b/modules/core/include/opencv2/core/types_c.h index f745db93d1a3..f2e2a70f2de5 100644 --- a/modules/core/include/opencv2/core/types_c.h +++ b/modules/core/include/opencv2/core/types_c.h @@ -546,7 +546,7 @@ CV_INLINE CvMat cvMat( int rows, int cols, int type, void* data CV_DEFAULT(NULL) { CvMat m; - assert( (unsigned)CV_MAT_DEPTH(type) <= CV_64F ); + assert((unsigned)CV_MAT_DEPTH(type) <= (unsigned)CV_64F); type = CV_MAT_TYPE(type); m.type = CV_MAT_MAGIC_VAL | CV_MAT_CONT_FLAG | type; m.cols = cols; @@ -567,7 +567,7 @@ CV_INLINE CvMat cvMat(const cv::Mat& m) CV_DbgAssert(m.dims <= 2); self = cvMat(m.rows, m.dims == 1 ? 1 : m.cols, m.type(), m.data); self.step = (int)m.step[0]; - self.type = (self.type & ~cv::Mat::CONTINUOUS_FLAG) | (m.flags & cv::Mat::CONTINUOUS_FLAG); + self.type = (self.type & static_cast(~cv::Mat::CONTINUOUS_FLAG)) | (m.flags & static_cast(cv::Mat::CONTINUOUS_FLAG)); return self; } CV_INLINE CvMat cvMat() @@ -656,7 +656,7 @@ CV_INLINE void cvmSet( CvMat* mat, int row, int col, double value ) CV_INLINE int cvIplDepth( int type ) { - int depth = CV_MAT_DEPTH(type); + ElemType depth = CV_MAT_DEPTH(type); return CV_ELEM_SIZE1(depth)*8 | (depth == CV_8S || depth == CV_16S || depth == CV_32S ? IPL_DEPTH_SIGN : 0); } @@ -1705,7 +1705,6 @@ typedef CvContour CvPoint2DSeq; #define CV_SEQ_ELTYPE_POINT CV_32SC2 /**< (x,y) */ #define CV_SEQ_ELTYPE_CODE CV_8UC1 /**< freeman code: 0..7 */ #define CV_SEQ_ELTYPE_GENERIC 0 -#define CV_SEQ_ELTYPE_PTR CV_MAKE_TYPE(CV_8U, 8 /*sizeof(void*)*/) #define CV_SEQ_ELTYPE_PPOINT CV_SEQ_ELTYPE_PTR /**< &(x,y) */ #define CV_SEQ_ELTYPE_INDEX CV_32SC1 /**< #(x,y) */ #define CV_SEQ_ELTYPE_GRAPH_EDGE 0 /**< &next_o, &next_d, &vtx_o, &vtx_d */ diff --git a/modules/core/misc/java/src/cpp/core_manual.hpp b/modules/core/misc/java/src/cpp/core_manual.hpp index 82d460fa5341..2329bd1cbf11 100644 --- a/modules/core/misc/java/src/cpp/core_manual.hpp +++ b/modules/core/misc/java/src/cpp/core_manual.hpp @@ -13,13 +13,13 @@ CV_EXPORTS_W void setErrorVerbosity(bool verbose); namespace cv { -CV_EXPORTS_W void add(InputArray src1, Scalar src2, OutputArray dst, InputArray mask=noArray(), int dtype=-1); +CV_EXPORTS_W void add(InputArray src1, Scalar src2, OutputArray dst, InputArray mask=noArray(), ElemType ddepth = CV_TYPE_AUTO); -CV_EXPORTS_W void subtract(InputArray src1, Scalar src2, OutputArray dst, InputArray mask=noArray(), int dtype=-1); +CV_EXPORTS_W void subtract(InputArray src1, Scalar src2, OutputArray dst, InputArray mask=noArray(), ElemType ddepth = CV_TYPE_AUTO); -CV_EXPORTS_W void multiply(InputArray src1, Scalar src2, OutputArray dst, double scale=1, int dtype=-1); +CV_EXPORTS_W void multiply(InputArray src1, Scalar src2, OutputArray dst, double scale=1, ElemType ddepth = CV_TYPE_AUTO); -CV_EXPORTS_W void divide(InputArray src1, Scalar src2, OutputArray dst, double scale=1, int dtype=-1); +CV_EXPORTS_W void divide(InputArray src1, Scalar src2, OutputArray dst, double scale=1, ElemType ddepth = CV_TYPE_AUTO); CV_EXPORTS_W void absdiff(InputArray src1, Scalar src2, OutputArray dst); diff --git a/modules/core/misc/python/pyopencv_core.hpp b/modules/core/misc/python/pyopencv_core.hpp index 9017a5beccda..28c11ced08b4 100644 --- a/modules/core/misc/python/pyopencv_core.hpp +++ b/modules/core/misc/python/pyopencv_core.hpp @@ -1,30 +1,10 @@ #ifdef HAVE_OPENCV_CORE -#include "opencv2/core/cuda.hpp" +#include "opencv2/core.hpp" -typedef std::vector vector_GpuMat; -typedef cuda::GpuMat::Allocator GpuMat_Allocator; -typedef cuda::HostMem::AllocType HostMem_AllocType; -typedef cuda::Event::CreateFlags Event_CreateFlags; - -CV_PY_TO_CLASS(cuda::GpuMat); -CV_PY_TO_CLASS(cuda::Stream); -CV_PY_TO_CLASS(cuda::Event); -CV_PY_TO_CLASS(cuda::HostMem); - -CV_PY_TO_CLASS_PTR(cuda::GpuMat); -CV_PY_TO_CLASS_PTR(cuda::GpuMat::Allocator); - -CV_PY_TO_ENUM(cuda::Event::CreateFlags); -CV_PY_TO_ENUM(cuda::HostMem::AllocType); -CV_PY_TO_ENUM(cuda::FeatureSet); - -CV_PY_FROM_CLASS(cuda::GpuMat); -CV_PY_FROM_CLASS(cuda::Stream); -CV_PY_FROM_CLASS(cuda::HostMem); - -CV_PY_FROM_CLASS_PTR(cuda::GpuMat::Allocator); - -CV_PY_FROM_ENUM(cuda::DeviceInfo::ComputeMode); +#ifdef CV_TYPE_SAFE_API +CV_PY_FROM_ENUM(ElemType); +CV_PY_TO_ENUM(ElemType); +#endif #endif diff --git a/modules/core/misc/python/pyopencv_cuda.hpp b/modules/core/misc/python/pyopencv_cuda.hpp new file mode 100644 index 000000000000..9017a5beccda --- /dev/null +++ b/modules/core/misc/python/pyopencv_cuda.hpp @@ -0,0 +1,30 @@ +#ifdef HAVE_OPENCV_CORE + +#include "opencv2/core/cuda.hpp" + +typedef std::vector vector_GpuMat; +typedef cuda::GpuMat::Allocator GpuMat_Allocator; +typedef cuda::HostMem::AllocType HostMem_AllocType; +typedef cuda::Event::CreateFlags Event_CreateFlags; + +CV_PY_TO_CLASS(cuda::GpuMat); +CV_PY_TO_CLASS(cuda::Stream); +CV_PY_TO_CLASS(cuda::Event); +CV_PY_TO_CLASS(cuda::HostMem); + +CV_PY_TO_CLASS_PTR(cuda::GpuMat); +CV_PY_TO_CLASS_PTR(cuda::GpuMat::Allocator); + +CV_PY_TO_ENUM(cuda::Event::CreateFlags); +CV_PY_TO_ENUM(cuda::HostMem::AllocType); +CV_PY_TO_ENUM(cuda::FeatureSet); + +CV_PY_FROM_CLASS(cuda::GpuMat); +CV_PY_FROM_CLASS(cuda::Stream); +CV_PY_FROM_CLASS(cuda::HostMem); + +CV_PY_FROM_CLASS_PTR(cuda::GpuMat::Allocator); + +CV_PY_FROM_ENUM(cuda::DeviceInfo::ComputeMode); + +#endif diff --git a/modules/core/misc/python/shadow_umat.hpp b/modules/core/misc/python/shadow_umat.hpp index 39ffef1d4712..dd3a88ad5b14 100644 --- a/modules/core/misc/python/shadow_umat.hpp +++ b/modules/core/misc/python/shadow_umat.hpp @@ -11,11 +11,11 @@ class CV_EXPORTS_W UMat CV_WRAP UMat(UMatUsageFlags usageFlags = USAGE_DEFAULT); //! constructs 2D matrix of the specified size and type // (_type is CV_8UC1, CV_64FC3, CV_32SC(12) etc.) - CV_WRAP UMat(int rows, int cols, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); - CV_WRAP UMat(Size size, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + CV_WRAP UMat(int rows, int cols, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + CV_WRAP UMat(Size size, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); //! constucts 2D matrix and fills it with the specified value _s. - CV_WRAP UMat(int rows, int cols, int type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); - CV_WRAP UMat(Size size, int type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); + CV_WRAP UMat(int rows, int cols, ElemType type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); + CV_WRAP UMat(Size size, ElemType type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); //! Mat is mappable to UMat CV_WRAP_MAPPABLE(Ptr); diff --git a/modules/core/perf/perf_merge.cpp b/modules/core/perf/perf_merge.cpp index e10642dcb493..7af9625bbc10 100644 --- a/modules/core/perf/perf_merge.cpp +++ b/modules/core/perf/perf_merge.cpp @@ -25,7 +25,7 @@ PERF_TEST_P( Size_SrcDepth_DstChannels, merge, vector mv; for( int i = 0; i < dstChannels; ++i ) { - mv.push_back( Mat(sz, CV_MAKETYPE(srcDepth, 1)) ); + mv.push_back( Mat(sz, srcDepth) ); randu(mv[i], 0, maxValue); } diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp index ce943e0ffb57..db00ca789674 100644 --- a/modules/core/src/arithm.cpp +++ b/modules/core/src/arithm.cpp @@ -61,7 +61,7 @@ void convertAndUnrollScalar( const Mat& sc, int buftype, uchar* scbuf, size_t bl { int scn = (int)sc.total(), cn = CV_MAT_CN(buftype); size_t esz = CV_ELEM_SIZE(buftype); - getConvertFunc(sc.depth(), buftype)(sc.ptr(), 1, 0, 1, scbuf, 1, Size(std::min(cn, scn), 1), 0); + getConvertFunc(sc.depth(), CV_MAT_DEPTH(buftype))(sc.ptr(), 1, 0, 1, scbuf, 1, Size(std::min(cn, scn), 1), 0); // unroll the scalar if( scn < cn ) { @@ -91,7 +91,7 @@ static bool ocl_binary_op(InputArray _src1, InputArray _src2, OutputArray _dst, { bool haveMask = !_mask.empty(); int srctype = _src1.type(); - int srcdepth = CV_MAT_DEPTH(srctype); + ElemType srcdepth = CV_MAT_DEPTH(srctype); int cn = CV_MAT_CN(srctype); const ocl::Device d = ocl::Device::getDefault(); @@ -109,8 +109,8 @@ static bool ocl_binary_op(InputArray _src1, InputArray _src2, OutputArray _dst, haveMask ? "MASK_" : "", haveScalar ? "UNARY_OP" : "BINARY_OP", oclop2str[oclop], bitwise ? ocl::memopTypeToStr(CV_MAKETYPE(srcdepth, kercn)) : ocl::typeToStr(CV_MAKETYPE(srcdepth, kercn)), doubleSupport ? " -D DOUBLE_SUPPORT" : "", - bitwise ? ocl::memopTypeToStr(CV_MAKETYPE(srcdepth, 1)) : - ocl::typeToStr(CV_MAKETYPE(srcdepth, 1)), + bitwise ? ocl::memopTypeToStr(srcdepth) : + ocl::typeToStr(srcdepth), bitwise ? ocl::memopTypeToStr(CV_MAKETYPE(srcdepth, scalarcn)) : ocl::typeToStr(CV_MAKETYPE(srcdepth, scalarcn)), kercn, rowsPerWI); @@ -168,8 +168,12 @@ static void binary_op( InputArray _src1, InputArray _src2, OutputArray _dst, { const _InputArray *psrc1 = &_src1, *psrc2 = &_src2; _InputArray::KindFlag kind1 = psrc1->kind(), kind2 = psrc2->kind(); - int type1 = psrc1->type(), depth1 = CV_MAT_DEPTH(type1), cn = CV_MAT_CN(type1); - int type2 = psrc2->type(), depth2 = CV_MAT_DEPTH(type2), cn2 = CV_MAT_CN(type2); + ElemType type1 = psrc1->type(); + ElemType depth1 = CV_MAT_DEPTH(type1); + int cn = CV_MAT_CN(type1); + ElemType type2 = psrc2->type(); + ElemType depth2 = CV_MAT_DEPTH(type2); + int cn2 = CV_MAT_CN(type2); int dims1 = psrc1->dims(), dims2 = psrc2->dims(); Size sz1 = dims1 <= 2 ? psrc1->size() : Size(); Size sz2 = dims2 <= 2 ? psrc2->size() : Size(); @@ -453,7 +457,7 @@ void cv::min(const UMat& src1, const UMat& src2, UMat& dst) namespace cv { -static int actualScalarDepth(const double* data, int len) +static ElemType actualScalarDepth(const double* data, int len) { int i = 0, minval = INT_MAX, maxval = INT_MIN; for(; i < len; ++i) @@ -475,24 +479,29 @@ static int actualScalarDepth(const double* data, int len) #ifdef HAVE_OPENCL static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, - InputArray _mask, int wtype, + InputArray _mask, ElemType wtype, void* usrdata, int oclop, bool haveScalar ) { const ocl::Device d = ocl::Device::getDefault(); bool doubleSupport = d.doubleFPConfig() > 0; - int type1 = _src1.type(), depth1 = CV_MAT_DEPTH(type1), cn = CV_MAT_CN(type1); + ElemType type1 = _src1.type(); + ElemType depth1 = CV_MAT_DEPTH(type1); + int cn = CV_MAT_CN(type1); bool haveMask = !_mask.empty(); if ( (haveMask || haveScalar) && cn > 4 ) return false; - int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype), wdepth = std::max(CV_32S, CV_MAT_DEPTH(wtype)); + ElemType dtype = _dst.type(); + ElemType ddepth = CV_MAT_DEPTH(dtype); + ElemType wdepth = CV_MAX_DEPTH(CV_32S, CV_MAT_DEPTH(wtype)); if (!doubleSupport) - wdepth = std::min(wdepth, CV_32F); + wdepth = CV_MIN_DEPTH(wdepth, CV_32F); wtype = CV_MAKETYPE(wdepth, cn); - int type2 = haveScalar ? wtype : _src2.type(), depth2 = CV_MAT_DEPTH(type2); + ElemType type2 = haveScalar ? wtype : _src2.type(); + ElemType depth2 = CV_MAT_DEPTH(type2); if (!doubleSupport && (depth2 == CV_64F || depth1 == CV_64F)) return false; @@ -596,16 +605,21 @@ static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, #endif static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, - InputArray _mask, int dtype, BinaryFuncC* tab, bool muldiv=false, + InputArray _mask, ElemType ddepth, BinaryFuncC* tab, bool muldiv=false, void* usrdata=0, int oclop=-1 ) { const _InputArray *psrc1 = &_src1, *psrc2 = &_src2; _InputArray::KindFlag kind1 = psrc1->kind(), kind2 = psrc2->kind(); bool haveMask = !_mask.empty(); bool reallocate = false; - int type1 = psrc1->type(), depth1 = CV_MAT_DEPTH(type1), cn = CV_MAT_CN(type1); - int type2 = psrc2->type(), depth2 = CV_MAT_DEPTH(type2), cn2 = CV_MAT_CN(type2); - int wtype, dims1 = psrc1->dims(), dims2 = psrc2->dims(); + ElemType type1 = psrc1->type(); + ElemType depth1 = CV_MAT_DEPTH(type1); + int cn = CV_MAT_CN(type1); + ElemType type2 = psrc2->type(); + ElemType depth2 = CV_MAT_DEPTH(type2); + int cn2 = CV_MAT_CN(type2); + ElemType wtype; + int dims1 = psrc1->dims(), dims2 = psrc2->dims(); Size sz1 = dims1 <= 2 ? psrc1->size() : Size(); Size sz2 = dims2 <= 2 ? psrc2->size() : Size(); #ifdef HAVE_OPENCL @@ -615,14 +629,14 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, bool src2Scalar = checkScalar(*psrc2, type1, kind2, kind1); if( (kind1 == kind2 || cn == 1) && sz1 == sz2 && dims1 <= 2 && dims2 <= 2 && type1 == type2 && - !haveMask && ((!_dst.fixedType() && (dtype < 0 || CV_MAT_DEPTH(dtype) == depth1)) || + !haveMask && ((!_dst.fixedType() && (ddepth == CV_TYPE_AUTO || ddepth == depth1)) || (_dst.fixedType() && _dst.type() == type1)) && (src1Scalar == src2Scalar) ) { _dst.createSameSize(*psrc1, type1); CV_OCL_RUN(use_opencl, ocl_arithm_op(*psrc1, *psrc2, _dst, _mask, - (!usrdata ? type1 : std::max(depth1, CV_32F)), + (!usrdata ? type1 : CV_MAKE_TYPE(CV_MAX_DEPTH(depth1, CV_32F), 1)), usrdata, oclop, false)) Mat src1 = psrc1->getMat(), src2 = psrc2->getMat(), dst = _dst.getMat(); @@ -671,28 +685,23 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, depth2 = CV_64F; } - if( dtype < 0 ) + if (ddepth == CV_TYPE_AUTO && !_dst.fixedType() && !haveScalar && type1 != type2) { - if( _dst.fixedType() ) - dtype = _dst.type(); - else - { - if( !haveScalar && type1 != type2 ) - CV_Error(CV_StsBadArg, - "When the input arrays in add/subtract/multiply/divide functions have different types, " - "the output array type must be explicitly specified"); - dtype = type1; - } + CV_Error(CV_StsBadArg, + "When the input arrays in add/subtract/multiply/divide functions have different types, " + "the output array type must be explicitly specified"); } - dtype = CV_MAT_DEPTH(dtype); + if (ddepth == CV_TYPE_AUTO) + ddepth = _dst.fixedType() ? _dst.depth() : CV_MAT_DEPTH(type1); + ElemType dtype = CV_MAKETYPE(ddepth, 1); - if( depth1 == depth2 && dtype == depth1 ) + if (depth1 == depth2 && ddepth == depth1) wtype = dtype; else if( !muldiv ) { wtype = depth1 <= CV_8S && depth2 <= CV_8S ? CV_16S : - depth1 <= CV_32S && depth2 <= CV_32S ? CV_32S : std::max(depth1, depth2); - wtype = std::max(wtype, dtype); + depth1 <= CV_32S && depth2 <= CV_32S ? CV_32S : CV_MAX_DEPTH(depth1, depth2); + wtype = CV_MAX_DEPTH(wtype, dtype); // when the result of addition should be converted to an integer type, // and just one of the input arrays is floating-point, it makes sense to convert that input to integer type before the operation, @@ -702,16 +711,16 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, } else { - wtype = std::max(depth1, std::max(depth2, CV_32F)); - wtype = std::max(wtype, dtype); + wtype = CV_MAKETYPE(CV_MAX_DEPTH(depth1, depth2, CV_32F), 1); + wtype = CV_MAKETYPE(CV_MAX_DEPTH(wtype, ddepth), 1); } - dtype = CV_MAKETYPE(dtype, cn); + dtype = CV_MAKETYPE(ddepth, cn); wtype = CV_MAKETYPE(wtype, cn); if( haveMask ) { - int mtype = _mask.type(); + ElemType mtype = _mask.type(); CV_Assert( (mtype == CV_8UC1 || mtype == CV_8SC1) && _mask.sameSize(*psrc1) ); reallocate = !_dst.sameSize(*psrc1) || _dst.type() != dtype; } @@ -724,9 +733,9 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, ocl_arithm_op(*psrc1, *psrc2, _dst, _mask, wtype, usrdata, oclop, haveScalar)) - BinaryFunc cvtsrc1 = type1 == wtype ? 0 : getConvertFunc(type1, wtype); - BinaryFunc cvtsrc2 = type2 == type1 ? cvtsrc1 : type2 == wtype ? 0 : getConvertFunc(type2, wtype); - BinaryFunc cvtdst = dtype == wtype ? 0 : getConvertFunc(wtype, dtype); + BinaryFunc cvtsrc1 = type1 == wtype ? 0 : getConvertFunc(CV_MAT_DEPTH(type1), CV_MAT_DEPTH(wtype)); + BinaryFunc cvtsrc2 = type2 == type1 ? cvtsrc1 : type2 == wtype ? 0 : getConvertFunc(CV_MAT_DEPTH(type2), CV_MAT_DEPTH(wtype)); + BinaryFunc cvtdst = dtype == wtype ? 0 : getConvertFunc(CV_MAT_DEPTH(wtype), ddepth); size_t esz1 = CV_ELEM_SIZE(type1), esz2 = CV_ELEM_SIZE(type2); size_t dsz = CV_ELEM_SIZE(dtype), wsz = CV_ELEM_SIZE(wtype); @@ -919,26 +928,26 @@ static BinaryFuncC* getAbsDiffTab() } void cv::add( InputArray src1, InputArray src2, OutputArray dst, - InputArray mask, int dtype ) + InputArray mask, ElemType ddepth ) { CV_INSTRUMENT_REGION(); - arithm_op(src1, src2, dst, mask, dtype, getAddTab(), false, 0, OCL_OP_ADD ); + arithm_op(src1, src2, dst, mask, ddepth, getAddTab(), false, 0, OCL_OP_ADD ); } void cv::subtract( InputArray _src1, InputArray _src2, OutputArray _dst, - InputArray mask, int dtype ) + InputArray mask, ElemType ddepth ) { CV_INSTRUMENT_REGION(); - arithm_op(_src1, _src2, _dst, mask, dtype, getSubTab(), false, 0, OCL_OP_SUB ); + arithm_op(_src1, _src2, _dst, mask, ddepth, getSubTab(), false, 0, OCL_OP_SUB ); } void cv::absdiff( InputArray src1, InputArray src2, OutputArray dst ) { CV_INSTRUMENT_REGION(); - arithm_op(src1, src2, dst, noArray(), -1, getAbsDiffTab(), false, 0, OCL_OP_ABSDIFF); + arithm_op(src1, src2, dst, noArray(), CV_TYPE_AUTO, getAbsDiffTab(), false, 0, OCL_OP_ABSDIFF); } /****************************************************************************************\ @@ -987,28 +996,28 @@ static BinaryFuncC* getRecipTab() } void cv::multiply(InputArray src1, InputArray src2, - OutputArray dst, double scale, int dtype) + OutputArray dst, double scale, ElemType ddepth) { CV_INSTRUMENT_REGION(); - arithm_op(src1, src2, dst, noArray(), dtype, getMulTab(), + arithm_op(src1, src2, dst, noArray(), ddepth, getMulTab(), true, &scale, std::abs(scale - 1.0) < DBL_EPSILON ? OCL_OP_MUL : OCL_OP_MUL_SCALE); } void cv::divide(InputArray src1, InputArray src2, - OutputArray dst, double scale, int dtype) + OutputArray dst, double scale, ElemType ddepth) { CV_INSTRUMENT_REGION(); - arithm_op(src1, src2, dst, noArray(), dtype, getDivTab(), true, &scale, OCL_OP_DIV_SCALE); + arithm_op(src1, src2, dst, noArray(), ddepth, getDivTab(), true, &scale, OCL_OP_DIV_SCALE); } void cv::divide(double scale, InputArray src2, - OutputArray dst, int dtype) + OutputArray dst, ElemType ddepth) { CV_INSTRUMENT_REGION(); - arithm_op(src2, src2, dst, noArray(), dtype, getRecipTab(), true, &scale, OCL_OP_RECIP_SCALE); + arithm_op(src2, src2, dst, noArray(), ddepth, getRecipTab(), true, &scale, OCL_OP_RECIP_SCALE); } /****************************************************************************************\ @@ -1033,12 +1042,12 @@ static BinaryFuncC* getAddWeightedTab() } void cv::addWeighted( InputArray src1, double alpha, InputArray src2, - double beta, double gamma, OutputArray dst, int dtype ) + double beta, double gamma, OutputArray dst, ElemType ddepth ) { CV_INSTRUMENT_REGION(); double scalars[] = {alpha, beta, gamma}; - arithm_op(src1, src2, dst, noArray(), dtype, getAddWeightedTab(), true, scalars, OCL_OP_ADDW); + arithm_op(src1, src2, dst, noArray(), ddepth, getAddWeightedTab(), true, scalars, OCL_OP_ADDW); } @@ -1049,7 +1058,7 @@ void cv::addWeighted( InputArray src1, double alpha, InputArray src2, namespace cv { -static BinaryFuncC getCmpFunc(int depth) +static BinaryFuncC getCmpFunc(ElemType depth) { static BinaryFuncC cmpTab[] = { @@ -1063,13 +1072,13 @@ static BinaryFuncC getCmpFunc(int depth) return cmpTab[depth]; } -static double getMinVal(int depth) +static double getMinVal(ElemType depth) { static const double tab[] = {0, -128, 0, -32768, INT_MIN, -FLT_MAX, -DBL_MAX, 0}; return tab[depth]; } -static double getMaxVal(int depth) +static double getMaxVal(ElemType depth) { static const double tab[] = {255, 127, 65535, 32767, INT_MAX, FLT_MAX, DBL_MAX, 0}; return tab[depth]; @@ -1081,8 +1090,11 @@ static bool ocl_compare(InputArray _src1, InputArray _src2, OutputArray _dst, in { const ocl::Device& dev = ocl::Device::getDefault(); bool doubleSupport = dev.doubleFPConfig() > 0; - int type1 = _src1.type(), depth1 = CV_MAT_DEPTH(type1), cn = CV_MAT_CN(type1), - type2 = _src2.type(), depth2 = CV_MAT_DEPTH(type2); + int type1 = _src1.type(); + ElemType depth1 = CV_MAT_DEPTH(type1); + int cn = CV_MAT_CN(type1); + ElemType type2 = _src2.type(); + ElemType depth2 = CV_MAT_DEPTH(type2); if (!doubleSupport && depth1 == CV_64F) return false; @@ -1227,7 +1239,8 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op) return; } - int cn = src1.channels(), depth1 = src1.depth(), depth2 = src2.depth(); + int cn = src1.channels(); + ElemType depth1 = src1.depth(), depth2 = src2.depth(); _dst.create(src1.dims, src1.size, CV_8UC(cn)); src1 = src1.reshape(1); src2 = src2.reshape(1); @@ -1569,7 +1582,7 @@ static void inRangeReduce(const uchar* src, uchar* dst, size_t len, int cn) typedef void (*InRangeFunc)( const uchar* src1, size_t step1, const uchar* src2, size_t step2, const uchar* src3, size_t step3, uchar* dst, size_t step, Size sz ); -static InRangeFunc getInRangeFunc(int depth) +static InRangeFunc getInRangeFunc(ElemType depth) { static InRangeFunc inRangeTab[] = { @@ -1589,8 +1602,8 @@ static bool ocl_inRange( InputArray _src, InputArray _lowerb, const ocl::Device & d = ocl::Device::getDefault(); _InputArray::KindFlag skind = _src.kind(), lkind = _lowerb.kind(), ukind = _upperb.kind(); Size ssize = _src.size(), lsize = _lowerb.size(), usize = _upperb.size(); - int stype = _src.type(), ltype = _lowerb.type(), utype = _upperb.type(); - int sdepth = CV_MAT_DEPTH(stype), ldepth = CV_MAT_DEPTH(ltype), udepth = CV_MAT_DEPTH(utype); + ElemType stype = _src.type(), ltype = _lowerb.type(), utype = _upperb.type(); + ElemType sdepth = CV_MAT_DEPTH(stype), ldepth = CV_MAT_DEPTH(ltype), udepth = CV_MAT_DEPTH(utype); int cn = CV_MAT_CN(stype), rowsPerWI = d.isIntel() ? 4 : 1; bool lbScalar = false, ubScalar = false; @@ -1658,7 +1671,7 @@ static bool ocl_inRange( InputArray _src, InputArray _lowerb, BinaryFunc sccvtfunc = getConvertFunc(ldepth, CV_32S); sccvtfunc(lscalar.ptr(), 1, 0, 1, (uchar*)ilbuf, 1, Size(cn, 1), 0); sccvtfunc(uscalar.ptr(), 1, 0, 1, (uchar*)iubuf, 1, Size(cn, 1), 0); - int minval = cvRound(getMinVal(sdepth)), maxval = cvRound(getMaxVal(sdepth)); + int minval = cvRound(getMinVal(sdepth)), maxval = cvRound(getMaxVal(sdepth)); for( int k = 0; k < cn; k++ ) { @@ -1737,7 +1750,8 @@ void cv::inRange(InputArray _src, InputArray _lowerb, CV_Assert(lbScalar == ubScalar); - int cn = src.channels(), depth = src.depth(); + int cn = src.channels(); + ElemType depth = src.depth(); size_t esz = src.elemSize(); size_t blocksize0 = (size_t)(BLOCK_SIZE + esz-1)/esz; @@ -1763,7 +1777,7 @@ void cv::inRange(InputArray _src, InputArray _lowerb, ubuf = buf = alignPtr(buf + blocksize*esz, 16); CV_Assert( lb.type() == ub.type() ); - int scdepth = lb.depth(); + ElemType scdepth = lb.depth(); if( scdepth != depth && depth < CV_32S ) { @@ -1773,7 +1787,7 @@ void cv::inRange(InputArray _src, InputArray _lowerb, BinaryFunc sccvtfunc = getConvertFunc(scdepth, CV_32S); sccvtfunc(lb.ptr(), 1, 0, 1, (uchar*)ilbuf, 1, Size(cn, 1), 0); sccvtfunc(ub.ptr(), 1, 0, 1, (uchar*)iubuf, 1, Size(cn, 1), 0); - int minval = cvRound(getMinVal(depth)), maxval = cvRound(getMaxVal(depth)); + int minval = cvRound(getMinVal(depth)), maxval = cvRound(getMaxVal(depth)); for( int k = 0; k < cn; k++ ) { @@ -1904,7 +1918,7 @@ CV_IMPL void cvAdd( const CvArr* srcarr1, const CvArr* srcarr2, CvArr* dstarr, c CV_Assert( src1.size == dst.size && src1.channels() == dst.channels() ); if( maskarr ) mask = cv::cvarrToMat(maskarr); - cv::add( src1, src2, dst, mask, dst.type() ); + cv::add( src1, src2, dst, mask, dst.depth() ); } @@ -1915,7 +1929,7 @@ CV_IMPL void cvSub( const CvArr* srcarr1, const CvArr* srcarr2, CvArr* dstarr, c CV_Assert( src1.size == dst.size && src1.channels() == dst.channels() ); if( maskarr ) mask = cv::cvarrToMat(maskarr); - cv::subtract( src1, src2, dst, mask, dst.type() ); + cv::subtract(src1, src2, dst, mask, dst.depth()); } @@ -1926,7 +1940,7 @@ CV_IMPL void cvAddS( const CvArr* srcarr1, CvScalar value, CvArr* dstarr, const CV_Assert( src1.size == dst.size && src1.channels() == dst.channels() ); if( maskarr ) mask = cv::cvarrToMat(maskarr); - cv::add( src1, (const cv::Scalar&)value, dst, mask, dst.type() ); + cv::add(src1, (const cv::Scalar&)value, dst, mask, dst.depth()); } @@ -1937,7 +1951,7 @@ CV_IMPL void cvSubRS( const CvArr* srcarr1, CvScalar value, CvArr* dstarr, const CV_Assert( src1.size == dst.size && src1.channels() == dst.channels() ); if( maskarr ) mask = cv::cvarrToMat(maskarr); - cv::subtract( (const cv::Scalar&)value, src1, dst, mask, dst.type() ); + cv::subtract((const cv::Scalar&)value, src1, dst, mask, dst.depth()); } @@ -1947,7 +1961,7 @@ CV_IMPL void cvMul( const CvArr* srcarr1, const CvArr* srcarr2, cv::Mat src1 = cv::cvarrToMat(srcarr1), src2 = cv::cvarrToMat(srcarr2), dst = cv::cvarrToMat(dstarr); CV_Assert( src1.size == dst.size && src1.channels() == dst.channels() ); - cv::multiply( src1, src2, dst, scale, dst.type() ); + cv::multiply(src1, src2, dst, scale, dst.depth()); } @@ -1959,9 +1973,9 @@ CV_IMPL void cvDiv( const CvArr* srcarr1, const CvArr* srcarr2, CV_Assert( src2.size == dst.size && src2.channels() == dst.channels() ); if( srcarr1 ) - cv::divide( cv::cvarrToMat(srcarr1), src2, dst, scale, dst.type() ); + cv::divide(cv::cvarrToMat(srcarr1), src2, dst, scale, dst.depth()); else - cv::divide( scale, src2, dst, dst.type() ); + cv::divide(scale, src2, dst, dst.depth()); } @@ -1973,7 +1987,7 @@ cvAddWeighted( const CvArr* srcarr1, double alpha, cv::Mat src1 = cv::cvarrToMat(srcarr1), src2 = cv::cvarrToMat(srcarr2), dst = cv::cvarrToMat(dstarr); CV_Assert( src1.size == dst.size && src1.channels() == dst.channels() ); - cv::addWeighted( src1, alpha, src2, beta, gamma, dst, dst.type() ); + cv::addWeighted(src1, alpha, src2, beta, gamma, dst, dst.depth()); } diff --git a/modules/core/src/array.cpp b/modules/core/src/array.cpp index a1a23ec8d648..70424d8a78af 100644 --- a/modules/core/src/array.cpp +++ b/modules/core/src/array.cpp @@ -54,7 +54,6 @@ /* default image row align (in bytes) */ #define CV_DEFAULT_IMAGE_ROW_ALIGN 4 - static struct { Cv_iplCreateImageHeader createHeader; @@ -94,7 +93,7 @@ cvSetIPLAllocators( Cv_iplCreateImageHeader createHeader, // Creates CvMat and underlying data CV_IMPL CvMat* -cvCreateMat( int height, int width, int type ) +cvCreateMat(int height, int width, int type) { CvMat* arr = cvCreateMatHeader( height, width, type ); cvCreateData( arr ); @@ -111,7 +110,7 @@ static void icvCheckHuge( CvMat* arr ) // Creates CvMat header only CV_IMPL CvMat* -cvCreateMatHeader( int rows, int cols, int type ) +cvCreateMatHeader(int rows, int cols, int type) { type = CV_MAT_TYPE(type); @@ -525,7 +524,7 @@ CV_IMPL int cvNextNArraySlice( CvNArrayIterator* iterator ) // Creates CvMatND and underlying data CV_IMPL CvSparseMat* -cvCreateSparseMat( int dims, const int* sizes, int type ) +cvCreateSparseMat(int dims, const int* sizes, int type) { type = CV_MAT_TYPE( type ); int pix_size1 = CV_ELEM_SIZE1(type); @@ -899,7 +898,7 @@ cvSetData( CvArr* arr, void* data, int step ) { CvMat* mat = (CvMat*)arr; - int type = CV_MAT_TYPE(mat->type); + ElemType type = CV_MAT_TYPE(mat->type); pix_size = CV_ELEM_SIZE(type); min_step = mat->cols*pix_size; @@ -1082,7 +1081,7 @@ cvGetRawData( const CvArr* arr, uchar** data, int* step, CvSize* roi_size ) CV_IMPL int cvGetElemType( const CvArr* arr ) { - int type = -1; + ElemType type = CV_TYPE_AUTO; if( CV_IS_MAT_HDR(arr) || CV_IS_MATND_HDR(arr) || CV_IS_SPARSE_MAT_HDR(arr)) type = CV_MAT_TYPE( ((CvMat*)arr)->type ); else if( CV_IS_IMAGE(arr)) @@ -1377,7 +1376,7 @@ cvGetCols( const CvArr* arr, CvMat* submat, int start_col, int end_col ) submat->cols = end_col - start_col; submat->step = mat->step; submat->data.ptr = mat->data.ptr + (size_t)start_col*CV_ELEM_SIZE(mat->type); - submat->type = mat->type & (submat->rows > 1 && submat->cols < cols ? ~CV_MAT_CONT_FLAG : -1); + submat->type = mat->type & (submat->rows > 1 && submat->cols < cols ? ~CV_MAT_CONT_FLAG : CV_TYPE_AUTO); submat->refcount = 0; submat->hdr_refcount = 0; res = submat; @@ -1454,11 +1453,11 @@ cvGetDiag( const CvArr* arr, CvMat* submat, int diag ) // Converts CvScalar to specified type CV_IMPL void -cvScalarToRawData( const CvScalar* scalar, void* data, int type, int extend_to_12 ) +cvScalarToRawData(const CvScalar* scalar, void* data, int type, int extend_to_12) { type = CV_MAT_TYPE(type); int cn = CV_MAT_CN( type ); - int depth = type & CV_MAT_DEPTH_MASK; + ElemType depth = CV_MAT_DEPTH(type); assert( scalar && data ); if( (unsigned)(cn - 1) >= 4 ) @@ -1600,41 +1599,36 @@ static double icvGetReal( const void* data, int type ) } -static void icvSetReal( double value, const void* data, int type ) +static void icvSetReal(double value, const void* data, int _depth) { - if( type < CV_32F ) - { - int ivalue = cvRound(value); - switch( type ) - { - case CV_8U: - *(uchar*)data = cv::saturate_cast(ivalue); - break; - case CV_8S: - *(schar*)data = cv::saturate_cast(ivalue); - break; - case CV_16U: - *(ushort*)data = cv::saturate_cast(ivalue); - break; - case CV_16S: - *(short*)data = cv::saturate_cast(ivalue); - break; - case CV_32S: - *(int*)data = cv::saturate_cast(ivalue); - break; - } - } - else + ElemType depth = static_cast(_depth); + switch (depth) { - switch( type ) - { - case CV_32F: - *(float*)data = (float)value; - break; - case CV_64F: - *(double*)data = value; - break; - } + case CV_8U: + *(uchar*)data = cv::saturate_cast(cvRound(value)); + break; + case CV_8S: + *(schar*)data = cv::saturate_cast(cvRound(value)); + break; + case CV_16U: + *(ushort*)data = cv::saturate_cast(cvRound(value)); + break; + case CV_16S: + *(short*)data = cv::saturate_cast(cvRound(value)); + break; + case CV_32S: + *(int*)data = cv::saturate_cast(cvRound(value)); + break; + case CV_32F: + *(float*)data = (float)value; + break; + case CV_64F: + *(double*)data = value; + break; + case CV_16F: + break;// unhandled + default: + break;// unhandled } } @@ -1648,7 +1642,7 @@ cvPtr1D( const CvArr* arr, int idx, int* _type ) { CvMat* mat = (CvMat*)arr; - int type = CV_MAT_TYPE(mat->type); + ElemType type = CV_MAT_TYPE(mat->type); int pix_size = CV_ELEM_SIZE(type); if( _type ) @@ -1807,8 +1801,8 @@ cvPtr2D( const CvArr* arr, int y, int x, int* _type ) if( _type ) { - int type = IPL2CV_DEPTH(img->depth); - if( type < 0 || (unsigned)(img->nChannels - 1) > 3 ) + ElemType type = CV_MAKETYPE(IPL2CV_DEPTH(img->depth), 1); + if( type < CV_8UC1 || (unsigned)(img->nChannels - 1) > 3 ) CV_Error( CV_StsUnsupportedFormat, "" ); *_type = CV_MAKETYPE( type, img->nChannels ); @@ -2399,7 +2393,8 @@ cvGetMat( const CvArr* array, CvMat* mat, else if( CV_IS_IMAGE_HDR(src) ) { const IplImage* img = (const IplImage*)src; - int depth, order; + int depth; + int order; if( img->imageData == 0 ) CV_Error( CV_StsNullPtr, "The image has NULL data pointer" ); @@ -2414,7 +2409,7 @@ cvGetMat( const CvArr* array, CvMat* mat, { if( order == IPL_DATA_ORDER_PLANE ) { - int type = depth; + ElemType type = static_cast(depth); if( img->roi->coi == 0 ) CV_Error( CV_StsBadFlag, @@ -2429,7 +2424,7 @@ cvGetMat( const CvArr* array, CvMat* mat, } else /* pixel order */ { - int type = CV_MAKETYPE( depth, img->nChannels ); + ElemType type = CV_MAKETYPE( depth, img->nChannels ); coi = img->roi->coi; if( img->nChannels > CV_CN_MAX ) @@ -2445,7 +2440,7 @@ cvGetMat( const CvArr* array, CvMat* mat, } else { - int type = CV_MAKETYPE( depth, img->nChannels ); + ElemType type = CV_MAKETYPE( depth, img->nChannels ); if( order != IPL_DATA_ORDER_PIXEL ) CV_Error( CV_StsBadFlag, "Pixel order should be used with coi == 0" ); @@ -2802,7 +2797,7 @@ cvGetImage( const CvArr* array, IplImage* img ) if( mat->data.ptr == 0 ) CV_Error( CV_StsNullPtr, "" ); - int depth = cvIplDepth(mat->type); + ElemType depth = static_cast(cvIplDepth(mat->type)); cvInitImageHeader( img, cvSize(mat->cols, mat->rows), depth, CV_MAT_CN(mat->type) ); @@ -2908,7 +2903,7 @@ cvCreateImage( CvSize size, int depth, int channels ) // initialize IplImage header, allocated by the user CV_IMPL IplImage* -cvInitImageHeader( IplImage * image, CvSize size, int depth, +cvInitImageHeader(IplImage * image, CvSize size, int depth, int channels, int origin, int align ) { const char *colorModel, *channelSeq; @@ -3226,7 +3221,8 @@ void scalarToRawData(const Scalar& s, void* _buf, int type, int unroll_to) { CV_INSTRUMENT_REGION(); - const int depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + const ElemType depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); CV_Assert(cn <= 4); switch(depth) { diff --git a/modules/core/src/batch_distance.cpp b/modules/core/src/batch_distance.cpp index 71d0e9e3ff3b..02ac0c0ce923 100644 --- a/modules/core/src/batch_distance.cpp +++ b/modules/core/src/batch_distance.cpp @@ -263,14 +263,14 @@ struct BatchDistInvoker : public ParallelLoopBody } void cv::batchDistance( InputArray _src1, InputArray _src2, - OutputArray _dist, int dtype, OutputArray _nidx, + OutputArray _dist, ElemType dtype, OutputArray _nidx, int normType, int K, InputArray _mask, int update, bool crosscheck ) { CV_INSTRUMENT_REGION(); Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat(); - int type = src1.type(); + ElemType type = src1.type(); CV_Assert( type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)); CV_Assert( _nidx.needed() == (K > 0) ); diff --git a/modules/core/src/channels.cpp b/modules/core/src/channels.cpp index 4e464d910c59..4afad2ecc87b 100644 --- a/modules/core/src/channels.cpp +++ b/modules/core/src/channels.cpp @@ -77,7 +77,7 @@ static void mixChannels64s( const int64** src, const int* sdelta, typedef void (*MixChannelsFunc)( const uchar** src, const int* sdelta, uchar** dst, const int* ddelta, int len, int npairs ); -static MixChannelsFunc getMixchFunc(int depth) +static MixChannelsFunc getMixchFunc(ElemType depth) { static MixChannelsFunc mixchTab[] = { @@ -101,7 +101,7 @@ void cv::mixChannels( const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts, cons CV_Assert( src && nsrcs > 0 && dst && ndsts > 0 && fromTo && npairs > 0 ); size_t i, j, k, esz1 = dst[0].elemSize1(); - int depth = dst[0].depth(); + ElemType depth = dst[0].depth(); AutoBuffer buf((nsrcs + ndsts + 1)*(sizeof(Mat*) + sizeof(uchar*)) + npairs*(sizeof(uchar*)*2 + sizeof(int)*6)); const Mat** arrays = (const Mat**)(uchar*)buf.data(); @@ -210,7 +210,8 @@ static bool ocl_mixChannels(InputArrayOfArrays _src, InputOutputArrayOfArrays _d CV_Assert(nsrc > 0 && ndst > 0); Size size = src[0].size(); - int depth = src[0].depth(), esz = CV_ELEM_SIZE(depth), + ElemType depth = src[0].depth(); + int esz = CV_ELEM_SIZE(depth), rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1; for (size_t i = 1, ssize = src.size(); i < ssize; ++i) @@ -421,7 +422,9 @@ void cv::extractChannel(InputArray _src, OutputArray _dst, int coi) { CV_INSTRUMENT_REGION(); - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemType depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); CV_Assert( 0 <= coi && coi < cn ); int ch[] = { coi, 0 }; @@ -449,8 +452,12 @@ void cv::insertChannel(InputArray _src, InputOutputArray _dst, int coi) { CV_INSTRUMENT_REGION(); - int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), scn = CV_MAT_CN(stype); - int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype), dcn = CV_MAT_CN(dtype); + ElemType stype = _src.type(); + ElemType sdepth = CV_MAT_DEPTH(stype); + int scn = CV_MAT_CN(stype); + ElemType dtype = _dst.type(); + ElemType ddepth = CV_MAT_DEPTH(dtype); + int dcn = CV_MAT_CN(dtype); CV_Assert( _src.sameSize(_dst) && sdepth == ddepth ); CV_Assert( 0 <= coi && coi < dcn && scn == 1 ); diff --git a/modules/core/src/check.cpp b/modules/core/src/check.cpp index 676f755d1d2f..11779899a6fc 100644 --- a/modules/core/src/check.cpp +++ b/modules/core/src/check.cpp @@ -8,13 +8,13 @@ namespace cv { -const char* depthToString(int depth) +const char* depthToString(ElemType depth) { const char* s = detail::depthToString_(depth); return s ? s : ""; } -const cv::String typeToString(int type) +const cv::String typeToString(ElemType type) { cv::String s = detail::typeToString_(type); if (s.empty()) @@ -41,17 +41,17 @@ static const char* getTestOpMath(unsigned testOp) return testOp < CV__LAST_TEST_OP ? _names[testOp] : "???"; } -const char* depthToString_(int depth) +const char* depthToString_(ElemType depth) { static const char* depthNames[] = { "CV_8U", "CV_8S", "CV_16U", "CV_16S", "CV_32S", "CV_32F", "CV_64F", "CV_16F" }; - return (depth <= CV_16F && depth >= 0) ? depthNames[depth] : NULL; + return (depth <= CV_16F && depth >= CV_8U) ? depthNames[depth] : NULL; } -const cv::String typeToString_(int type) +const cv::String typeToString_(ElemType type) { - int depth = CV_MAT_DEPTH(type); + ElemType depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type); - if (depth >= 0 && depth <= CV_16F) + if (depth >= CV_8U && depth <= CV_16F) return cv::format("%sC%d", depthToString_(depth), cn); return cv::String(); } @@ -69,28 +69,28 @@ void check_failed_auto_(const T& v1, const T& v2, const CheckContext& ctx) ss << " '" << ctx.p2_str << "' is " << v2; cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line); } -void check_failed_MatDepth(const int v1, const int v2, const CheckContext& ctx) +void check_failed_MatDepth(const ElemType v1, const ElemType v2, const CheckContext& ctx) { std::stringstream ss; ss << ctx.message << " (expected: '" << ctx.p1_str << " " << getTestOpMath(ctx.testOp) << " " << ctx.p2_str << "'), where" << std::endl - << " '" << ctx.p1_str << "' is " << v1 << " (" << depthToString(v1) << ")" << std::endl; + << " '" << ctx.p1_str << "' is " << static_cast(v1) << " (" << depthToString(v1) << ")" << std::endl; if (ctx.testOp != TEST_CUSTOM && ctx.testOp < CV__LAST_TEST_OP) { ss << "must be " << getTestOpPhraseStr(ctx.testOp) << std::endl; } - ss << " '" << ctx.p2_str << "' is " << v2 << " (" << depthToString(v2) << ")"; + ss << " '" << ctx.p2_str << "' is " << static_cast(v2) << " (" << depthToString(v2) << ")"; cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line); } -void check_failed_MatType(const int v1, const int v2, const CheckContext& ctx) +void check_failed_MatType(const ElemType v1, const ElemType v2, const CheckContext& ctx) { std::stringstream ss; ss << ctx.message << " (expected: '" << ctx.p1_str << " " << getTestOpMath(ctx.testOp) << " " << ctx.p2_str << "'), where" << std::endl - << " '" << ctx.p1_str << "' is " << v1 << " (" << typeToString(v1) << ")" << std::endl; + << " '" << ctx.p1_str << "' is " << static_cast(v1) << " (" << typeToString(v1) << ")" << std::endl; if (ctx.testOp != TEST_CUSTOM && ctx.testOp < CV__LAST_TEST_OP) { ss << "must be " << getTestOpPhraseStr(ctx.testOp) << std::endl; } - ss << " '" << ctx.p2_str << "' is " << v2 << " (" << typeToString(v2) << ")"; + ss << " '" << ctx.p2_str << "' is " << static_cast(v2) << " (" << typeToString(v2) << ")"; cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line); } void check_failed_MatChannels(const int v1, const int v2, const CheckContext& ctx) @@ -125,22 +125,22 @@ void check_failed_auto_(const T& v, const CheckContext& ctx) << " '" << ctx.p1_str << "' is " << v; cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line); } -void check_failed_MatDepth(const int v, const CheckContext& ctx) +void check_failed_MatDepth(const ElemType v, const CheckContext& ctx) { std::stringstream ss; ss << ctx.message << ":" << std::endl << " '" << ctx.p2_str << "'" << std::endl << "where" << std::endl - << " '" << ctx.p1_str << "' is " << v << " (" << depthToString(v) << ")"; + << " '" << ctx.p1_str << "' is " << static_cast(v) << " (" << depthToString(v) << ")"; cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line); } -void check_failed_MatType(const int v, const CheckContext& ctx) +void check_failed_MatType(const ElemType v, const CheckContext& ctx) { std::stringstream ss; ss << ctx.message << ":" << std::endl << " '" << ctx.p2_str << "'" << std::endl << "where" << std::endl - << " '" << ctx.p1_str << "' is " << v << " (" << typeToString(v) << ")"; + << " '" << ctx.p1_str << "' is " << static_cast(v) << " (" << typeToString(v) << ")"; cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line); } void check_failed_MatChannels(const int v, const CheckContext& ctx) diff --git a/modules/core/src/convert.cpp b/modules/core/src/convert.cpp index e31e1b2c4388..593ee92ffaf1 100644 --- a/modules/core/src/convert.cpp +++ b/modules/core/src/convert.cpp @@ -332,7 +332,7 @@ DEF_CVT_FUNC(32f64f, float, double) DEF_CPY_FUNC(64s, int64) */ -BinaryFunc getConvertFunc(int sdepth, int ddepth) +BinaryFunc getConvertFunc(ElemType sdepth, ElemType ddepth) { static BinaryFunc cvtTab[][8] = { @@ -380,7 +380,7 @@ BinaryFunc getConvertFunc(int sdepth, int ddepth) } #ifdef HAVE_OPENCL -static bool ocl_convertFp16( InputArray _src, OutputArray _dst, int sdepth, int ddepth ) +static bool ocl_convertFp16(InputArray _src, OutputArray _dst, ElemType sdepth, ElemType ddepth) { int type = _src.type(), cn = CV_MAT_CN(type); @@ -411,7 +411,7 @@ static bool ocl_convertFp16( InputArray _src, OutputArray _dst, int sdepth, int } // cv:: -void cv::Mat::convertTo(OutputArray _dst, int _type, double alpha, double beta) const +void cv::Mat::convertTo(OutputArray _dst, ElemType ddepth, double alpha, double beta) const { CV_INSTRUMENT_REGION(); @@ -423,12 +423,13 @@ void cv::Mat::convertTo(OutputArray _dst, int _type, double alpha, double beta) bool noScale = fabs(alpha-1) < DBL_EPSILON && fabs(beta) < DBL_EPSILON; - if( _type < 0 ) - _type = _dst.fixedType() ? _dst.type() : type(); - else - _type = CV_MAKETYPE(CV_MAT_DEPTH(_type), channels()); + int cn = channels(); + if (ddepth == CV_TYPE_AUTO) + ddepth = _dst.fixedType() ? _dst.depth() : depth(); + ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ + ElemType dtype = CV_MAKETYPE(ddepth, cn); - int sdepth = depth(), ddepth = CV_MAT_DEPTH(_type); + ElemType sdepth = depth(); if( sdepth == ddepth && noScale ) { copyTo(_dst); @@ -437,15 +438,14 @@ void cv::Mat::convertTo(OutputArray _dst, int _type, double alpha, double beta) Mat src = *this; if( dims <= 2 ) - _dst.create( size(), _type ); + _dst.create(size(), dtype); else - _dst.create( dims, size, _type ); + _dst.create(dims, size, dtype); Mat dst = _dst.getMat(); BinaryFunc func = noScale ? getConvertFunc(sdepth, ddepth) : getConvertScaleFunc(sdepth, ddepth); double scale[] = {alpha, beta}; - int cn = channels(); CV_Assert( func != 0 ); if( dims <= 2 ) @@ -471,7 +471,7 @@ void cv::convertFp16( InputArray _src, OutputArray _dst ) { CV_INSTRUMENT_REGION(); - int sdepth = _src.depth(), ddepth = 0; + ElemType sdepth = _src.depth(), ddepth = CV_8U; BinaryFunc func = 0; switch( sdepth ) @@ -502,7 +502,7 @@ void cv::convertFp16( InputArray _src, OutputArray _dst ) Mat src = _src.getMat(); - int type = CV_MAKETYPE(ddepth, src.channels()); + ElemType type = CV_MAKETYPE(ddepth, src.channels()); _dst.create( src.dims, src.size, type ); Mat dst = _dst.getMat(); int cn = src.channels(); diff --git a/modules/core/src/convert_c.cpp b/modules/core/src/convert_c.cpp index efe4de740ac2..5d0770a0c702 100644 --- a/modules/core/src/convert_c.cpp +++ b/modules/core/src/convert_c.cpp @@ -130,5 +130,5 @@ CV_IMPL void cvNormalize( const CvArr* srcarr, CvArr* dstarr, if( maskarr ) mask = cv::cvarrToMat(maskarr); CV_Assert( dst.size() == src.size() && src.channels() == dst.channels() ); - cv::normalize( src, dst, a, b, norm_type, dst.type(), mask ); + cv::normalize( src, dst, a, b, norm_type, dst.depth(), mask ); } diff --git a/modules/core/src/convert_scale.cpp b/modules/core/src/convert_scale.cpp index 2758685f4ae0..485e7e2e9ad7 100644 --- a/modules/core/src/convert_scale.cpp +++ b/modules/core/src/convert_scale.cpp @@ -287,7 +287,7 @@ DEF_CVT_SCALE_FUNC(32f16f, cvt1_32f, float, float16_t, float) DEF_CVT_SCALE_FUNC(64f16f, cvt_64f, double, float16_t, double) DEF_CVT_SCALE_FUNC(16f, cvt1_32f, float16_t, float16_t, float) -static BinaryFunc getCvtScaleAbsFunc(int depth) +static BinaryFunc getCvtScaleAbsFunc(ElemType depth) { static BinaryFunc cvtScaleAbsTab[] = { @@ -299,7 +299,7 @@ static BinaryFunc getCvtScaleAbsFunc(int depth) return cvtScaleAbsTab[depth]; } -BinaryFunc getConvertScaleFunc(int sdepth, int ddepth) +BinaryFunc getConvertScaleFunc(ElemType sdepth, ElemType ddepth) { static BinaryFunc cvtScaleTab[][8] = { @@ -354,7 +354,9 @@ static bool ocl_convertScaleAbs( InputArray _src, OutputArray _dst, double alpha { const ocl::Device & d = ocl::Device::getDefault(); - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemType depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); bool doubleSupport = d.doubleFPConfig() > 0; if (!doubleSupport && depth == CV_64F) return false; @@ -374,7 +376,7 @@ static bool ocl_convertScaleAbs( InputArray _src, OutputArray _dst, double alpha int rowsPerWI = d.isIntel() ? 4 : 1; char cvt[2][50]; - int wdepth = std::max(depth, CV_32F); + ElemType wdepth = CV_MAX_DEPTH(depth, CV_32F); String build_opt = format("-D OP_CONVERT_SCALE_ABS -D UNARY_OP -D dstT=%s -D srcT1=%s" " -D workT=%s -D wdepth=%d -D convertToWT1=%s -D convertToDT=%s" " -D workT1=%s -D rowsPerWI=%d%s", @@ -447,20 +449,22 @@ namespace cv { #ifdef HAVE_OPENCL -static bool ocl_normalize( InputArray _src, InputOutputArray _dst, InputArray _mask, int dtype, +static bool ocl_normalize( InputArray _src, InputOutputArray _dst, InputArray _mask, ElemType ddepth, double scale, double delta ) { UMat src = _src.getUMat(); if( _mask.empty() ) - src.convertTo( _dst, dtype, scale, delta ); + src.convertTo(_dst, ddepth, scale, delta); else if (src.channels() <= 4) { const ocl::Device & dev = ocl::Device::getDefault(); - int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype), - ddepth = CV_MAT_DEPTH(dtype), wdepth = std::max(CV_32F, std::max(sdepth, ddepth)), - rowsPerWI = dev.isIntel() ? 4 : 1; + ElemType stype = _src.type(); + ElemType sdepth = CV_MAT_DEPTH(stype); + int cn = CV_MAT_CN(stype); + ElemType wdepth = CV_MAX_DEPTH(CV_32F, sdepth, ddepth); + int rowsPerWI = dev.isIntel() ? 4 : 1; float fscale = static_cast(scale), fdelta = static_cast(delta); bool haveScale = std::fabs(scale - 1) > DBL_EPSILON, @@ -468,7 +472,7 @@ static bool ocl_normalize( InputArray _src, InputOutputArray _dst, InputArray _m haveDelta = std::fabs(delta) > DBL_EPSILON, doubleSupport = dev.doubleFPConfig() > 0; - if (!haveScale && !haveDelta && stype == dtype) + if (!haveScale && !haveDelta && sdepth == ddepth) { _src.copyTo(_dst, _mask); return true; @@ -485,7 +489,7 @@ static bool ocl_normalize( InputArray _src, InputOutputArray _dst, InputArray _m char cvt[2][40]; String opts = format("-D srcT=%s -D dstT=%s -D convertToWT=%s -D cn=%d -D rowsPerWI=%d" " -D convertToDT=%s -D workT=%s%s%s%s -D srcT1=%s -D dstT1=%s", - ocl::typeToStr(stype), ocl::typeToStr(dtype), + ocl::typeToStr(stype), ocl::typeToStr(ddepth), ocl::convertTypeStr(sdepth, wdepth, cn, cvt[0]), cn, rowsPerWI, ocl::convertTypeStr(wdepth, ddepth, cn, cvt[1]), ocl::typeToStr(CV_MAKE_TYPE(wdepth, cn)), @@ -525,7 +529,7 @@ static bool ocl_normalize( InputArray _src, InputOutputArray _dst, InputArray _m else { UMat temp; - src.convertTo( temp, dtype, scale, delta ); + src.convertTo(temp, ddepth, scale, delta); temp.copyTo( _dst, _mask ); } @@ -537,15 +541,16 @@ static bool ocl_normalize( InputArray _src, InputOutputArray _dst, InputArray _m } // cv:: void cv::normalize( InputArray _src, InputOutputArray _dst, double a, double b, - int norm_type, int rtype, InputArray _mask ) + int norm_type, ElemType ddepth, InputArray _mask ) { CV_INSTRUMENT_REGION(); double scale = 1, shift = 0; - int type = _src.type(), depth = CV_MAT_DEPTH(type); + ElemType type = _src.type(); + ElemType depth = CV_MAT_DEPTH(type); - if( rtype < 0 ) - rtype = _dst.fixedType() ? _dst.depth() : depth; + if (ddepth == CV_TYPE_AUTO) + ddepth = _dst.fixedType() ? _dst.depth() : depth; if( norm_type == CV_MINMAX ) { @@ -553,7 +558,7 @@ void cv::normalize( InputArray _src, InputOutputArray _dst, double a, double b, double dmin = MIN( a, b ), dmax = MAX( a, b ); minMaxIdx( _src, &smin, &smax, 0, 0, _mask ); scale = (dmax - dmin)*(smax - smin > DBL_EPSILON ? 1./(smax - smin) : 0); - if( rtype == CV_32F ) + if (ddepth == CV_32F) { scale = (float)scale; shift = (float)dmin - (float)(smin*scale); @@ -571,15 +576,15 @@ void cv::normalize( InputArray _src, InputOutputArray _dst, double a, double b, CV_Error( CV_StsBadArg, "Unknown/unsupported norm type" ); CV_OCL_RUN(_dst.isUMat(), - ocl_normalize(_src, _dst, _mask, rtype, scale, shift)) + ocl_normalize(_src, _dst, _mask, ddepth, scale, shift)) Mat src = _src.getMat(); if( _mask.empty() ) - src.convertTo( _dst, rtype, scale, shift ); + src.convertTo(_dst, ddepth, scale, shift); else { Mat temp; - src.convertTo( temp, rtype, scale, shift ); + src.convertTo(temp, ddepth, scale, shift); temp.copyTo( _dst, _mask ); } } diff --git a/modules/core/src/copy.cpp b/modules/core/src/copy.cpp index 38264cc58f34..8ca8c1dfb53e 100644 --- a/modules/core/src/copy.cpp +++ b/modules/core/src/copy.cpp @@ -246,11 +246,10 @@ void Mat::copyTo( OutputArray _dst ) const } #endif - int dtype = _dst.type(); - if( _dst.fixedType() && dtype != type() ) + if (_dst.fixedType() && _dst.type() != type()) { - CV_Assert( channels() == CV_MAT_CN(dtype) ); - convertTo( _dst, dtype ); + CV_Assert(channels() == _dst.channels()); + convertTo(_dst, _dst.depth()); return; } @@ -657,7 +656,9 @@ static bool ocl_flip(InputArray _src, OutputArray _dst, int flipCode ) CV_Assert(flipCode >= -1 && flipCode <= 1); const ocl::Device & dev = ocl::Device::getDefault(); - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), + ElemType type = _src.type(); + ElemType depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), flipType, kercn = std::min(ocl::predictOptimalVectorWidth(_src, _dst), 4); bool doubleSupport = dev.doubleFPConfig() > 0; @@ -766,7 +767,7 @@ void flip( InputArray _src, OutputArray _dst, int flip_mode ) CV_OCL_RUN( _dst.isUMat(), ocl_flip(_src, _dst, flip_mode)) Mat src = _src.getMat(); - int type = src.type(); + ElemType type = src.type(); _dst.create( size, type ); Mat dst = _dst.getMat(); @@ -841,7 +842,9 @@ static bool ocl_repeat(InputArray _src, int ny, int nx, OutputArray _dst) return true; } - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), + ElemType type = _src.type(); + ElemType depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1, kercn = ocl::predictOptimalVectorWidth(_src, _dst); @@ -1085,8 +1088,10 @@ namespace cv { static bool ocl_copyMakeBorder( InputArray _src, OutputArray _dst, int top, int bottom, int left, int right, int borderType, const Scalar& value ) { - int type = _src.type(), cn = CV_MAT_CN(type), depth = CV_MAT_DEPTH(type), - rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1; + ElemType type = _src.type(); + int cn = CV_MAT_CN(type); + ElemType depth = CV_MAT_DEPTH(type); + int rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1; bool isolated = (borderType & BORDER_ISOLATED) != 0; borderType &= ~cv::BORDER_ISOLATED; @@ -1097,7 +1102,7 @@ static bool ocl_copyMakeBorder( InputArray _src, OutputArray _dst, int top, int const char * const borderMap[] = { "BORDER_CONSTANT", "BORDER_REPLICATE", "BORDER_REFLECT", "BORDER_WRAP", "BORDER_REFLECT_101" }; int scalarcn = cn == 3 ? 4 : cn; - int sctype = CV_MAKETYPE(depth, scalarcn); + ElemType sctype = CV_MAKETYPE(depth, scalarcn); String buildOptions = format("-D T=%s -D %s -D T1=%s -D cn=%d -D ST=%s -D rowsPerWI=%d", ocl::memopTypeToStr(type), borderMap[borderType], ocl::memopTypeToStr(depth), cn, @@ -1190,7 +1195,7 @@ void cv::copyMakeBorder( InputArray _src, OutputArray _dst, int top, int bottom, ocl_copyMakeBorder(_src, _dst, top, bottom, left, right, borderType, value)) Mat src = _src.getMat(); - int type = src.type(); + ElemType type = src.type(); if( src.isSubmatrix() && (borderType & BORDER_ISOLATED) == 0 ) { diff --git a/modules/core/src/count_non_zero.cpp b/modules/core/src/count_non_zero.cpp index 3cff0944bc5f..68a5e5abf17f 100644 --- a/modules/core/src/count_non_zero.cpp +++ b/modules/core/src/count_non_zero.cpp @@ -177,7 +177,7 @@ static int countNonZero64f( const double* src, int len ) typedef int (*CountNonZeroFunc)(const uchar*, int); -static CountNonZeroFunc getCountNonZeroTab(int depth) +static CountNonZeroFunc getCountNonZeroTab(ElemType depth) { static CountNonZeroFunc countNonZeroTab[] = { @@ -194,7 +194,9 @@ static CountNonZeroFunc getCountNonZeroTab(int depth) #ifdef HAVE_OPENCL static bool ocl_countNonZero( InputArray _src, int & res ) { - int type = _src.type(), depth = CV_MAT_DEPTH(type), kercn = ocl::predictOptimalVectorWidth(_src); + ElemType type = _src.type(); + ElemType depth = CV_MAT_DEPTH(type); + int kercn = ocl::predictOptimalVectorWidth(_src); bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; if (depth == CV_64F && !doubleSupport) @@ -241,7 +243,7 @@ static bool ipp_countNonZero( Mat &src, int &res ) #endif Ipp32s count = 0; - int depth = src.depth(); + ElemType depth = src.depth(); if(src.dims <= 2) { @@ -294,7 +296,8 @@ int cv::countNonZero( InputArray _src ) { CV_INSTRUMENT_REGION(); - int type = _src.type(), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + int cn = CV_MAT_CN(type); CV_Assert( cn == 1 ); #if defined HAVE_OPENCL || defined HAVE_IPP @@ -331,7 +334,7 @@ void cv::findNonZero( InputArray _src, OutputArray _idx ) Mat src = _src.getMat(); CV_Assert( src.channels() == 1 && src.dims == 2 ); - int depth = src.depth(); + ElemType depth = src.depth(); std::vector idxvec; int rows = src.rows, cols = src.cols; AutoBuffer buf_(cols + 1); diff --git a/modules/core/src/cuda/gpu_mat.cu b/modules/core/src/cuda/gpu_mat.cu index e1b0c1b22d83..a1f87744ad3d 100644 --- a/modules/core/src/cuda/gpu_mat.cu +++ b/modules/core/src/cuda/gpu_mat.cu @@ -151,11 +151,11 @@ void cv::cuda::GpuMat::setDefaultAllocator(Allocator* allocator) ///////////////////////////////////////////////////// /// create -void cv::cuda::GpuMat::create(int _rows, int _cols, int _type) +void cv::cuda::GpuMat::create(int _rows, int _cols, ElemType _type) { CV_DbgAssert( _rows >= 0 && _cols >= 0 ); - _type &= Mat::TYPE_MASK; + _type &= static_cast(Mat::TYPE_MASK); if (rows == _rows && cols == _cols && type() == _type && data) return; @@ -165,7 +165,7 @@ void cv::cuda::GpuMat::create(int _rows, int _cols, int _type) if (_rows > 0 && _cols > 0) { - flags = Mat::MAGIC_VAL + _type; + flags = static_cast(Mat::MAGIC_VAL | _type); rows = _rows; cols = _cols; @@ -182,7 +182,7 @@ void cv::cuda::GpuMat::create(int _rows, int _cols, int _type) } if (esz * cols == step) - flags |= Mat::CONTINUOUS_FLAG; + flags |= static_cast(Mat::CONTINUOUS_FLAG); int64 _nettosize = static_cast(step) * rows; size_t nettosize = static_cast(_nettosize); @@ -523,15 +523,14 @@ namespace } } -void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, Stream& stream) const +void cv::cuda::GpuMat::convertTo(OutputArray _dst, ElemType ddepth, Stream& stream) const { - if (rtype < 0) - rtype = type(); - else - rtype = CV_MAKE_TYPE(CV_MAT_DEPTH(rtype), channels()); + if (ddepth == CV_TYPE_AUTO) + ddepth = _dst.fixedType() ? _dst.depth() : depth(); + ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ + ElemType dtype = CV_MAKETYPE(ddepth, channels()); - const int sdepth = depth(); - const int ddepth = CV_MAT_DEPTH(rtype); + const ElemType sdepth = depth(); if (sdepth == ddepth) { if (stream) @@ -546,7 +545,7 @@ void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, Stream& stream) co GpuMat src = *this; - _dst.create(size(), rtype); + _dst.create(size(), dtype); GpuMat dst = _dst.getGpuMat(); typedef void (*func_t)(const GpuMat& src, const GpuMat& dst, Stream& stream); @@ -564,19 +563,18 @@ void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, Stream& stream) co funcs[sdepth][ddepth](reshape(1), dst.reshape(1), stream); } -void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, double alpha, double beta, Stream& stream) const +void cv::cuda::GpuMat::convertTo(OutputArray _dst, ElemType ddepth, double alpha, double beta, Stream& stream) const { - if (rtype < 0) - rtype = type(); - else - rtype = CV_MAKETYPE(CV_MAT_DEPTH(rtype), channels()); + if (ddepth == CV_TYPE_AUTO) + ddepth = _dst.fixedType() ? _dst.depth() : depth(); + ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ + ElemType dtype = CV_MAKETYPE(ddepth, channels()); - const int sdepth = depth(); - const int ddepth = CV_MAT_DEPTH(rtype); + const ElemType sdepth = depth(); GpuMat src = *this; - _dst.create(size(), rtype); + _dst.create(size(), dtype); GpuMat dst = _dst.getGpuMat(); typedef void (*func_t)(const GpuMat& src, const GpuMat& dst, double alpha, double beta, Stream& stream); @@ -597,7 +595,7 @@ void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, double alpha, doub void cv::cuda::convertFp16(InputArray _src, OutputArray _dst, Stream& stream) { GpuMat src = _src.getGpuMat(); - int ddepth = 0; + ElemType ddepth = CV_TYPE_AUTO; switch(src.depth()) { @@ -611,7 +609,7 @@ void cv::cuda::convertFp16(InputArray _src, OutputArray _dst, Stream& stream) CV_Error(Error::StsUnsupportedFormat, "Unsupported input depth"); return; } - int type = CV_MAKE_TYPE(CV_MAT_DEPTH(ddepth), src.channels()); + ElemType type = CV_MAKE_TYPE(CV_MAT_DEPTH(ddepth), src.channels()); _dst.create(src.size(), type); GpuMat dst = _dst.getGpuMat(); diff --git a/modules/core/src/cuda_gpu_mat.cpp b/modules/core/src/cuda_gpu_mat.cpp index a245b1a293ec..93047ccc13f6 100644 --- a/modules/core/src/cuda_gpu_mat.cpp +++ b/modules/core/src/cuda_gpu_mat.cpp @@ -53,8 +53,8 @@ void cv::cuda::GpuMat::updateContinuityFlag() flags = cv::updateContinuityFlag(flags, 2, sz, steps); } -cv::cuda::GpuMat::GpuMat(int rows_, int cols_, int type_, void* data_, size_t step_) : - flags(Mat::MAGIC_VAL + (type_ & Mat::TYPE_MASK)), rows(rows_), cols(cols_), +cv::cuda::GpuMat::GpuMat(int rows_, int cols_, ElemType type_, void* data_, size_t step_) : + flags(static_cast(Mat::MAGIC_VAL | (type_ & Mat::TYPE_MASK))), rows(rows_), cols(cols_), step(step_), data((uchar*)data_), refcount(0), datastart((uchar*)data_), dataend((const uchar*)data_), allocator(defaultAllocator()) @@ -77,8 +77,8 @@ cv::cuda::GpuMat::GpuMat(int rows_, int cols_, int type_, void* data_, size_t st updateContinuityFlag(); } -cv::cuda::GpuMat::GpuMat(Size size_, int type_, void* data_, size_t step_) : - flags(Mat::MAGIC_VAL + (type_ & Mat::TYPE_MASK)), rows(size_.height), cols(size_.width), +cv::cuda::GpuMat::GpuMat(Size size_, ElemType type_, void* data_, size_t step_) : + flags(static_cast(Mat::MAGIC_VAL | (type_ & Mat::TYPE_MASK))), rows(size_.height), cols(size_.width), step(step_), data((uchar*)data_), refcount(0), datastart((uchar*)data_), dataend((const uchar*)data_), allocator(defaultAllocator()) @@ -256,7 +256,7 @@ GpuMat& cv::cuda::GpuMat::adjustROI(int dtop, int dbottom, int dleft, int dright namespace { template - void createContinuousImpl(int rows, int cols, int type, ObjType& obj) + void createContinuousImpl(int rows, int cols, ElemType type, ObjType& obj) { const int area = rows * cols; @@ -267,7 +267,7 @@ namespace } } -void cv::cuda::createContinuous(int rows, int cols, int type, OutputArray arr) +void cv::cuda::createContinuous(int rows, int cols, ElemType type, OutputArray arr) { switch (arr.kind()) { @@ -291,7 +291,7 @@ void cv::cuda::createContinuous(int rows, int cols, int type, OutputArray arr) namespace { template - void ensureSizeIsEnoughImpl(int rows, int cols, int type, ObjType& obj) + void ensureSizeIsEnoughImpl(int rows, int cols, ElemType type, ObjType& obj) { if (obj.empty() || obj.type() != type || obj.data != obj.datastart) { @@ -321,7 +321,7 @@ namespace } } -void cv::cuda::ensureSizeIsEnough(int rows, int cols, int type, OutputArray arr) +void cv::cuda::ensureSizeIsEnough(int rows, int cols, ElemType type, OutputArray arr) { switch (arr.kind()) { @@ -364,7 +364,7 @@ GpuMat cv::cuda::getInputMat(InputArray _src, Stream& stream) #endif } -GpuMat cv::cuda::getOutputMat(OutputArray _dst, int rows, int cols, int type, Stream& stream) +GpuMat cv::cuda::getOutputMat(OutputArray _dst, int rows, int cols, ElemType type, Stream& stream) { #ifndef HAVE_CUDA CV_UNUSED(_dst); @@ -420,7 +420,7 @@ void cv::cuda::GpuMat::setDefaultAllocator(Allocator* allocator) throw_no_cuda(); } -void cv::cuda::GpuMat::create(int _rows, int _cols, int _type) +void cv::cuda::GpuMat::create(int _rows, int _cols, ElemType _type) { CV_UNUSED(_rows); CV_UNUSED(_cols); @@ -494,18 +494,18 @@ GpuMat& cv::cuda::GpuMat::setTo(Scalar s, InputArray _mask, Stream& _stream) throw_no_cuda(); } -void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, Stream& _stream) const +void cv::cuda::GpuMat::convertTo(OutputArray _dst, ElemType ddepth, Stream& _stream) const { CV_UNUSED(_dst); - CV_UNUSED(rtype); + CV_UNUSED(ddepth); CV_UNUSED(_stream); throw_no_cuda(); } -void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, double alpha, double beta, Stream& _stream) const +void cv::cuda::GpuMat::convertTo(OutputArray _dst, ElemType ddepth, double alpha, double beta, Stream& _stream) const { CV_UNUSED(_dst); - CV_UNUSED(rtype); + CV_UNUSED(ddepth); CV_UNUSED(alpha); CV_UNUSED(beta); CV_UNUSED(_stream); diff --git a/modules/core/src/cuda_host_mem.cpp b/modules/core/src/cuda_host_mem.cpp index 0c120f82f99f..de06da82a059 100644 --- a/modules/core/src/cuda_host_mem.cpp +++ b/modules/core/src/cuda_host_mem.cpp @@ -58,7 +58,7 @@ class HostMemAllocator : public MatAllocator { } - UMatData* allocate(int dims, const int* sizes, int type, + UMatData* allocate(int dims, const int* sizes, ElemType type, void* data0, size_t* step, AccessFlag /*flags*/, UMatUsageFlags /*usageFlags*/) const CV_OVERRIDE { @@ -175,7 +175,7 @@ namespace } #endif -void cv::cuda::HostMem::create(int rows_, int cols_, int type_) +void cv::cuda::HostMem::create(int rows_, int cols_, ElemType type_) { #ifndef HAVE_CUDA CV_UNUSED(rows_); @@ -189,7 +189,7 @@ void cv::cuda::HostMem::create(int rows_, int cols_, int type_) CV_Assert( devInfo.canMapHostMemory() ); } - type_ &= Mat::TYPE_MASK; + type_ &= static_cast(Mat::TYPE_MASK); if (rows == rows_ && cols == cols_ && type() == type_ && data) return; @@ -201,7 +201,7 @@ void cv::cuda::HostMem::create(int rows_, int cols_, int type_) if (rows_ > 0 && cols_ > 0) { - flags = Mat::MAGIC_VAL + type_; + flags = static_cast(Mat::MAGIC_VAL | type_); rows = rows_; cols = cols_; step = elemSize() * cols; diff --git a/modules/core/src/cuda_stream.cpp b/modules/core/src/cuda_stream.cpp index 79d747722080..6790b0aa0ff2 100644 --- a/modules/core/src/cuda_stream.cpp +++ b/modules/core/src/cuda_stream.cpp @@ -711,7 +711,7 @@ cv::cuda::BufferPool::BufferPool(Stream& stream) : allocator_(stream.impl_->allo } #endif -GpuMat cv::cuda::BufferPool::getBuffer(int rows, int cols, int type) +GpuMat cv::cuda::BufferPool::getBuffer(int rows, int cols, ElemType type) { #ifndef HAVE_CUDA CV_UNUSED(rows); diff --git a/modules/core/src/datastructs.cpp b/modules/core/src/datastructs.cpp index 1e374c8d84ee..6a22bb3f6164 100644 --- a/modules/core/src/datastructs.cpp +++ b/modules/core/src/datastructs.cpp @@ -385,7 +385,7 @@ cvCreateSeq( int seq_flags, size_t header_size, size_t elem_size, CvMemStorage* seq->header_size = (int)header_size; seq->flags = (seq_flags & ~CV_MAGIC_MASK) | CV_SEQ_MAGIC_VAL; { - int elemtype = CV_MAT_TYPE(seq_flags); + ElemType elemtype = CV_MAT_TYPE(seq_flags); int typesize = CV_ELEM_SIZE(elemtype); if( elemtype != CV_SEQ_ELTYPE_GENERIC && elemtype != CV_SEQ_ELTYPE_PTR && diff --git a/modules/core/src/directx.cpp b/modules/core/src/directx.cpp index 99c27ec7054e..81809fb72290 100644 --- a/modules/core/src/directx.cpp +++ b/modules/core/src/directx.cpp @@ -59,13 +59,13 @@ namespace cv { namespace directx { -int getTypeFromDXGI_FORMAT(const int iDXGI_FORMAT) +ElemType getTypeFromDXGI_FORMAT(const int iDXGI_FORMAT) { CV_UNUSED(iDXGI_FORMAT); #if !defined(HAVE_DIRECTX) NO_DIRECTX_SUPPORT_ERROR; #else - const int errorType = -1; + const ElemType errorType = CV_TYPE_AUTO; switch ((enum DXGI_FORMAT)iDXGI_FORMAT) { //case DXGI_FORMAT_UNKNOWN: @@ -177,13 +177,13 @@ int getTypeFromDXGI_FORMAT(const int iDXGI_FORMAT) #endif } -int getTypeFromD3DFORMAT(const int iD3DFORMAT) +ElemType getTypeFromD3DFORMAT(const int iD3DFORMAT) { CV_UNUSED(iD3DFORMAT); #if !defined(HAVE_DIRECTX) NO_DIRECTX_SUPPORT_ERROR; #else - const int errorType = -1; + const ElemType errorType = CV_TYPE_AUTO; switch ((enum _D3DFORMAT)iD3DFORMAT) { //case D3DFMT_UNKNOWN: @@ -774,7 +774,7 @@ void convertToD3D11Texture2D(InputArray src, ID3D11Texture2D* pD3D11Texture2D) pD3D11Texture2D->GetDesc(&desc); int srcType = src.type(); - int textureType = getTypeFromDXGI_FORMAT(desc.Format); + ElemType textureType = getTypeFromDXGI_FORMAT(desc.Format); CV_Assert(textureType == srcType); Size srcSize = src.size(); @@ -882,8 +882,8 @@ void convertFromD3D11Texture2D(ID3D11Texture2D* pD3D11Texture2D, OutputArray dst D3D11_TEXTURE2D_DESC desc = { 0 }; pD3D11Texture2D->GetDesc(&desc); - int textureType = getTypeFromDXGI_FORMAT(desc.Format); - CV_Assert(textureType >= 0); + ElemType textureType = getTypeFromDXGI_FORMAT(desc.Format); + CV_Assert(textureType >= CV_8UC1); // TODO Need to specify ACCESS_WRITE here somehow to prevent useless data copying! dst.create(Size(desc.Width, desc.Height), textureType); @@ -1014,7 +1014,7 @@ void convertToD3D10Texture2D(InputArray src, ID3D10Texture2D* pD3D10Texture2D) pD3D10Texture2D->GetDesc(&desc); int srcType = src.type(); - int textureType = getTypeFromDXGI_FORMAT(desc.Format); + ElemType textureType = getTypeFromDXGI_FORMAT(desc.Format); CV_Assert(textureType == srcType); Size srcSize = src.size(); diff --git a/modules/core/src/downhill_simplex.cpp b/modules/core/src/downhill_simplex.cpp index 15d6469465f4..425a63a8a777 100644 --- a/modules/core/src/downhill_simplex.cpp +++ b/modules/core/src/downhill_simplex.cpp @@ -201,8 +201,8 @@ class DownhillSolverImpl CV_FINAL : public DownhillSolver } else { - int x_type = x_.fixedType() ? x_.type() : CV_64F; - simplex.row(0).convertTo(x_, x_type); + ElemType x_depth = x_.fixedType() ? x_.depth() : CV_64F; + simplex.row(0).convertTo(x_, x_depth); } return res; } diff --git a/modules/core/src/dxt.cpp b/modules/core/src/dxt.cpp index bfa61d05029c..7e18d7cdcad6 100644 --- a/modules/core/src/dxt.cpp +++ b/modules/core/src/dxt.cpp @@ -1885,11 +1885,11 @@ struct OCL_FftPlan String buildOptions; int thread_count; int dft_size; - int dft_depth; + ElemType dft_depth; bool status; public: - OCL_FftPlan(int _size, int _depth) : dft_size(_size), dft_depth(_depth), status(true) + OCL_FftPlan(int _size, ElemType _depth) : dft_size(_size), dft_depth(_depth), status(true) { CV_Assert( dft_depth == CV_32F || dft_depth == CV_64F ); @@ -2092,7 +2092,7 @@ class OCL_FftPlanCache CV_SINGLETON_LAZY_INIT_REF(OCL_FftPlanCache, new OCL_FftPlanCache()) } - Ptr getFftPlan(int dft_size, int depth) + Ptr getFftPlan(int dft_size, ElemType depth) { int key = (dft_size << 16) | (depth & 0xFFFF); std::map >::iterator f = planStorage.find(key); @@ -2123,14 +2123,16 @@ class OCL_FftPlanCache static bool ocl_dft_rows(InputArray _src, OutputArray _dst, int nonzero_rows, int flags, int fftType) { - int type = _src.type(), depth = CV_MAT_DEPTH(type); + ElemType type = _src.type(); + ElemType depth = CV_MAT_DEPTH(type); Ptr plan = OCL_FftPlanCache::getInstance().getFftPlan(_src.cols(), depth); return plan->enqueueTransform(_src, _dst, nonzero_rows, flags, fftType, true); } static bool ocl_dft_cols(InputArray _src, OutputArray _dst, int nonzero_cols, int flags, int fftType) { - int type = _src.type(), depth = CV_MAT_DEPTH(type); + ElemType type = _src.type(); + ElemType depth = CV_MAT_DEPTH(type); Ptr plan = OCL_FftPlanCache::getInstance().getFftPlan(_src.rows(), depth); return plan->enqueueTransform(_src, _dst, nonzero_cols, flags, fftType, false); } @@ -2160,7 +2162,9 @@ inline FftType determineFFTType(bool real_input, bool complex_input, bool real_o static bool ocl_dft(InputArray _src, OutputArray _dst, int flags, int nonzero_rows) { - int type = _src.type(), cn = CV_MAT_CN(type), depth = CV_MAT_DEPTH(type); + ElemType type = _src.type(); + int cn = CV_MAT_CN(type); + ElemType depth = CV_MAT_DEPTH(type); Size ssize = _src.size(); bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; @@ -2195,12 +2199,12 @@ static bool ocl_dft(InputArray _src, OutputArray _dst, int flags, int nonzero_ro // real output if (is1d) { - _dst.create(src.size(), CV_MAKETYPE(depth, 1)); + _dst.create(src.size(), depth); output = _dst.getUMat(); } else { - _dst.create(src.size(), CV_MAKETYPE(depth, 1)); + _dst.create(src.size(), depth); output.create(src.size(), CV_MAKETYPE(depth, 2)); } } @@ -2413,7 +2417,9 @@ static void CL_CALLBACK oclCleanupCallback(cl_event e, cl_int, void *p) static bool ocl_dft_amdfft(InputArray _src, OutputArray _dst, int flags) { - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemType depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); Size ssize = _src.size(); bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; @@ -2500,7 +2506,7 @@ static void complementComplex(T * ptr, size_t step, int n, int len, int dft_dims } } -static void complementComplexOutput(int depth, uchar * ptr, size_t step, int count, int len, int dft_dims) +static void complementComplexOutput(ElemType depth, uchar * ptr, size_t step, int count, int len, int dft_dims) { if( depth == CV_32F ) complementComplex((float*)ptr, step, count, len, dft_dims); @@ -2620,7 +2626,7 @@ class OcvDftImpl CV_FINAL : public hal::DFT2D DftMode mode; int elem_size; int complex_elem_size; - int depth; + ElemType depth; bool real_transform; int nonzero_rows; bool isRowTransform; @@ -2646,7 +2652,7 @@ class OcvDftImpl CV_FINAL : public hal::DFT2D mode = InvalidDft; elem_size = 0; complex_elem_size = 0; - depth = 0; + depth = CV_8U; real_transform = false; nonzero_rows = 0; isRowTransform = false; @@ -2656,7 +2662,7 @@ class OcvDftImpl CV_FINAL : public hal::DFT2D dst_channels = 0; } - void init(int _width, int _height, int _depth, int _src_channels, int _dst_channels, int flags, int _nonzero_rows) + void init(int _width, int _height, ElemType _depth, int _src_channels, int _dst_channels, int flags, int _nonzero_rows) { bool isComplex = _src_channels != _dst_channels; nonzero_rows = _nonzero_rows; @@ -3056,7 +3062,7 @@ class OcvDftBasicImpl CV_FINAL : public hal::DFT1D { opt.factors = _factors; } - void init(int len, int count, int depth, int flags, bool *needBuffer) + void init(int len, int count, ElemType depth, int flags, bool *needBuffer) { int prev_len = opt.n; @@ -3208,7 +3214,7 @@ struct ReplacementDFT1D : public hal::DFT1D bool isInitialized; ReplacementDFT1D() : context(0), isInitialized(false) {} - bool init(int len, int count, int depth, int flags, bool *needBuffer) + bool init(int len, int count, ElemType depth, int flags, bool *needBuffer) { int res = cv_hal_dftInit1D(&context, len, count, depth, flags, needBuffer); isInitialized = (res == CV_HAL_ERROR_OK); @@ -3236,7 +3242,7 @@ struct ReplacementDFT2D : public hal::DFT2D bool isInitialized; ReplacementDFT2D() : context(0), isInitialized(false) {} - bool init(int width, int height, int depth, + bool init(int width, int height, ElemType depth, int src_channels, int dst_channels, int flags, int nonzero_rows) { @@ -3264,7 +3270,7 @@ namespace hal { //================== 1D ====================== -Ptr DFT1D::create(int len, int count, int depth, int flags, bool *needBuffer) +Ptr DFT1D::create(int len, int count, ElemType depth, int flags, bool *needBuffer) { { ReplacementDFT1D *impl = new ReplacementDFT1D(); @@ -3283,7 +3289,7 @@ Ptr DFT1D::create(int len, int count, int depth, int flags, bool *needBuf //================== 2D ====================== -Ptr DFT2D::create(int width, int height, int depth, +Ptr DFT2D::create(int width, int height, ElemType depth, int src_channels, int dst_channels, int flags, int nonzero_rows) { @@ -3329,8 +3335,8 @@ void cv::dft( InputArray _src0, OutputArray _dst, int flags, int nonzero_rows ) Mat src0 = _src0.getMat(), src = src0; bool inv = (flags & DFT_INVERSE) != 0; - int type = src.type(); - int depth = src.depth(); + ElemType type = src.type(); + ElemType depth = src.depth(); CV_Assert( type == CV_32FC1 || type == CV_32FC2 || type == CV_64FC1 || type == CV_64FC2 ); @@ -3376,8 +3382,8 @@ namespace cv { static bool ocl_mulSpectrums( InputArray _srcA, InputArray _srcB, OutputArray _dst, int flags, bool conjB ) { - int atype = _srcA.type(), btype = _srcB.type(), - rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1; + ElemType atype = _srcA.type(), btype = _srcB.type(); + int rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1; Size asize = _srcA.size(), bsize = _srcB.size(); CV_Assert(asize == bsize); @@ -3535,7 +3541,9 @@ void cv::mulSpectrums( InputArray _srcA, InputArray _srcB, ocl_mulSpectrums(_srcA, _srcB, _dst, flags, conjB)) Mat srcA = _srcA.getMat(), srcB = _srcB.getMat(); - int depth = srcA.depth(), cn = srcA.channels(), type = srcA.type(); + ElemType depth = srcA.depth(); + int cn = srcA.channels(); + ElemType type = srcA.type(); size_t rows = srcA.rows, cols = srcA.cols; CV_Assert( type == srcB.type() && srcA.size() == srcB.size() ); @@ -4065,9 +4073,9 @@ class OcvDctImpl CV_FINAL : public hal::DCT2D int end_stage; int width; int height; - int depth; + ElemType depth; - void init(int _width, int _height, int _depth, int flags) + void init(int _width, int _height, ElemType _depth, int flags) { width = _width; height = _height; @@ -4190,7 +4198,7 @@ struct ReplacementDCT2D : public hal::DCT2D bool isInitialized; ReplacementDCT2D() : context(0), isInitialized(false) {} - bool init(int width, int height, int depth, int flags) + bool init(int width, int height, ElemType depth, int flags) { int res = hal_ni_dctInit2D(&context, width, height, depth, flags); isInitialized = (res == CV_HAL_ERROR_OK); @@ -4214,7 +4222,7 @@ struct ReplacementDCT2D : public hal::DCT2D namespace hal { -Ptr DCT2D::create(int width, int height, int depth, int flags) +Ptr DCT2D::create(int width, int height, ElemType depth, int flags) { { ReplacementDCT2D *impl = new ReplacementDCT2D(); @@ -4239,7 +4247,8 @@ void cv::dct( InputArray _src0, OutputArray _dst, int flags ) CV_INSTRUMENT_REGION(); Mat src0 = _src0.getMat(), src = src0; - int type = src.type(), depth = src.depth(); + ElemType type = src.type(); + ElemType depth = src.depth(); CV_Assert( type == CV_32FC1 || type == CV_64FC1 ); _dst.create( src.rows, src.cols, type ); diff --git a/modules/core/src/hal_replacement.hpp b/modules/core/src/hal_replacement.hpp index 1a558f253278..e837ae850aa2 100644 --- a/modules/core/src/hal_replacement.hpp +++ b/modules/core/src/hal_replacement.hpp @@ -507,7 +507,7 @@ struct cvhalDFT {}; @param flags algorithm options (combination of CV_HAL_DFT_INVERSE, CV_HAL_DFT_SCALE, ...) @param needBuffer pointer to boolean variable, if valid pointer provided, then variable value should be set to true to signal that additional memory buffer is needed for operations */ -inline int hal_ni_dftInit1D(cvhalDFT **context, int len, int count, int depth, int flags, bool *needBuffer) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_dftInit1D(cvhalDFT **context, int len, int count, ElemType depth, int flags, bool *needBuffer) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @param context pointer to context storing all necessary data @param src source data @@ -534,7 +534,7 @@ inline int hal_ni_dftFree1D(cvhalDFT *context) { return CV_HAL_ERROR_NOT_IMPLEME @param flags algorithm options (combination of CV_HAL_DFT_INVERSE, ...) @param nonzero_rows number of nonzero rows in image, can be used for optimization */ -inline int hal_ni_dftInit2D(cvhalDFT **context, int width, int height, int depth, int src_channels, int dst_channels, int flags, int nonzero_rows) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_dftInit2D(cvhalDFT **context, int width, int height, ElemType depth, int src_channels, int dst_channels, int flags, int nonzero_rows) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @param context pointer to context storing all necessary data @param src_data,src_step source image data and step @@ -558,7 +558,7 @@ inline int hal_ni_dftFree2D(cvhalDFT *context) { return CV_HAL_ERROR_NOT_IMPLEME @param depth image type (CV_32F or CV64F) @param flags algorithm options (combination of CV_HAL_DFT_INVERSE, ...) */ -inline int hal_ni_dctInit2D(cvhalDFT **context, int width, int height, int depth, int flags) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_dctInit2D(cvhalDFT **context, int width, int height, ElemType depth, int flags) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @param context pointer to context storing all necessary data @param src_data,src_step source image data and step @@ -721,7 +721,7 @@ inline int hal_ni_gemm64fc(const double* src1, size_t src1_step, const double* s @param minIdx,maxIdx Pointer to the returned minimum and maximum location. @param mask Specified array region. */ -inline int hal_ni_minMaxIdx(const uchar* src_data, size_t src_step, int width, int height, int depth, double* minVal, double* maxVal, +inline int hal_ni_minMaxIdx(const uchar* src_data, size_t src_step, int width, int height, ElemType depth, double* minVal, double* maxVal, int* minIdx, int* maxIdx, uchar* mask) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } //! @cond IGNORED diff --git a/modules/core/src/lapack.cpp b/modules/core/src/lapack.cpp index d8ceaf6abbc9..666f27e2d9cf 100644 --- a/modules/core/src/lapack.cpp +++ b/modules/core/src/lapack.cpp @@ -765,7 +765,8 @@ double cv::determinant( InputArray _mat ) Mat mat = _mat.getMat(); double result = 0; - int type = mat.type(), rows = mat.rows; + ElemType type = mat.type(); + int rows = mat.rows; size_t step = mat.step; const uchar* m = mat.ptr(); @@ -1401,7 +1402,7 @@ bool cv::eigen( InputArray _src, OutputArray _evals, OutputArray _evects ) CV_INSTRUMENT_REGION(); Mat src = _src.getMat(); - int type = src.type(); + ElemType type = src.type(); int n = src.rows; CV_Assert( src.rows == src.cols ); @@ -1478,7 +1479,7 @@ static void _SVDcompute( InputArray _aarr, OutputArray _w, { Mat src = _aarr.getMat(); int m = src.rows, n = src.cols; - int type = src.type(); + ElemType type = src.type(); bool compute_uv = _u.needed() || _vt.needed(); bool full_uv = (flags & SVD::FULL_UV) != 0; @@ -1566,7 +1567,8 @@ void SVD::backSubst( InputArray _w, InputArray _u, InputArray _vt, InputArray _rhs, OutputArray _dst ) { Mat w = _w.getMat(), u = _u.getMat(), vt = _vt.getMat(), rhs = _rhs.getMat(); - int type = w.type(), esz = (int)w.elemSize(); + ElemType type = w.type(); + int esz = (int)w.elemSize(); int m = u.rows, n = vt.cols, nb = rhs.data ? rhs.cols : m, nm = std::min(m, n); size_t wstep = w.rows == 1 ? (size_t)esz : w.cols == 1 ? (size_t)w.step : (size_t)w.step + esz; AutoBuffer buffer(nb*sizeof(double) + 16); @@ -1626,7 +1628,7 @@ cvDet( const CvArr* arr ) if( CV_IS_MAT(arr) && ((CvMat*)arr)->rows <= 3 ) { CvMat* mat = (CvMat*)arr; - int type = CV_MAT_TYPE(mat->type); + ElemType type = CV_MAT_TYPE(mat->type); int rows = mat->rows; uchar* m = mat->data.ptr; int step = mat->step; @@ -1717,7 +1719,8 @@ CV_IMPL void cvSVD( CvArr* aarr, CvArr* warr, CvArr* uarr, CvArr* varr, int flags ) { cv::Mat a = cv::cvarrToMat(aarr), w = cv::cvarrToMat(warr), u, v; - int m = a.rows, n = a.cols, type = a.type(), mn = std::max(m, n), nm = std::min(m, n); + int m = a.rows, n = a.cols, mn = std::max(m, n), nm = std::min(m, n); + ElemType type = a.type(); CV_Assert( w.type() == type && (w.size() == cv::Size(nm,1) || w.size() == cv::Size(1, nm) || diff --git a/modules/core/src/lda.cpp b/modules/core/src/lda.cpp index a339b391363c..053dffedb51f 100644 --- a/modules/core/src/lda.cpp +++ b/modules/core/src/lda.cpp @@ -51,7 +51,7 @@ static Mat argsort(InputArray _src, bool ascending=true) return sorted_indices; } -static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double beta=0) { +static Mat asRowMatrix(InputArrayOfArrays src, ElemType rtype, double alpha = 1, double beta = 0) { // make sure the input data is a vector of matrices or vector of vector if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_ARRAY_MAT && src.kind() != _InputArray::STD_VECTOR_VECTOR) { @@ -947,7 +947,8 @@ void eigenNonSymmetric(InputArray _src, OutputArray _evals, OutputArray _evects) CV_INSTRUMENT_REGION(); Mat src = _src.getMat(); - int type = src.type(); + ElemType type = src.type(); + ElemType depth = src.depth(); size_t n = (size_t)src.rows; CV_Assert(src.rows == src.cols); diff --git a/modules/core/src/lut.cpp b/modules/core/src/lut.cpp index 3b45b906e0a7..309812544b0e 100644 --- a/modules/core/src/lut.cpp +++ b/modules/core/src/lut.cpp @@ -78,7 +78,8 @@ static LUTFunc lutTab[] = static bool ocl_LUT(InputArray _src, InputArray _lut, OutputArray _dst) { - int lcn = _lut.channels(), dcn = _src.channels(), ddepth = _lut.depth(); + int lcn = _lut.channels(), dcn = _src.channels(); + ElemType ddepth = _lut.depth(); UMat src = _src.getUMat(), lut = _lut.getUMat(); _dst.create(src.size(), CV_MAKETYPE(ddepth, dcn)); @@ -360,7 +361,8 @@ void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst ) { CV_INSTRUMENT_REGION(); - int cn = _src.channels(), depth = _src.depth(); + int cn = _src.channels(); + ElemType depth = _src.depth(); int lutcn = _lut.channels(); CV_Assert( (lutcn == cn || lutcn == 1) && diff --git a/modules/core/src/mathfuncs.cpp b/modules/core/src/mathfuncs.cpp index e8067b512813..c16b8523ad4e 100644 --- a/modules/core/src/mathfuncs.cpp +++ b/modules/core/src/mathfuncs.cpp @@ -60,7 +60,9 @@ static const char* oclop2str[] = { "OP_LOG", "OP_EXP", "OP_MAG", "OP_PHASE_DEGRE static bool ocl_math_op(InputArray _src1, InputArray _src2, OutputArray _dst, int oclop) { - int type = _src1.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src1.type(); + ElemType depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); int kercn = oclop == OCL_OP_PHASE_DEGREES || oclop == OCL_OP_PHASE_RADIANS ? 1 : ocl::predictOptimalVectorWidth(_src1, _src2, _dst); @@ -147,7 +149,9 @@ void magnitude( InputArray src1, InputArray src2, OutputArray dst ) { CV_INSTRUMENT_REGION(); - int type = src1.type(), depth = src1.depth(), cn = src1.channels(); + int type = src1.type(); + ElemType depth = src1.depth(); + int cn = src1.channels(); CV_Assert( src1.size() == src2.size() && type == src2.type() && (depth == CV_32F || depth == CV_64F)); CV_OCL_RUN(dst.isUMat() && src1.dims() <= 2 && src2.dims() <= 2, @@ -183,7 +187,9 @@ void phase( InputArray src1, InputArray src2, OutputArray dst, bool angleInDegre { CV_INSTRUMENT_REGION(); - int type = src1.type(), depth = src1.depth(), cn = src1.channels(); + ElemType type = src1.type(); + ElemType depth = src1.depth(); + int cn = src1.channels(); CV_Assert( src1.size() == src2.size() && type == src2.type() && (depth == CV_32F || depth == CV_64F)); CV_OCL_RUN(dst.isUMat() && src1.dims() <= 2 && src2.dims() <= 2, @@ -228,7 +234,9 @@ static bool ocl_cartToPolar( InputArray _src1, InputArray _src2, OutputArray _dst1, OutputArray _dst2, bool angleInDegrees ) { const ocl::Device & d = ocl::Device::getDefault(); - int type = _src1.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), + ElemType type = _src1.type(); + ElemType depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), rowsPerWI = d.isIntel() ? 4 : 1; bool doubleSupport = d.doubleFPConfig() > 0; @@ -273,7 +281,9 @@ void cartToPolar( InputArray src1, InputArray src2, ocl_cartToPolar(src1, src2, dst1, dst2, angleInDegrees)) Mat X = src1.getMat(), Y = src2.getMat(); - int type = X.type(), depth = X.depth(), cn = X.channels(); + ElemType type = X.type(); + ElemType depth = X.depth(); + int cn = X.channels(); CV_Assert( X.size == Y.size && type == Y.type() && (depth == CV_32F || depth == CV_64F)); dst1.create( X.dims, X.size, type ); dst2.create( X.dims, X.size, type ); @@ -466,7 +476,9 @@ static bool ocl_polarToCart( InputArray _mag, InputArray _angle, OutputArray _dst1, OutputArray _dst2, bool angleInDegrees ) { const ocl::Device & d = ocl::Device::getDefault(); - int type = _angle.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), + ElemType type = _angle.type(); + ElemType depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), rowsPerWI = d.isIntel() ? 4 : 1; bool doubleSupport = d.doubleFPConfig() > 0; @@ -503,7 +515,7 @@ static bool ipp_polarToCart(Mat &mag, Mat &angle, Mat &x, Mat &y) { CV_INSTRUMENT_REGION_IPP(); - int depth = angle.depth(); + ElemType depth = angle.depth(); if(depth != CV_32F && depth != CV_64F) return false; @@ -562,7 +574,9 @@ void polarToCart( InputArray src1, InputArray src2, { CV_INSTRUMENT_REGION(); - int type = src2.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = src2.type(); + ElemType depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); CV_Assert((depth == CV_32F || depth == CV_64F) && (src1.empty() || src1.type() == type)); CV_OCL_RUN(!src1.empty() && src2.dims() <= 2 && dst1.isUMat() && dst2.isUMat(), @@ -665,7 +679,9 @@ void exp( InputArray _src, OutputArray _dst ) { CV_INSTRUMENT_REGION(); - int type = _src.type(), depth = _src.depth(), cn = _src.channels(); + ElemType type = _src.type(); + ElemType depth = _src.depth(); + int cn = _src.channels(); CV_Assert( depth == CV_32F || depth == CV_64F ); CV_OCL_RUN(_dst.isUMat() && _src.dims() <= 2, @@ -698,7 +714,9 @@ void log( InputArray _src, OutputArray _dst ) { CV_INSTRUMENT_REGION(); - int type = _src.type(), depth = _src.depth(), cn = _src.channels(); + ElemType type = _src.type(); + ElemType depth = _src.depth(); + int cn = _src.channels(); CV_Assert( depth == CV_32F || depth == CV_64F ); CV_OCL_RUN( _dst.isUMat() && _src.dims() <= 2, @@ -1136,7 +1154,9 @@ static bool ocl_pow(InputArray _src, double power, OutputArray _dst, bool is_ipower, int ipower) { const ocl::Device & d = ocl::Device::getDefault(); - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), + ElemType type = _src.type(); + ElemType depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), rowsPerWI = d.isIntel() ? 4 : 1; bool doubleSupport = d.doubleFPConfig() > 0; @@ -1204,8 +1224,9 @@ void pow( InputArray _src, double power, OutputArray _dst ) { CV_INSTRUMENT_REGION(); - int type = _src.type(), depth = CV_MAT_DEPTH(type), - cn = CV_MAT_CN(type), ipower = cvRound(power); + ElemType type = _src.type(); + ElemType depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), ipower = cvRound(power); bool is_ipower = fabs(ipower - power) < DBL_EPSILON; #ifdef HAVE_OPENCL bool useOpenCL = _dst.isUMat() && _src.dims() <= 2; @@ -1396,7 +1417,7 @@ template<> struct mat_type_assotiations static const type max_allowable = INT_MAX; }; -template +template static bool checkIntegerRange(cv::Mat src, Point& bad_pt, int minVal, int maxVal) { typedef mat_type_assotiations type_ass; @@ -1462,7 +1483,7 @@ bool checkRange(InputArray _src, bool quiet, Point* pt, double minVal, double ma return true; } - int depth = src.depth(); + ElemType depth = src.depth(); Point badPt(-1, -1); if (depth < CV_32F) @@ -1890,8 +1911,8 @@ double cv::solvePoly( InputArray _coeffs0, OutputArray _roots0, int maxIters ) double maxDiff = 0; int iter, i, j; Mat coeffs0 = _coeffs0.getMat(); - int ctype = _coeffs0.type(); - int cdepth = CV_MAT_DEPTH(ctype); + ElemType ctype = _coeffs0.type(); + ElemType cdepth = CV_MAT_DEPTH(ctype); CV_Assert( CV_MAT_DEPTH(ctype) >= CV_32F && CV_MAT_CN(ctype) <= 2 ); CV_Assert( coeffs0.rows == 1 || coeffs0.cols == 1 ); diff --git a/modules/core/src/matmul.cpp b/modules/core/src/matmul.cpp index 7cd89c622210..003ff157f082 100644 --- a/modules/core/src/matmul.cpp +++ b/modules/core/src/matmul.cpp @@ -700,7 +700,8 @@ static void GEMMStore_64fc( const Complexd* c_data, size_t c_step, static bool ocl_gemm_amdblas( InputArray matA, InputArray matB, double alpha, InputArray matC, double beta, OutputArray matD, int flags ) { - int type = matA.type(), esz = CV_ELEM_SIZE(type); + ElemType type = matA.type(); + int esz = CV_ELEM_SIZE(type); bool haveC = matC.kind() != cv::_InputArray::NONE; Size sizeA = matA.size(), sizeB = matB.size(), sizeC = haveC ? matC.size() : Size(0, 0); bool atrans = (flags & GEMM_1_T) != 0, btrans = (flags & GEMM_2_T) != 0, ctrans = (flags & GEMM_3_T) != 0; @@ -793,8 +794,9 @@ static bool ocl_gemm_amdblas( InputArray matA, InputArray matB, double alpha, static bool ocl_gemm( InputArray matA, InputArray matB, double alpha, InputArray matC, double beta, OutputArray matD, int flags ) { - int depth = matA.depth(), cn = matA.channels(); - int type = CV_MAKETYPE(depth, cn); + ElemType depth = matA.depth(); + int cn = matA.channels(); + ElemType type = CV_MAKETYPE(depth, cn); CV_Assert_N( type == matB.type(), (type == CV_32FC1 || type == CV_64FC1 || type == CV_32FC2 || type == CV_64FC2) ); @@ -905,7 +907,8 @@ static void gemmImpl( Mat A, Mat B, double alpha, static float zerof[] = {0,0,0,0}; Size a_size = A.size(), d_size; - int i, len = 0, type = A.type(); + int i, len = 0; + ElemType type = A.type(); switch( flags & (GEMM_1_T|GEMM_2_T) ) { @@ -1442,7 +1445,7 @@ static void gemmImpl( Mat A, Mat B, double alpha, template inline static void callGemmImpl(const fptype *src1, size_t src1_step, const fptype *src2, size_t src2_step, fptype alpha, - const fptype *src3, size_t src3_step, fptype beta, fptype *dst, size_t dst_step, int m_a, int n_a, int n_d, int flags, int type) + const fptype *src3, size_t src3_step, fptype beta, fptype *dst, size_t dst_step, int m_a, int n_a, int n_d, int flags, ElemType type) { CV_StaticAssert(GEMM_1_T == CV_HAL_GEMM_1_T, "Incompatible GEMM_1_T flag in HAL"); CV_StaticAssert(GEMM_2_T == CV_HAL_GEMM_2_T, "Incompatible GEMM_2_T flag in HAL"); @@ -1553,7 +1556,8 @@ void cv::gemm( InputArray matA, InputArray matB, double alpha, Mat A = matA.getMat(), B = matB.getMat(), C = beta != 0.0 ? matC.getMat() : Mat(); Size a_size = A.size(), d_size; - int len = 0, type = A.type(); + int len = 0; + ElemType type = A.type(); CV_Assert_N( type == B.type(), (type == CV_32FC1 || type == CV_64FC1 || type == CV_32FC2 || type == CV_64FC2) ); @@ -2053,7 +2057,7 @@ diagtransform_64f(const double* src, double* dst, const double* m, int len, int typedef void (*TransformFunc)( const uchar* src, uchar* dst, const uchar* m, int, int, int ); -static TransformFunc getTransformFunc(int depth) +static TransformFunc getTransformFunc(ElemType depth) { static TransformFunc transformTab[] = { @@ -2065,7 +2069,7 @@ static TransformFunc getTransformFunc(int depth) return transformTab[depth]; } -static TransformFunc getDiagTransformFunc(int depth) +static TransformFunc getDiagTransformFunc(ElemType depth) { static TransformFunc diagTransformTab[] = { @@ -2084,7 +2088,8 @@ void cv::transform( InputArray _src, OutputArray _dst, InputArray _mtx ) CV_INSTRUMENT_REGION(); Mat src = _src.getMat(), m = _mtx.getMat(); - int depth = src.depth(), scn = src.channels(), dcn = m.rows; + ElemType depth = src.depth(); + int scn = src.channels(), dcn = m.rows; CV_Assert( scn == m.cols || scn + 1 == m.cols ); bool isDiag = false; @@ -2264,7 +2269,8 @@ void cv::perspectiveTransform( InputArray _src, OutputArray _dst, InputArray _mt CV_INSTRUMENT_REGION(); Mat src = _src.getMat(), m = _mtx.getMat(); - int depth = src.depth(), scn = src.channels(), dcn = m.rows-1; + ElemType depth = src.depth(); + int scn = src.channels(), dcn = m.rows - 1; CV_Assert( scn + 1 == m.cols ); CV_Assert( depth == CV_32F || depth == CV_64F ); @@ -2358,18 +2364,19 @@ typedef void (*ScaleAddFunc)(const uchar* src1, const uchar* src2, uchar* dst, i #ifdef HAVE_OPENCL -static bool ocl_scaleAdd( InputArray _src1, double alpha, InputArray _src2, OutputArray _dst, int type ) +static bool ocl_scaleAdd(InputArray _src1, double alpha, InputArray _src2, OutputArray _dst, ElemType type) { const ocl::Device & d = ocl::Device::getDefault(); bool doubleSupport = d.doubleFPConfig() > 0; Size size = _src1.size(); - int depth = CV_MAT_DEPTH(type); + ElemType depth = CV_MAT_DEPTH(type); if ( (!doubleSupport && depth == CV_64F) || size != _src2.size() ) return false; _dst.create(size, type); - int cn = CV_MAT_CN(type), wdepth = std::max(depth, CV_32F); + int cn = CV_MAT_CN(type); + ElemType wdepth = CV_MAX_DEPTH(depth, CV_32F); int kercn = ocl::predictOptimalVectorWidthMax(_src1, _src2, _dst), rowsPerWI = d.isIntel() ? 4 : 1; @@ -2410,7 +2417,9 @@ void cv::scaleAdd( InputArray _src1, double alpha, InputArray _src2, OutputArray { CV_INSTRUMENT_REGION(); - int type = _src1.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src1.type(); + ElemType depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); CV_Assert( type == _src2.type() ); CV_OCL_RUN(_src1.dims() <= 2 && _src2.dims() <= 2 && _dst.isUMat(), @@ -2453,25 +2462,26 @@ void cv::scaleAdd( InputArray _src1, double alpha, InputArray _src2, OutputArray * Covariation Matrix * \****************************************************************************************/ -void cv::calcCovarMatrix( const Mat* data, int nsamples, Mat& covar, Mat& _mean, int flags, int ctype ) +void cv::calcCovarMatrix( const Mat* data, int nsamples, Mat& covar, Mat& _mean, int flags, ElemType cdepth ) { CV_INSTRUMENT_REGION(); CV_Assert_N( data, nsamples > 0 ); Size size = data[0].size(); int sz = size.width * size.height, esz = (int)data[0].elemSize(); - int type = data[0].type(); + ElemType type = data[0].type(); Mat mean; - ctype = std::max(std::max(CV_MAT_DEPTH(ctype >= 0 ? ctype : type), _mean.depth()), CV_32F); + cdepth = CV_MAT_DEPTH(cdepth); /* backwards compatibility */ + cdepth = CV_MAX_DEPTH(cdepth >= CV_8U ? cdepth : CV_MAT_DEPTH(type), _mean.depth(), CV_32F); if( (flags & CV_COVAR_USE_AVG) != 0 ) { CV_Assert( _mean.size() == size ); - if( _mean.isContinuous() && _mean.type() == ctype ) + if (_mean.isContinuous() && _mean.depth() == cdepth) mean = _mean.reshape(1, 1); else { - _mean.convertTo(mean, ctype); + _mean.convertTo(mean, cdepth); mean = mean.reshape(1, 1); } } @@ -2490,15 +2500,16 @@ void cv::calcCovarMatrix( const Mat* data, int nsamples, Mat& covar, Mat& _mean, } } - calcCovarMatrix( _data, covar, mean, (flags & ~(CV_COVAR_ROWS|CV_COVAR_COLS)) | CV_COVAR_ROWS, ctype ); + calcCovarMatrix(_data, covar, mean, (flags & ~(CV_COVAR_ROWS | CV_COVAR_COLS)) | CV_COVAR_ROWS, cdepth); if( (flags & CV_COVAR_USE_AVG) == 0 ) _mean = mean.reshape(1, size.height); } -void cv::calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray _mean, int flags, int ctype ) +void cv::calcCovarMatrix(InputArray _src, OutputArray _covar, InputOutputArray _mean, int flags, ElemType cdepth) { CV_INSTRUMENT_REGION(); + cdepth = CV_MAT_DEPTH(cdepth); /* backwards compatibility */ if(_src.kind() == _InputArray::STD_VECTOR_MAT || _src.kind() == _InputArray::STD_ARRAY_MAT) { std::vector src; @@ -2507,9 +2518,9 @@ void cv::calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray CV_Assert( src.size() > 0 ); Size size = src[0].size(); - int type = src[0].type(); + ElemType type = src[0].type(); - ctype = std::max(std::max(CV_MAT_DEPTH(ctype >= 0 ? ctype : type), _mean.depth()), CV_32F); + cdepth = CV_MAX_DEPTH(cdepth >= CV_8U ? cdepth : CV_MAT_DEPTH(type), _mean.depth(), CV_32F); Mat _data(static_cast(src.size()), size.area(), type); @@ -2526,19 +2537,19 @@ void cv::calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray { CV_Assert( _mean.size() == size ); - if( mean.type() != ctype ) + if (mean.depth() != cdepth) { mean = _mean.getMat(); - _mean.create(mean.size(), ctype); + _mean.create(mean.size(), cdepth); Mat tmp = _mean.getMat(); - mean.convertTo(tmp, ctype); + mean.convertTo(tmp, cdepth); mean = tmp; } mean = _mean.getMat().reshape(1, 1); } - calcCovarMatrix( _data, _covar, mean, (flags & ~(CV_COVAR_ROWS|CV_COVAR_COLS)) | CV_COVAR_ROWS, ctype ); + calcCovarMatrix(_data, _covar, mean, (flags & ~(CV_COVAR_ROWS | CV_COVAR_COLS)) | CV_COVAR_ROWS, cdepth); if( (flags & CV_COVAR_USE_AVG) == 0 ) { @@ -2551,7 +2562,7 @@ void cv::calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray Mat data = _src.getMat(), mean; CV_Assert( ((flags & CV_COVAR_ROWS) != 0) ^ ((flags & CV_COVAR_COLS) != 0) ); bool takeRows = (flags & CV_COVAR_ROWS) != 0; - int type = data.type(); + ElemType type = data.type(); int nsamples = takeRows ? data.rows : data.cols; CV_Assert( nsamples > 0 ); Size size = takeRows ? Size(data.cols, 1) : Size(1, data.rows); @@ -2559,25 +2570,25 @@ void cv::calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray if( (flags & CV_COVAR_USE_AVG) != 0 ) { mean = _mean.getMat(); - ctype = std::max(std::max(CV_MAT_DEPTH(ctype >= 0 ? ctype : type), mean.depth()), CV_32F); + cdepth = CV_MAX_DEPTH(cdepth >= CV_8U ? cdepth : CV_MAT_DEPTH(type), mean.depth(), CV_32F); CV_Assert( mean.size() == size ); - if( mean.type() != ctype ) + if (mean.depth() != cdepth) { - _mean.create(mean.size(), ctype); + _mean.create(mean.size(), cdepth); Mat tmp = _mean.getMat(); - mean.convertTo(tmp, ctype); + mean.convertTo(tmp, cdepth); mean = tmp; } } else { - ctype = std::max(CV_MAT_DEPTH(ctype >= 0 ? ctype : type), CV_32F); - reduce( _src, _mean, takeRows ? 0 : 1, CV_REDUCE_AVG, ctype ); + cdepth = CV_MAX_DEPTH(cdepth >= CV_8U ? cdepth : CV_MAT_DEPTH(type), CV_32F); + reduce(_src, _mean, takeRows ? 0 : 1, CV_REDUCE_AVG, cdepth); mean = _mean.getMat(); } mulTransposed( data, _covar, ((flags & CV_COVAR_NORMAL) == 0) ^ takeRows, - mean, (flags & CV_COVAR_SCALE) != 0 ? 1./nsamples : 1, ctype ); + mean, (flags & CV_COVAR_SCALE) != 0 ? 1. / nsamples : 1, cdepth); } /****************************************************************************************\ @@ -2589,7 +2600,8 @@ double cv::Mahalanobis( InputArray _v1, InputArray _v2, InputArray _icovar ) CV_INSTRUMENT_REGION(); Mat v1 = _v1.getMat(), v2 = _v2.getMat(), icovar = _icovar.getMat(); - int type = v1.type(), depth = v1.depth(); + ElemType type = v1.type(); + ElemType depth = v1.depth(); Size sz = v1.size(); int i, j, len = sz.width*sz.height*v1.channels(); AutoBuffer buf(len); @@ -2876,14 +2888,14 @@ typedef void (*MulTransposedFunc)(const Mat& src, Mat& dst, const Mat& delta, do } void cv::mulTransposed( InputArray _src, OutputArray _dst, bool ata, - InputArray _delta, double scale, int dtype ) + InputArray _delta, double scale, ElemType ddepth ) { CV_INSTRUMENT_REGION(); Mat src = _src.getMat(), delta = _delta.getMat(); const int gemm_level = 100; // boundary above which GEMM is faster. - int stype = src.type(); - dtype = std::max(std::max(CV_MAT_DEPTH(dtype >= 0 ? dtype : stype), delta.depth()), CV_32F); + ElemType sdepth = src.depth(); + ddepth = CV_MAX_DEPTH(ddepth >= CV_8U ? ddepth : sdepth, delta.depth(), CV_32F); CV_Assert( src.channels() == 1 ); if( !delta.empty() ) @@ -2891,15 +2903,15 @@ void cv::mulTransposed( InputArray _src, OutputArray _dst, bool ata, CV_Assert_N( delta.channels() == 1, (delta.rows == src.rows || delta.rows == 1), (delta.cols == src.cols || delta.cols == 1)); - if( delta.type() != dtype ) - delta.convertTo(delta, dtype); + if (delta.depth() != ddepth) + delta.convertTo(delta, ddepth); } int dsize = ata ? src.cols : src.rows; - _dst.create( dsize, dsize, dtype ); + _dst.create(dsize, dsize, ddepth); Mat dst = _dst.getMat(); - if( src.data == dst.data || (stype == dtype && + if (src.data == dst.data || (sdepth == ddepth && (dst.cols >= gemm_level && dst.rows >= gemm_level && src.cols >= gemm_level && src.rows >= gemm_level))) { @@ -2921,63 +2933,63 @@ void cv::mulTransposed( InputArray _src, OutputArray _dst, bool ata, else { MulTransposedFunc func = 0; - if(stype == CV_8U && dtype == CV_32F) + if (sdepth == CV_8U && ddepth == CV_32F) { if(ata) func = MulTransposedR; else func = MulTransposedL; } - else if(stype == CV_8U && dtype == CV_64F) + else if (sdepth == CV_8U && ddepth == CV_64F) { if(ata) func = MulTransposedR; else func = MulTransposedL; } - else if(stype == CV_16U && dtype == CV_32F) + else if (sdepth == CV_16U && ddepth == CV_32F) { if(ata) func = MulTransposedR; else func = MulTransposedL; } - else if(stype == CV_16U && dtype == CV_64F) + else if (sdepth == CV_16U && ddepth == CV_64F) { if(ata) func = MulTransposedR; else func = MulTransposedL; } - else if(stype == CV_16S && dtype == CV_32F) + else if (sdepth == CV_16S && ddepth == CV_32F) { if(ata) func = MulTransposedR; else func = MulTransposedL; } - else if(stype == CV_16S && dtype == CV_64F) + else if (sdepth == CV_16S && ddepth == CV_64F) { if(ata) func = MulTransposedR; else func = MulTransposedL; } - else if(stype == CV_32F && dtype == CV_32F) + else if (sdepth == CV_32F && ddepth == CV_32F) { if(ata) func = MulTransposedR; else func = MulTransposedL; } - else if(stype == CV_32F && dtype == CV_64F) + else if (sdepth == CV_32F && ddepth == CV_64F) { if(ata) func = MulTransposedR; else func = MulTransposedL; } - else if(stype == CV_64F && dtype == CV_64F) + else if (sdepth == CV_64F && ddepth == CV_64F) { if(ata) func = MulTransposedR; @@ -3271,7 +3283,7 @@ static double dotProd_64f(const double* src1, const double* src2, int len) typedef double (*DotProdFunc)(const uchar* src1, const uchar* src2, int len); -static DotProdFunc getDotProdFunc(int depth) +static DotProdFunc getDotProdFunc(ElemType depth) { static DotProdFunc dotProdTab[] = { @@ -3389,14 +3401,14 @@ cvCalcCovarMatrix( const CvArr** vecarr, int count, { cv::Mat data = cv::cvarrToMat(vecarr[0]); - cv::calcCovarMatrix( data, cov, mean, flags, cov.type() ); + cv::calcCovarMatrix( data, cov, mean, flags, cov.depth() ); } else { std::vector data(count); for( int i = 0; i < count; i++ ) data[i] = cv::cvarrToMat(vecarr[i]); - cv::calcCovarMatrix( &data[0], count, cov, mean, flags, cov.type() ); + cv::calcCovarMatrix(&data[0], count, cov, mean, flags, cov.depth()); } if( mean.data != mean0.data && mean0.data ) @@ -3421,7 +3433,7 @@ cvMulTransposed( const CvArr* srcarr, CvArr* dstarr, cv::Mat src = cv::cvarrToMat(srcarr), dst0 = cv::cvarrToMat(dstarr), dst = dst0, delta; if( deltaarr ) delta = cv::cvarrToMat(deltaarr); - cv::mulTransposed( src, dst, order != 0, delta, scale, dst.type()); + cv::mulTransposed( src, dst, order != 0, delta, scale, dst.depth()); if( dst.data != dst0.data ) dst.convertTo(dst0, dst0.type()); } diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index a353eee8c432..976e47d73bff 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -126,7 +126,7 @@ BufferPoolController* MatAllocator::getBufferPoolController(const char* id) cons class StdMatAllocator CV_FINAL : public MatAllocator { public: - UMatData* allocate(int dims, const int* sizes, int type, + UMatData* allocate(int dims, const int* sizes, ElemType type, void* data0, size_t* step, AccessFlag /*flags*/, UMatUsageFlags /*usageFlags*/) const CV_OVERRIDE { size_t total = CV_ELEM_SIZE(type); @@ -262,7 +262,7 @@ void setSize( Mat& m, int _dims, const int* _sz, const size_t* _steps, bool auto } } -int updateContinuityFlag(int flags, int dims, const int* size, const size_t* step) +MagicFlag updateContinuityFlag(MagicFlag flags, int dims, const int* size, const size_t* step) { int i, j; for( i = 0; i < dims; i++ ) @@ -280,8 +280,8 @@ int updateContinuityFlag(int flags, int dims, const int* size, const size_t* ste } if( j <= i && t == (uint64)(int)t ) - return flags | Mat::CONTINUOUS_FLAG; - return flags & ~Mat::CONTINUOUS_FLAG; + return flags | static_cast(Mat::CONTINUOUS_FLAG); + return flags & static_cast(~Mat::CONTINUOUS_FLAG); } void Mat::updateContinuityFlag() @@ -315,7 +315,7 @@ void finalizeHdr(Mat& m) //================================================================================================== -void Mat::create(int d, const int* _sizes, int _type) +void Mat::create(int d, const int* _sizes, ElemType _type) { int i; CV_Assert(0 <= d && d <= CV_MAX_DIM && _sizes); @@ -343,7 +343,7 @@ void Mat::create(int d, const int* _sizes, int _type) release(); if( d == 0 ) return; - flags = (_type & CV_MAT_TYPE_MASK) | MAGIC_VAL; + flags = static_cast(MAGIC_VAL) | (_type & CV_MAT_TYPE_MASK); setSize(*this, d, _sizes, 0, true); if( total() > 0 ) @@ -373,7 +373,7 @@ void Mat::create(int d, const int* _sizes, int _type) finalizeHdr(*this); } -void Mat::create(const std::vector& _sizes, int _type) +void Mat::create(const std::vector& _sizes, ElemType _type) { create((int)_sizes.size(), _sizes.data(), _type); } @@ -399,7 +399,7 @@ void Mat::deallocate() } Mat::Mat(const Mat& m, const Range& _rowRange, const Range& _colRange) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows) { CV_Assert( m.dims >= 2 ); @@ -423,7 +423,7 @@ Mat::Mat(const Mat& m, const Range& _rowRange, const Range& _colRange) && _rowRange.end <= m.rows ); rows = _rowRange.size(); data += step*_rowRange.start; - flags |= SUBMATRIX_FLAG; + flags |= static_cast(SUBMATRIX_FLAG); } if( _colRange != Range::all() && _colRange != Range(0,cols) ) @@ -432,7 +432,7 @@ Mat::Mat(const Mat& m, const Range& _rowRange, const Range& _colRange) && _colRange.end <= m.cols ); cols = _colRange.size(); data += _colRange.start*elemSize(); - flags |= SUBMATRIX_FLAG; + flags |= static_cast(SUBMATRIX_FLAG); } } CV_CATCH_ALL @@ -466,7 +466,7 @@ Mat::Mat(const Mat& m, const Rect& roi) if( u ) CV_XADD(&u->refcount, 1); if( roi.width < m.cols || roi.height < m.rows ) - flags |= SUBMATRIX_FLAG; + flags |= static_cast(SUBMATRIX_FLAG); step[0] = m.step[0]; step[1] = esz; updateContinuityFlag(); @@ -479,8 +479,8 @@ Mat::Mat(const Mat& m, const Rect& roi) } -Mat::Mat(int _dims, const int* _sizes, int _type, void* _data, const size_t* _steps) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), +Mat::Mat(int _dims, const int* _sizes, ElemType _type, void* _data, const size_t* _steps) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows) { flags |= CV_MAT_TYPE(_type); @@ -490,8 +490,8 @@ Mat::Mat(int _dims, const int* _sizes, int _type, void* _data, const size_t* _st } -Mat::Mat(const std::vector& _sizes, int _type, void* _data, const size_t* _steps) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), +Mat::Mat(const std::vector& _sizes, ElemType _type, void* _data, const size_t* _steps) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows) { flags |= CV_MAT_TYPE(_type); @@ -502,7 +502,7 @@ Mat::Mat(const std::vector& _sizes, int _type, void* _data, const size_t* _ Mat::Mat(const Mat& m, const Range* ranges) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows) { int d = m.dims; @@ -521,14 +521,14 @@ Mat::Mat(const Mat& m, const Range* ranges) { size.p[i] = r.end - r.start; data += r.start*step.p[i]; - flags |= SUBMATRIX_FLAG; + flags |= static_cast(SUBMATRIX_FLAG); } } updateContinuityFlag(); } Mat::Mat(const Mat& m, const std::vector& ranges) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows) { int d = m.dims; @@ -547,7 +547,7 @@ Mat::Mat(const Mat& m, const std::vector& ranges) { size.p[i] = r.end - r.start; data += r.start*step.p[i]; - flags |= SUBMATRIX_FLAG; + flags |= static_cast(SUBMATRIX_FLAG); } } updateContinuityFlag(); @@ -580,7 +580,7 @@ Mat Mat::diag(int d) const m.updateContinuityFlag(); if( size() != Size(1,1) ) - m.flags |= SUBMATRIX_FLAG; + m.flags |= static_cast(SUBMATRIX_FLAG); return m; } @@ -614,7 +614,7 @@ void Mat::push_back_(const void* elem) for( int i = 1; i < dims; i++ ) tsz *= size.p[i]; if( esz < step.p[0] || tsz != (uint64)(int)tsz ) - flags &= ~CONTINUOUS_FLAG; + flags &= static_cast(~CONTINUOUS_FLAG); } @@ -654,7 +654,7 @@ void Mat::reserve(size_t nelems) void Mat::reserveBuffer(size_t nbytes) { size_t esz = 1; - int mtype = CV_8UC1; + ElemType mtype = CV_8UC1; if (!empty()) { if (!isSubmatrix() && data + nbytes <= dataend)//Should it be datalimit? @@ -931,9 +931,9 @@ Mat Mat::diag(const Mat& d) return m; } -int Mat::checkVector(int _elemChannels, int _depth, bool _requireContinuous) const +int Mat::checkVector(int _elemChannels, ElemType _depth, bool _requireContinuous) const { - return data && (depth() == _depth || _depth <= 0) && + return data && (depth() == _depth || _depth <= CV_8U) && (isContinuous() || !_requireContinuous) && ((dims == 2 && (((rows == 1 || cols == 1) && channels() == _elemChannels) || (cols == _elemChannels && channels() == 1))) || diff --git a/modules/core/src/matrix_c.cpp b/modules/core/src/matrix_c.cpp index 1c3e58857cb4..7fc00e499ec0 100644 --- a/modules/core/src/matrix_c.cpp +++ b/modules/core/src/matrix_c.cpp @@ -11,7 +11,7 @@ CvMatND cvMatND(const cv::Mat& m) int i, d = m.dims; for( i = 0; i < d; i++ ) self.dim[i].step = (int)m.step[i]; - self.type |= m.flags & cv::Mat::CONTINUOUS_FLAG; + self.type |= m.flags & static_cast(cv::Mat::CONTINUOUS_FLAG); return self; } @@ -35,7 +35,7 @@ static Mat cvMatToMat(const CvMat* m, bool copyData) if( !copyData ) { - thiz.flags = Mat::MAGIC_VAL + (m->type & (CV_MAT_TYPE_MASK|CV_MAT_CONT_FLAG)); + thiz.flags = static_cast(Mat::MAGIC_VAL | (m->type & (CV_MAT_TYPE_MASK|CV_MAT_CONT_FLAG))); thiz.dims = 2; thiz.rows = m->rows; thiz.cols = m->cols; @@ -50,7 +50,7 @@ static Mat cvMatToMat(const CvMat* m, bool copyData) else { thiz.datastart = thiz.dataend = thiz.data = 0; - Mat(m->rows, m->cols, m->type, m->data.ptr, m->step).copyTo(thiz); + Mat(m->rows, m->cols, static_cast(m->type), m->data.ptr, m->step).copyTo(thiz); } return thiz; @@ -97,14 +97,14 @@ static Mat iplImageToMat(const IplImage* img, bool copyData) m.dims = 2; CV_DbgAssert(CV_IS_IMAGE(img) && img->imageData != 0); - int imgdepth = IPL2CV_DEPTH(img->depth); + ElemType imgdepth = static_cast(IPL2CV_DEPTH(img->depth)); size_t esz; m.step[0] = img->widthStep; if(!img->roi) { CV_Assert(img->dataOrder == IPL_DATA_ORDER_PIXEL); - m.flags = Mat::MAGIC_VAL + CV_MAKETYPE(imgdepth, img->nChannels); + m.flags = static_cast(Mat::MAGIC_VAL) | CV_MAKETYPE(imgdepth, img->nChannels); m.rows = img->height; m.cols = img->width; m.datastart = m.data = (uchar*)img->imageData; @@ -114,7 +114,7 @@ static Mat iplImageToMat(const IplImage* img, bool copyData) { CV_Assert(img->dataOrder == IPL_DATA_ORDER_PIXEL || img->roi->coi != 0); bool selectedPlane = img->roi->coi && img->dataOrder == IPL_DATA_ORDER_PLANE; - m.flags = Mat::MAGIC_VAL + CV_MAKETYPE(imgdepth, selectedPlane ? 1 : img->nChannels); + m.flags = static_cast(Mat::MAGIC_VAL) | CV_MAKETYPE(imgdepth, selectedPlane ? 1 : img->nChannels); m.rows = img->roi->height; m.cols = img->roi->width; esz = CV_ELEM_SIZE(m.flags); @@ -169,16 +169,16 @@ Mat cvarrToMat(const CvArr* arr, bool copyData, return Mat(); CV_Assert(total > 0 && CV_ELEM_SIZE(seq->flags) == esz); if(!copyData && seq->first->next == seq->first) - return Mat(total, 1, type, seq->first->data); + return Mat(total, 1, static_cast(type), seq->first->data); if( abuf ) { abuf->allocate(((size_t)total*esz + sizeof(double)-1)/sizeof(double)); double* bufdata = abuf->data(); cvCvtSeqToArray(seq, bufdata, CV_WHOLE_SEQ); - return Mat(total, 1, type, bufdata); + return Mat(total, 1, static_cast(type), bufdata); } - Mat buf(total, 1, type); + Mat buf(total, 1, static_cast(type)); cvCvtSeqToArray(seq, buf.ptr(), CV_WHOLE_SEQ); return buf; } @@ -188,7 +188,7 @@ Mat cvarrToMat(const CvArr* arr, bool copyData, void extractImageCOI(const CvArr* arr, OutputArray _ch, int coi) { Mat mat = cvarrToMat(arr, false, true, 1); - _ch.create(mat.dims, mat.size, mat.depth()); + _ch.create(mat.dims, mat.size, CV_MAKETYPE(mat.depth(), 1)); Mat ch = _ch.getMat(); if(coi < 0) { @@ -273,7 +273,7 @@ cvReduce( const CvArr* srcarr, CvArr* dstarr, int dim, int op ) if( src.channels() != dst.channels() ) CV_Error( CV_StsUnmatchedFormats, "Input and output arrays must have the same number of channels" ); - cv::reduce(src, dst, dim, op, dst.type()); + cv::reduce(src, dst, dim, op, dst.depth()); } diff --git a/modules/core/src/matrix_expressions.cpp b/modules/core/src/matrix_expressions.cpp index 243d6b039725..7181abfd9891 100644 --- a/modules/core/src/matrix_expressions.cpp +++ b/modules/core/src/matrix_expressions.cpp @@ -21,7 +21,7 @@ class MatOp_Identity CV_FINAL : public MatOp virtual ~MatOp_Identity() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return true; } - void assign(const MatExpr& expr, Mat& m, int type=-1) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemType depth = CV_TYPE_AUTO) const CV_OVERRIDE; static void makeExpr(MatExpr& res, const Mat& m); }; @@ -35,7 +35,7 @@ class MatOp_AddEx CV_FINAL : public MatOp virtual ~MatOp_AddEx() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return true; } - void assign(const MatExpr& expr, Mat& m, int type=-1) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemType depth = CV_TYPE_AUTO) const CV_OVERRIDE; void add(const MatExpr& e1, const Scalar& s, MatExpr& res) const CV_OVERRIDE; void subtract(const Scalar& s, const MatExpr& expr, MatExpr& res) const CV_OVERRIDE; @@ -57,7 +57,7 @@ class MatOp_Bin CV_FINAL : public MatOp virtual ~MatOp_Bin() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return true; } - void assign(const MatExpr& expr, Mat& m, int type=-1) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemType depth = CV_TYPE_AUTO) const CV_OVERRIDE; void multiply(const MatExpr& e1, double s, MatExpr& res) const CV_OVERRIDE; void divide(double s, const MatExpr& e, MatExpr& res) const CV_OVERRIDE; @@ -75,7 +75,7 @@ class MatOp_Cmp CV_FINAL : public MatOp virtual ~MatOp_Cmp() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return true; } - void assign(const MatExpr& expr, Mat& m, int type=-1) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemType depth = CV_TYPE_AUTO) const CV_OVERRIDE; static void makeExpr(MatExpr& res, int cmpop, const Mat& a, const Mat& b); static void makeExpr(MatExpr& res, int cmpop, const Mat& a, double alpha); @@ -90,7 +90,7 @@ class MatOp_GEMM CV_FINAL : public MatOp virtual ~MatOp_GEMM() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return false; } - void assign(const MatExpr& expr, Mat& m, int type=-1) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemType depth = CV_TYPE_AUTO) const CV_OVERRIDE; void add(const MatExpr& e1, const MatExpr& e2, MatExpr& res) const CV_OVERRIDE; void subtract(const MatExpr& e1, const MatExpr& e2, MatExpr& res) const CV_OVERRIDE; @@ -111,7 +111,7 @@ class MatOp_Invert CV_FINAL : public MatOp virtual ~MatOp_Invert() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return false; } - void assign(const MatExpr& expr, Mat& m, int type=-1) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemType depth = CV_TYPE_AUTO) const CV_OVERRIDE; void matmul(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res) const CV_OVERRIDE; @@ -127,7 +127,7 @@ class MatOp_T CV_FINAL : public MatOp virtual ~MatOp_T() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return false; } - void assign(const MatExpr& expr, Mat& m, int type=-1) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemType depth = CV_TYPE_AUTO) const CV_OVERRIDE; void multiply(const MatExpr& e1, double s, MatExpr& res) const CV_OVERRIDE; void transpose(const MatExpr& expr, MatExpr& res) const CV_OVERRIDE; @@ -144,7 +144,7 @@ class MatOp_Solve CV_FINAL : public MatOp virtual ~MatOp_Solve() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return false; } - void assign(const MatExpr& expr, Mat& m, int type=-1) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemType depth = CV_TYPE_AUTO) const CV_OVERRIDE; static void makeExpr(MatExpr& res, int method, const Mat& a, const Mat& b); }; @@ -158,12 +158,12 @@ class MatOp_Initializer CV_FINAL : public MatOp virtual ~MatOp_Initializer() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return false; } - void assign(const MatExpr& expr, Mat& m, int type=-1) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemType depth = CV_TYPE_AUTO) const CV_OVERRIDE; void multiply(const MatExpr& e, double s, MatExpr& res) const CV_OVERRIDE; - static void makeExpr(MatExpr& res, int method, Size sz, int type, double alpha=1); - static void makeExpr(MatExpr& res, int method, int ndims, const int* sizes, int type, double alpha=1); + static void makeExpr(MatExpr& res, int method, Size sz, ElemType type, double alpha = 1); + static void makeExpr(MatExpr& res, int method, int ndims, const int* sizes, ElemType type, double alpha = 1); }; static MatOp_Initializer* getGlobalMatOpInitializer() @@ -571,7 +571,7 @@ Size MatOp::size(const MatExpr& expr) const return !expr.a.empty() ? expr.a.size() : expr.b.empty() ? expr.b.size() : expr.c.size(); } -int MatOp::type(const MatExpr& expr) const +ElemType MatOp::type(const MatExpr& expr) const { CV_INSTRUMENT_REGION(); @@ -1178,7 +1178,7 @@ Size MatExpr::size() const } -int MatExpr::type() const +ElemType MatExpr::type() const { CV_INSTRUMENT_REGION(); @@ -1186,20 +1186,23 @@ int MatExpr::type() const return a.type(); if( isCmp(*this) ) return CV_8U; - return op ? op->type(*this) : -1; + return op ? op->type(*this) : CV_TYPE_AUTO; } ///////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_Identity::assign(const MatExpr& e, Mat& m, int _type) const +void MatOp_Identity::assign(const MatExpr& e, Mat& m, ElemType _depth) const { - if( _type == -1 || _type == e.a.type() ) + if (_depth == CV_TYPE_AUTO) + _depth = e.a.depth(); + + if (_depth == e.a.depth()) m = e.a; else { - CV_Assert( CV_MAT_CN(_type) == e.a.channels() ); - e.a.convertTo(m, _type); + CV_Assert( CV_MAT_CN(_depth) == e.a.channels() ); + e.a.convertTo(m, _depth); } } @@ -1210,9 +1213,12 @@ inline void MatOp_Identity::makeExpr(MatExpr& res, const Mat& m) ///////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_AddEx::assign(const MatExpr& e, Mat& m, int _type) const +void MatOp_AddEx::assign(const MatExpr& e, Mat& m, ElemType _depth) const { - Mat temp, &dst = _type == -1 || e.a.type() == _type ? m : temp; + if (_depth == CV_TYPE_AUTO) + _depth = e.a.depth(); + + Mat temp, &dst = e.a.depth() == _depth ? m : temp; if( e.b.data ) { if( e.s == Scalar() || !e.s.isReal() ) @@ -1244,7 +1250,7 @@ void MatOp_AddEx::assign(const MatExpr& e, Mat& m, int _type) const } else if( e.s.isReal() && (dst.data != m.data || fabs(e.alpha) != 1)) { - e.a.convertTo(m, _type, e.alpha, e.s[0]); + e.a.convertTo(m, _depth, e.alpha, e.s[0]); return; } else if( e.alpha == 1 ) @@ -1331,9 +1337,12 @@ inline void MatOp_AddEx::makeExpr(MatExpr& res, const Mat& a, const Mat& b, doub ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_Bin::assign(const MatExpr& e, Mat& m, int _type) const +void MatOp_Bin::assign(const MatExpr& e, Mat& m, ElemType _depth) const { - Mat temp, &dst = _type == -1 || e.a.type() == _type ? m : temp; + if (_depth == CV_TYPE_AUTO) + _depth = e.a.depth(); + + Mat temp, &dst = e.a.depth() == _depth ? m : temp; if( e.flags == '*' ) cv::multiply(e.a, e.b, dst, e.alpha); @@ -1371,7 +1380,7 @@ void MatOp_Bin::assign(const MatExpr& e, Mat& m, int _type) const CV_Error(CV_StsError, "Unknown operation"); if( dst.data != m.data ) - dst.convertTo(m, _type); + dst.convertTo(m, _depth); } void MatOp_Bin::multiply(const MatExpr& e, double s, MatExpr& res) const @@ -1409,9 +1418,13 @@ inline void MatOp_Bin::makeExpr(MatExpr& res, char op, const Mat& a, const Scala /////////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_Cmp::assign(const MatExpr& e, Mat& m, int _type) const +void MatOp_Cmp::assign(const MatExpr& e, Mat& m, ElemType _depth) const { - Mat temp, &dst = _type == -1 || _type == CV_8U ? m : temp; + if (_depth == CV_TYPE_AUTO) + _depth = e.a.depth(); + + //TODO: Investigate why CV_8U is coded here + Mat temp, &dst = _depth == e.a.depth() || _depth == CV_8U ? m : temp; if( e.b.data ) cv::compare(e.a, e.b, dst, e.flags); @@ -1419,7 +1432,7 @@ void MatOp_Cmp::assign(const MatExpr& e, Mat& m, int _type) const cv::compare(e.a, e.alpha, dst, e.flags); if( dst.data != m.data ) - dst.convertTo(m, _type); + dst.convertTo(m, _depth); } inline void MatOp_Cmp::makeExpr(MatExpr& res, int cmpop, const Mat& a, const Mat& b) @@ -1434,14 +1447,17 @@ inline void MatOp_Cmp::makeExpr(MatExpr& res, int cmpop, const Mat& a, double al ///////////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_T::assign(const MatExpr& e, Mat& m, int _type) const +void MatOp_T::assign(const MatExpr& e, Mat& m, ElemType _depth) const { - Mat temp, &dst = _type == -1 || _type == e.a.type() ? m : temp; + if (_depth == CV_TYPE_AUTO) + _depth = e.a.depth(); + + Mat temp, &dst = _depth == e.a.depth() ? m : temp; cv::transpose(e.a, dst); if( dst.data != m.data || e.alpha != 1 ) - dst.convertTo(m, _type, e.alpha); + dst.convertTo(m, _depth, e.alpha); } void MatOp_T::multiply(const MatExpr& e, double s, MatExpr& res) const @@ -1469,13 +1485,16 @@ inline void MatOp_T::makeExpr(MatExpr& res, const Mat& a, double alpha) ///////////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_GEMM::assign(const MatExpr& e, Mat& m, int _type) const +void MatOp_GEMM::assign(const MatExpr& e, Mat& m, ElemType _depth) const { - Mat temp, &dst = _type == -1 || _type == e.a.type() ? m : temp; + if (_depth == CV_TYPE_AUTO) + _depth = e.a.depth(); + + Mat temp, &dst = _depth == e.a.depth() ? m : temp; cv::gemm(e.a, e.b, e.alpha, e.c, e.beta, dst, e.flags); if( dst.data != m.data ) - dst.convertTo(m, _type); + dst.convertTo(m, _depth); } void MatOp_GEMM::add(const MatExpr& e1, const MatExpr& e2, MatExpr& res) const @@ -1544,13 +1563,16 @@ inline void MatOp_GEMM::makeExpr(MatExpr& res, int flags, const Mat& a, const Ma /////////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_Invert::assign(const MatExpr& e, Mat& m, int _type) const +void MatOp_Invert::assign(const MatExpr& e, Mat& m, ElemType _depth) const { - Mat temp, &dst = _type == -1 || _type == e.a.type() ? m : temp; + if (_depth == CV_TYPE_AUTO) + _depth = e.a.depth(); + + Mat temp, &dst = _depth == e.a.depth() ? m : temp; cv::invert(e.a, dst, e.flags); if( dst.data != m.data ) - dst.convertTo(m, _type); + dst.convertTo(m, _depth); } void MatOp_Invert::matmul(const MatExpr& e1, const MatExpr& e2, MatExpr& res) const @@ -1570,13 +1592,16 @@ inline void MatOp_Invert::makeExpr(MatExpr& res, int method, const Mat& m) ///////////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_Solve::assign(const MatExpr& e, Mat& m, int _type) const +void MatOp_Solve::assign(const MatExpr& e, Mat& m, ElemType _depth) const { - Mat temp, &dst = _type == -1 || _type == e.a.type() ? m : temp; + if (_depth == CV_TYPE_AUTO) + _depth = e.a.depth(); + + Mat temp, &dst = _depth == e.a.depth() ? m : temp; cv::solve(e.a, e.b, dst, e.flags); if( dst.data != m.data ) - dst.convertTo(m, _type); + dst.convertTo(m, _depth); } inline void MatOp_Solve::makeExpr(MatExpr& res, int method, const Mat& a, const Mat& b) @@ -1586,15 +1611,15 @@ inline void MatOp_Solve::makeExpr(MatExpr& res, int method, const Mat& a, const ////////////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_Initializer::assign(const MatExpr& e, Mat& m, int _type) const +void MatOp_Initializer::assign(const MatExpr& e, Mat& m, ElemType _depth) const { - if( _type == -1 ) - _type = e.a.type(); + if (_depth == CV_TYPE_AUTO) + _depth = e.a.depth(); if( e.a.dims <= 2 ) - m.create(e.a.size(), _type); + m.create(e.a.size(), CV_MAKETYPE(_depth, e.a.channels())); else - m.create(e.a.dims, e.a.size, _type); + m.create(e.a.dims, e.a.size, CV_MAKETYPE(_depth, e.a.channels())); if( e.flags == 'I' && e.a.dims <= 2 ) setIdentity(m, Scalar(e.alpha)); @@ -1614,12 +1639,12 @@ void MatOp_Initializer::multiply(const MatExpr& e, double s, MatExpr& res) const res.alpha *= s; } -inline void MatOp_Initializer::makeExpr(MatExpr& res, int method, Size sz, int type, double alpha) +inline void MatOp_Initializer::makeExpr(MatExpr& res, int method, Size sz, ElemType type, double alpha) { res = MatExpr(getGlobalMatOpInitializer(), method, Mat(sz, type, (void*)(size_t)0xEEEEEEEE), Mat(), Mat(), alpha, 0); } -inline void MatOp_Initializer::makeExpr(MatExpr& res, int method, int ndims, const int* sizes, int type, double alpha) +inline void MatOp_Initializer::makeExpr(MatExpr& res, int method, int ndims, const int* sizes, ElemType type, double alpha) { res = MatExpr(getGlobalMatOpInitializer(), method, Mat(ndims, sizes, type, (void*)(size_t)0xEEEEEEEE), Mat(), Mat(), alpha, 0); } @@ -1660,7 +1685,7 @@ MatExpr Mat::mul(InputArray m, double scale) const return e; } -MatExpr Mat::zeros(int rows, int cols, int type) +MatExpr Mat::zeros(int rows, int cols, ElemType type) { CV_INSTRUMENT_REGION(); @@ -1669,7 +1694,7 @@ MatExpr Mat::zeros(int rows, int cols, int type) return e; } -MatExpr Mat::zeros(Size size, int type) +MatExpr Mat::zeros(Size size, ElemType type) { CV_INSTRUMENT_REGION(); @@ -1678,7 +1703,7 @@ MatExpr Mat::zeros(Size size, int type) return e; } -MatExpr Mat::zeros(int ndims, const int* sizes, int type) +MatExpr Mat::zeros(int ndims, const int* sizes, ElemType type) { CV_INSTRUMENT_REGION(); @@ -1687,7 +1712,7 @@ MatExpr Mat::zeros(int ndims, const int* sizes, int type) return e; } -MatExpr Mat::ones(int rows, int cols, int type) +MatExpr Mat::ones(int rows, int cols, ElemType type) { CV_INSTRUMENT_REGION(); @@ -1696,7 +1721,7 @@ MatExpr Mat::ones(int rows, int cols, int type) return e; } -MatExpr Mat::ones(Size size, int type) +MatExpr Mat::ones(Size size, ElemType type) { CV_INSTRUMENT_REGION(); @@ -1705,7 +1730,7 @@ MatExpr Mat::ones(Size size, int type) return e; } -MatExpr Mat::ones(int ndims, const int* sizes, int type) +MatExpr Mat::ones(int ndims, const int* sizes, ElemType type) { CV_INSTRUMENT_REGION(); @@ -1714,7 +1739,7 @@ MatExpr Mat::ones(int ndims, const int* sizes, int type) return e; } -MatExpr Mat::eye(int rows, int cols, int type) +MatExpr Mat::eye(int rows, int cols, ElemType type) { CV_INSTRUMENT_REGION(); @@ -1723,7 +1748,7 @@ MatExpr Mat::eye(int rows, int cols, int type) return e; } -MatExpr Mat::eye(Size size, int type) +MatExpr Mat::eye(Size size, ElemType type) { CV_INSTRUMENT_REGION(); diff --git a/modules/core/src/matrix_operations.cpp b/modules/core/src/matrix_operations.cpp index 6d865a51a91e..977dae731b8f 100644 --- a/modules/core/src/matrix_operations.cpp +++ b/modules/core/src/matrix_operations.cpp @@ -143,8 +143,10 @@ namespace cv { static bool ocl_setIdentity( InputOutputArray _m, const Scalar& s ) { - int type = _m.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), kercn = cn, rowsPerWI = 1; - int sctype = CV_MAKE_TYPE(depth, cn == 3 ? 4 : cn); + ElemType type = _m.type(); + ElemType depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), kercn = cn, rowsPerWI = 1; + ElemType sctype = CV_MAKE_TYPE(depth, cn == 3 ? 4 : cn); if (ocl::Device::getDefault().isIntel()) { rowsPerWI = 4; @@ -230,7 +232,7 @@ cv::Scalar cv::trace( InputArray _m ) Mat m = _m.getMat(); CV_Assert( m.dims <= 2 ); - int type = m.type(); + ElemType type = m.type(); int nm = std::min(m.rows, m.cols); if( type == CV_32FC1 ) @@ -370,8 +372,10 @@ static bool ocl_transpose( InputArray _src, OutputArray _dst ) { const ocl::Device & dev = ocl::Device::getDefault(); const int TILE_DIM = 32, BLOCK_ROWS = 8; - int type = _src.type(), cn = CV_MAT_CN(type), depth = CV_MAT_DEPTH(type), - rowsPerWI = dev.isIntel() ? 4 : 1; + ElemType type = _src.type(); + int cn = CV_MAT_CN(type); + ElemType depth = CV_MAT_DEPTH(type); + int rowsPerWI = dev.isIntel() ? 4 : 1; UMat src = _src.getUMat(); _dst.create(src.cols, src.rows, type); @@ -425,7 +429,7 @@ static bool ipp_transpose( Mat &src, Mat &dst ) { CV_INSTRUMENT_REGION_IPP(); - int type = src.type(); + ElemType type = src.type(); typedef IppStatus (CV_STDCALL * IppiTranspose)(const void * pSrc, int srcStep, void * pDst, int dstStep, IppiSize roiSize); typedef IppStatus (CV_STDCALL * IppiTransposeI)(const void * pSrcDst, int srcDstStep, IppiSize roiSize); IppiTranspose ippiTranspose = 0; @@ -494,7 +498,8 @@ void cv::transpose( InputArray _src, OutputArray _dst ) { CV_INSTRUMENT_REGION(); - int type = _src.type(), esz = CV_ELEM_SIZE(type); + ElemType type = _src.type(); + int esz = CV_ELEM_SIZE(type); CV_Assert( _src.dims() <= 2 && esz <= 32 ); CV_OCL_RUN(_dst.isUMat(), @@ -562,7 +567,8 @@ void cv::completeSymm( InputOutputArray _m, bool LtoR ) cv::Mat cv::Mat::cross(InputArray _m) const { Mat m = _m.getMat(); - int tp = type(), d = CV_MAT_DEPTH(tp); + ElemType tp = type(); + ElemType d = CV_MAT_DEPTH(tp); CV_Assert( dims <= 2 && m.dims <= 2 && size() == m.size() && tp == m.type() && ((rows == 3 && cols == 1) || (cols*channels() == 3 && rows == 1))); Mat result(rows, cols, tp); @@ -713,8 +719,8 @@ typedef void (*ReduceFunc)( const Mat& src, Mat& dst ); #ifdef HAVE_IPP static inline bool ipp_reduceSumC_8u16u16s32f_64f(const cv::Mat& srcmat, cv::Mat& dstmat) { - int sstep = (int)srcmat.step, stype = srcmat.type(), - ddepth = dstmat.depth(); + int sstep = (int)srcmat.step, stype = srcmat.type(); + ElemType ddepth = dstmat.depth(); IppiSize roisize = { srcmat.size().width, 1 }; @@ -771,7 +777,7 @@ static inline void reduceSumC_8u16u16s32f_64f(const cv::Mat& srcmat, cv::Mat& ds if(dstmat.depth() == CV_64F) { - int sdepth = CV_MAT_DEPTH(srcmat.type()); + ElemType sdepth = CV_MAT_DEPTH(srcmat.type()); func = sdepth == CV_8U ? (cv::ReduceFunc)cv::reduceC_ > : sdepth == CV_16U ? (cv::ReduceFunc)cv::reduceC_ > : @@ -860,11 +866,12 @@ REDUCE_OP(32f, Min, float, float) namespace cv { static bool ocl_reduce(InputArray _src, OutputArray _dst, - int dim, int op, int op0, int stype, int dtype) + int dim, int op, int op0, ElemType stype, ElemType dtype) { const int min_opt_cols = 128, buf_cols = 32; - int sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype), - ddepth = CV_MAT_DEPTH(dtype), ddepth0 = ddepth; + ElemType sdepth = CV_MAT_DEPTH(stype); + int cn = CV_MAT_CN(stype); + ElemType ddepth = CV_MAT_DEPTH(dtype), ddepth0 = ddepth; const ocl::Device &defDev = ocl::Device::getDefault(); bool doubleSupport = defDev.doubleFPConfig() > 0; @@ -882,7 +889,7 @@ static bool ocl_reduce(InputArray _src, OutputArray _dst, const char * const ops[4] = { "OCL_CV_REDUCE_SUM", "OCL_CV_REDUCE_AVG", "OCL_CV_REDUCE_MAX", "OCL_CV_REDUCE_MIN" }; - int wdepth = std::max(ddepth, CV_32F); + ElemType wdepth = CV_MAX_DEPTH(ddepth, CV_32F); if (useOptimized) { size_t tileHeight = (size_t)(wgs / buf_cols); @@ -962,17 +969,19 @@ static bool ocl_reduce(InputArray _src, OutputArray _dst, #endif -void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype) +void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, ElemType ddepth) { CV_INSTRUMENT_REGION(); CV_Assert( _src.dims() <= 2 ); int op0 = op; - int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype); - if( dtype < 0 ) - dtype = _dst.fixedType() ? _dst.type() : stype; - dtype = CV_MAKETYPE(dtype >= 0 ? dtype : stype, cn); - int ddepth = CV_MAT_DEPTH(dtype); + ElemType stype = _src.type(); + ElemType sdepth = _src.depth(); + int cn = CV_MAT_CN(stype); + if (ddepth == CV_TYPE_AUTO) + ddepth = _dst.fixedType() ? _dst.depth() : sdepth; + ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ + ElemType dtype = CV_MAKETYPE(ddepth, cn); CV_Assert( cn == CV_MAT_CN(dtype) ); CV_Assert( op == CV_REDUCE_SUM || op == CV_REDUCE_MAX || @@ -1174,7 +1183,7 @@ template static void sort_( const Mat& src, Mat& dst, int flags ) #ifdef HAVE_IPP typedef IppStatus (CV_STDCALL *IppSortFunc)(void *pSrcDst, int len, Ipp8u *pBuffer); -static IppSortFunc getSortFunc(int depth, bool sortDescending) +static IppSortFunc getSortFunc(ElemType depth, bool sortDescending) { if (!sortDescending) return depth == CV_8U ? (IppSortFunc)ippsSortRadixAscend_8u_I : @@ -1201,7 +1210,7 @@ static bool ipp_sort(const Mat& src, Mat& dst, int flags) bool sortRows = (flags & 1) == CV_SORT_EVERY_ROW; bool sortDescending = (flags & CV_SORT_DESCENDING) != 0; bool inplace = (src.data == dst.data); - int depth = src.depth(); + ElemType depth = src.depth(); IppDataType type = ippiGetDataType(depth); IppSortFunc ippsSortRadix_I = getSortFunc(depth, sortDescending); @@ -1322,7 +1331,7 @@ template static void sortIdx_( const Mat& src, Mat& dst, int flags ) #ifdef HAVE_IPP typedef IppStatus (CV_STDCALL *IppSortIndexFunc)(const void* pSrc, Ipp32s srcStrideBytes, Ipp32s *pDstIndx, int len, Ipp8u *pBuffer); -static IppSortIndexFunc getSortIndexFunc(int depth, bool sortDescending) +static IppSortIndexFunc getSortIndexFunc(ElemType depth, bool sortDescending) { if (!sortDescending) return depth == CV_8U ? (IppSortIndexFunc)ippsSortRadixIndexAscend_8u : @@ -1346,7 +1355,7 @@ static bool ipp_sortIdx( const Mat& src, Mat& dst, int flags ) bool sortRows = (flags & 1) == SORT_EVERY_ROW; bool sortDescending = (flags & SORT_DESCENDING) != 0; - int depth = src.depth(); + ElemType depth = src.depth(); IppDataType type = ippiGetDataType(depth); IppSortIndexFunc ippsSortRadixIndex = getSortIndexFunc(depth, sortDescending); diff --git a/modules/core/src/matrix_sparse.cpp b/modules/core/src/matrix_sparse.cpp index 61e7e90a5659..ab5c7e0bb0d6 100644 --- a/modules/core/src/matrix_sparse.cpp +++ b/modules/core/src/matrix_sparse.cpp @@ -149,7 +149,7 @@ static inline bool isZeroElem(const uchar* data, size_t elemSize) return true; } -SparseMat::Hdr::Hdr( int _dims, const int* _sizes, int _type ) +SparseMat::Hdr::Hdr(int _dims, const int* _sizes, ElemType _type) { refcount = 1; @@ -178,7 +178,7 @@ void SparseMat::Hdr::clear() SparseMat::SparseMat(const Mat& m) -: flags(MAGIC_VAL), hdr(0) +: flags(static_cast(MAGIC_VAL)), hdr(0) { create( m.dims, m.size, m.type() ); @@ -209,7 +209,7 @@ SparseMat::SparseMat(const Mat& m) } } -void SparseMat::create(int d, const int* _sizes, int _type) +void SparseMat::create(int d, const int* _sizes, ElemType _type) { CV_Assert( _sizes && 0 < d && d <= CV_MAX_DIM ); for( int i = 0; i < d; i++ ) @@ -235,7 +235,7 @@ void SparseMat::create(int d, const int* _sizes, int _type) _sizes = _sizes_backup; } release(); - flags = MAGIC_VAL | _type; + flags = static_cast(MAGIC_VAL) | _type; hdr = new Hdr(d, _sizes, _type); } @@ -278,30 +278,32 @@ void SparseMat::copyTo( Mat& m ) const } -void SparseMat::convertTo( SparseMat& m, int rtype, double alpha ) const +void SparseMat::convertTo(SparseMat& m, ElemType ddepth, double alpha) const { int cn = channels(); - if( rtype < 0 ) - rtype = type(); - rtype = CV_MAKETYPE(rtype, cn); - if( hdr == m.hdr && rtype != type() ) + if (ddepth == CV_TYPE_AUTO) + ddepth = depth(); + ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ + ElemType dtype = CV_MAKETYPE(ddepth, cn); + + if (hdr == m.hdr && dtype != type()) { SparseMat temp; - convertTo(temp, rtype, alpha); + convertTo(temp, CV_MAT_DEPTH(dtype), alpha); m = temp; return; } CV_Assert(hdr != 0); if( hdr != m.hdr ) - m.create( hdr->dims, hdr->size, rtype ); + m.create(hdr->dims, hdr->size, dtype); SparseMatConstIterator from = begin(); size_t N = nzcount(); if( alpha == 1 ) { - ConvertData cvtfunc = getConvertElem(type(), rtype); + ConvertData cvtfunc = getConvertElem(type(), dtype); for( size_t i = 0; i < N; i++, ++from ) { const Node* n = from.node(); @@ -311,7 +313,7 @@ void SparseMat::convertTo( SparseMat& m, int rtype, double alpha ) const } else { - ConvertScaleData cvtfunc = getConvertScaleElem(type(), rtype); + ConvertScaleData cvtfunc = getConvertScaleElem(type(), dtype); for( size_t i = 0; i < N; i++, ++from ) { const Node* n = from.node(); @@ -321,16 +323,16 @@ void SparseMat::convertTo( SparseMat& m, int rtype, double alpha ) const } } - -void SparseMat::convertTo( Mat& m, int rtype, double alpha, double beta ) const +void SparseMat::convertTo(Mat& m, ElemType ddepth, double alpha, double beta) const { int cn = channels(); - if( rtype < 0 ) - rtype = type(); - rtype = CV_MAKETYPE(rtype, cn); + if (ddepth == CV_TYPE_AUTO) + ddepth = depth(); + ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ + ElemType dtype = CV_MAKETYPE(ddepth, cn); CV_Assert( hdr ); - m.create( dims(), hdr->size, rtype ); + m.create(dims(), hdr->size, dtype); m = Scalar(beta); SparseMatConstIterator from = begin(); @@ -338,7 +340,7 @@ void SparseMat::convertTo( Mat& m, int rtype, double alpha, double beta ) const if( alpha == 1 && beta == 0 ) { - ConvertData cvtfunc = getConvertElem(type(), rtype); + ConvertData cvtfunc = getConvertElem(type(), dtype); for( size_t i = 0; i < N; i++, ++from ) { const Node* n = from.node(); @@ -348,7 +350,7 @@ void SparseMat::convertTo( Mat& m, int rtype, double alpha, double beta ) const } else { - ConvertScaleData cvtfunc = getConvertScaleElem(type(), rtype); + ConvertScaleData cvtfunc = getConvertScaleElem(type(), dtype); for( size_t i = 0; i < N; i++, ++from ) { const Node* n = from.node(); @@ -621,7 +623,7 @@ double norm( const SparseMat& src, int normType ) size_t i, N = src.nzcount(); normType &= NORM_TYPE_MASK; - int type = src.type(); + ElemType type = src.type(); double result = 0; CV_Assert( normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 ); @@ -758,7 +760,7 @@ void normalize( const SparseMat& src, SparseMat& dst, double a, int norm_type ) else CV_Error( CV_StsBadArg, "Unknown/unsupported norm type" ); - src.convertTo( dst, -1, scale ); + src.convertTo(dst, CV_TYPE_AUTO, scale); } } // cv:: @@ -787,7 +789,7 @@ CvSparseMat* cvCreateSparseMat(const cv::SparseMat& sm) void CvSparseMat::copyToSparseMat(cv::SparseMat& m) const { - m.create( dims, &size[0], type ); + m.create(dims, &size[0], static_cast(type)); CvSparseMatIterator it; CvSparseNode* n = cvInitSparseMatIterator(this, &it); diff --git a/modules/core/src/matrix_wrap.cpp b/modules/core/src/matrix_wrap.cpp index 5ee7ab3696ef..45990f102ea4 100644 --- a/modules/core/src/matrix_wrap.cpp +++ b/modules/core/src/matrix_wrap.cpp @@ -42,13 +42,13 @@ Mat _InputArray::getMat_(int i) const if( k == MATX || k == STD_ARRAY ) { CV_Assert( i < 0 ); - return Mat(sz, flags, obj); + return Mat(sz, CV_MAT_TYPE(flags), obj); } if( k == STD_VECTOR ) { CV_Assert( i < 0 ); - int t = CV_MAT_TYPE(flags); + ElemType t = CV_MAT_TYPE(flags); const std::vector& v = *(const std::vector*)obj; return !v.empty() ? Mat(size(), t, (void*)&v[0]) : Mat(); @@ -74,7 +74,7 @@ Mat _InputArray::getMat_(int i) const if( k == STD_VECTOR_VECTOR ) { - int t = type(i); + ElemType t = type(i); const std::vector >& vv = *(const std::vector >*)obj; CV_Assert( 0 <= i && i < (int)vv.size() ); const std::vector& v = vv[i]; @@ -205,7 +205,8 @@ void _InputArray::getMatVector(std::vector& mv) const const std::vector& v = *(const std::vector*)obj; size_t n = size().width, esz = CV_ELEM_SIZE(flags); - int t = CV_MAT_DEPTH(flags), cn = CV_MAT_CN(flags); + ElemType t = CV_MAKETYPE(CV_MAT_DEPTH(flags), 1); + int cn = CV_MAT_CN(flags); mv.resize(n); for( size_t i = 0; i < n; i++ ) @@ -223,7 +224,7 @@ void _InputArray::getMatVector(std::vector& mv) const { const std::vector >& vv = *(const std::vector >*)obj; int n = (int)vv.size(); - int t = CV_MAT_TYPE(flags); + ElemType t = CV_MAT_TYPE(flags); mv.resize(n); for( int i = 0; i < n; i++ ) @@ -762,7 +763,7 @@ size_t _InputArray::total(int i) const return size(i).area(); } -int _InputArray::type(int i) const +ElemType _InputArray::type(int i) const { _InputArray::KindFlag k = kind(); @@ -779,7 +780,7 @@ int _InputArray::type(int i) const return CV_MAT_TYPE(flags); if( k == NONE ) - return -1; + return CV_TYPE_AUTO; if( k == STD_VECTOR_UMAT ) { @@ -841,7 +842,7 @@ int _InputArray::type(int i) const CV_Error(Error::StsNotImplemented, "Unknown/unsupported array type"); } -int _InputArray::depth(int i) const +ElemType _InputArray::depth(int i) const { return CV_MAT_DEPTH(type(i)); } @@ -1186,7 +1187,7 @@ bool _OutputArray::fixedType() const return (flags & FIXED_TYPE) == FIXED_TYPE; } -void _OutputArray::create(Size _sz, int mtype, int i, bool allowTransposed, _OutputArray::DepthMask fixedDepthMask) const +void _OutputArray::create(Size _sz, ElemType mtype, int i, bool allowTransposed, _OutputArray::DepthMask fixedDepthMask) const { _InputArray::KindFlag k = kind(); if( k == MAT && i < 0 && !allowTransposed && fixedDepthMask == 0 ) @@ -1228,7 +1229,7 @@ void _OutputArray::create(Size _sz, int mtype, int i, bool allowTransposed, _Out create(2, sizes, mtype, i, allowTransposed, fixedDepthMask); } -void _OutputArray::create(int _rows, int _cols, int mtype, int i, bool allowTransposed, _OutputArray::DepthMask fixedDepthMask) const +void _OutputArray::create(int _rows, int _cols, ElemType mtype, int i, bool allowTransposed, _OutputArray::DepthMask fixedDepthMask) const { _InputArray::KindFlag k = kind(); if( k == MAT && i < 0 && !allowTransposed && fixedDepthMask == 0 ) @@ -1270,7 +1271,7 @@ void _OutputArray::create(int _rows, int _cols, int mtype, int i, bool allowTran create(2, sizes, mtype, i, allowTransposed, fixedDepthMask); } -void _OutputArray::create(int d, const int* sizes, int mtype, int i, +void _OutputArray::create(int d, const int* sizes, ElemType mtype, int i, bool allowTransposed, _OutputArray::DepthMask fixedDepthMask) const { int sizebuf[2]; @@ -1355,7 +1356,7 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i, if( k == MATX ) { CV_Assert( i < 0 ); - int type0 = CV_MAT_TYPE(flags); + ElemType type0 = CV_MAT_TYPE(flags); CV_Assert( mtype == type0 || (CV_MAT_CN(mtype) == 1 && ((1 << type0) & fixedDepthMask) != 0) ); CV_Assert( d == 2 && ((sizes[0] == sz.height && sizes[1] == sz.width) || (allowTransposed && sizes[0] == sz.width && sizes[1] == sz.height))); @@ -1364,7 +1365,7 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i, if( k == STD_ARRAY ) { - int type0 = CV_MAT_TYPE(flags); + ElemType type0 = CV_MAT_TYPE(flags); CV_Assert( mtype == type0 || (CV_MAT_CN(mtype) == 1 && ((1 << type0) & fixedDepthMask) != 0) ); CV_Assert( d == 2 && sz.area() == sizes[0]*sizes[1]); return; @@ -1391,7 +1392,7 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i, else CV_Assert( i < 0 ); - int type0 = CV_MAT_TYPE(flags); + ElemType type0 = CV_MAT_TYPE(flags); CV_Assert( mtype == type0 || (CV_MAT_CN(mtype) == CV_MAT_CN(type0) && ((1 << type0) & fixedDepthMask) != 0) ); int esz = CV_ELEM_SIZE(type0); @@ -1491,13 +1492,13 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i, v.resize(len); if( fixedType() ) { - int _type = CV_MAT_TYPE(flags); + ElemType _type = CV_MAT_TYPE(flags); for( size_t j = len0; j < len; j++ ) { if( v[j].type() == _type ) continue; CV_Assert( v[j].empty() ); - v[j].flags = (v[j].flags & ~CV_MAT_TYPE_MASK) | _type; + v[j].flags = static_cast((v[j].flags & ~CV_MAT_TYPE_MASK) | _type); } } return; @@ -1549,13 +1550,13 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i, CV_Assert(len == len0); if( fixedType() ) { - int _type = CV_MAT_TYPE(flags); + ElemType _type = CV_MAT_TYPE(flags); for( size_t j = len0; j < len; j++ ) { if( v[j].type() == _type ) continue; CV_Assert( v[j].empty() ); - v[j].flags = (v[j].flags & ~CV_MAT_TYPE_MASK) | _type; + v[j].flags = static_cast((v[j].flags & ~CV_MAT_TYPE_MASK) | _type); } } return; @@ -1609,13 +1610,13 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i, v.resize(len); if( fixedType() ) { - int _type = CV_MAT_TYPE(flags); + ElemType _type = CV_MAT_TYPE(flags); for( size_t j = len0; j < len; j++ ) { if( v[j].type() == _type ) continue; CV_Assert( v[j].empty() ); - v[j].flags = (v[j].flags & ~CV_MAT_TYPE_MASK) | _type; + v[j].flags = static_cast((v[j].flags & ~CV_MAT_TYPE_MASK) | _type); } } return; @@ -1658,7 +1659,7 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i, CV_Error(Error::StsNotImplemented, "Unknown/unsupported array type"); } -void _OutputArray::createSameSize(const _InputArray& arr, int mtype) const +void _OutputArray::createSameSize(const _InputArray& arr, ElemType mtype) const { int arrsz[CV_MAX_DIM], d = arr.sizend(arrsz); create(d, arrsz, mtype); diff --git a/modules/core/src/mean.cpp b/modules/core/src/mean.cpp index 8542381d4994..a364745a29ab 100644 --- a/modules/core/src/mean.cpp +++ b/modules/core/src/mean.cpp @@ -24,7 +24,7 @@ static bool ipp_mean( Mat &src, Mat &mask, Scalar &ret ) if( src.dims == 2 || (src.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) ) { IppiSize sz = { cols, rows }; - int type = src.type(); + ElemType type = src.type(); if( !mask.empty() ) { typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC1)(const void *, int, const void *, int, IppiSize, Ipp64f *); @@ -111,7 +111,8 @@ cv::Scalar cv::mean( InputArray _src, InputArray _mask ) Mat src = _src.getMat(), mask = _mask.getMat(); CV_Assert( mask.empty() || mask.type() == CV_8U ); - int k, cn = src.channels(), depth = src.depth(); + int k, cn = src.channels(); + ElemType depth = src.depth(); Scalar s; CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_mean(src, mask, s), s) @@ -466,7 +467,7 @@ static int sqsum64f( const double* src, const uchar* mask, double* sum, double* typedef int (*SumSqrFunc)(const uchar*, const uchar* mask, uchar*, uchar*, int, int); -static SumSqrFunc getSumSqrTab(int depth) +static SumSqrFunc getSumSqrTab(ElemType depth) { static SumSqrFunc sumSqrTab[] = { @@ -490,7 +491,8 @@ static bool ocl_meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv return false; { - int type = _src.type(), depth = CV_MAT_DEPTH(type); + ElemType type = _src.type(); + ElemType depth = CV_MAT_DEPTH(type); bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0, isContinuous = _src.isContinuous(), isMaskContinuous = _mask.isContinuous(); @@ -503,9 +505,9 @@ static bool ocl_meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv } size_t wgs = defDev.maxWorkGroupSize(); - int ddepth = std::max(CV_32S, depth), sqddepth = std::max(CV_32F, depth), - dtype = CV_MAKE_TYPE(ddepth, cn), - sqdtype = CV_MAKETYPE(sqddepth, cn); + ElemType ddepth = CV_MAX_DEPTH(CV_32S, depth), sqddepth = CV_MAX_DEPTH(CV_32F, depth); + ElemType sqdtype = CV_MAKETYPE(sqddepth, cn); + ElemType dtype = CV_MAKE_TYPE(ddepth, cn); CV_Assert(!haveMask || _mask.type() == CV_8UC1); int wgs2_aligned = 1; @@ -707,7 +709,7 @@ static bool ipp_meanStdDev(Mat& src, OutputArray _mean, OutputArray _sdv, Mat& m for( int c = cn; c < dcn_stddev; c++ ) pstddev[c] = 0; IppiSize sz = { cols, rows }; - int type = src.type(); + ElemType type = src.type(); if( !mask.empty() ) { typedef IppStatus (CV_STDCALL* ippiMaskMeanStdDevFuncC1)(const void *, int, const void *, int, IppiSize, Ipp64f *, Ipp64f *); @@ -799,7 +801,8 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_meanStdDev(src, _mean, _sdv, mask)); - int k, cn = src.channels(), depth = src.depth(); + int k, cn = src.channels(); + ElemType depth = src.depth(); SumSqrFunc func = getSumSqrTab(depth); diff --git a/modules/core/src/merge.cpp b/modules/core/src/merge.cpp index 1f74a06aba86..a0c710b70d99 100644 --- a/modules/core/src/merge.cpp +++ b/modules/core/src/merge.cpp @@ -212,7 +212,7 @@ void merge64s(const int64** src, int64* dst, int len, int cn ) typedef void (*MergeFunc)(const uchar** src, uchar* dst, int len, int cn); -static MergeFunc getMergeFunc(int depth) +static MergeFunc getMergeFunc(ElemType depth) { static MergeFunc mergeTab[] = { @@ -285,7 +285,7 @@ void cv::merge(const Mat* mv, size_t n, OutputArray _dst) CV_Assert( mv && n > 0 ); - int depth = mv[0].depth(); + ElemType depth = mv[0].depth(); bool allch1 = true; int k, cn = 0; size_t i; @@ -371,14 +371,17 @@ static bool ocl_merge( InputArrayOfArrays _mv, OutputArray _dst ) _mv.getUMatVector(src); CV_Assert(!src.empty()); - int type = src[0].type(), depth = CV_MAT_DEPTH(type), - rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1; + ElemType type = src[0].type(); + ElemType depth = CV_MAT_DEPTH(type); + int rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1; Size size = src[0].size(); for (size_t i = 0, srcsize = src.size(); i < srcsize; ++i) { - int itype = src[i].type(), icn = CV_MAT_CN(itype), idepth = CV_MAT_DEPTH(itype), - esz1 = CV_ELEM_SIZE1(idepth); + int itype = src[i].type(); + int icn = CV_MAT_CN(itype); + ElemType idepth = CV_MAT_DEPTH(itype); + int esz1 = CV_ELEM_SIZE1(idepth); if (src[i].dims > 2) return false; diff --git a/modules/core/src/minmax.cpp b/modules/core/src/minmax.cpp index 7c5b31839802..d989923508a6 100644 --- a/modules/core/src/minmax.cpp +++ b/modules/core/src/minmax.cpp @@ -93,7 +93,7 @@ static void minMaxIdx_64f(const double* src, const uchar* mask, double* minval, typedef void (*MinMaxIdxFunc)(const uchar*, const uchar*, int*, int*, size_t*, size_t*, int, size_t); -static MinMaxIdxFunc getMinmaxTab(int depth) +static MinMaxIdxFunc getMinmaxTab(ElemType depth) { static MinMaxIdxFunc minmaxTab[] = { @@ -230,7 +230,7 @@ typedef void (*getMinMaxResFunc)(const Mat & db, double * minVal, double * maxVa int * minLoc, int *maxLoc, int gropunum, int cols, double * maxVal2); bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int* minLoc, int* maxLoc, InputArray _mask, - int ddepth, bool absValues, InputArray _src2, double * maxVal2) + ElemType ddepth, bool absValues, InputArray _src2, double * maxVal2) { const ocl::Device & dev = ocl::Device::getDefault(); @@ -241,7 +241,9 @@ bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int* minLoc bool doubleSupport = dev.doubleFPConfig() > 0, haveMask = !_mask.empty(), haveSrc2 = _src2.kind() != _InputArray::NONE; - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), + ElemType type = _src.type(); + ElemType depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), kercn = haveMask ? cn : std::min(4, ocl::predictOptimalVectorWidth(_src, _src2)); // disabled following modes since it occasionally fails on AMD devices (e.g. A10-6800K, sep. 2014) @@ -251,7 +253,7 @@ bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int* minLoc CV_Assert( (cn == 1 && (!haveMask || _mask.type() == CV_8U)) || (cn >= 1 && !minLoc && !maxLoc) ); - if (ddepth < 0) + if (ddepth == CV_TYPE_AUTO) ddepth = depth; CV_Assert(!haveSrc2 || _src2.type() == type); @@ -374,7 +376,7 @@ namespace ovx { } static bool openvx_minMaxIdx(Mat &src, double* minVal, double* maxVal, int* minIdx, int* maxIdx, Mat &mask) { - int stype = src.type(); + ElemType stype = src.type(); size_t total_size = src.total(); int rows = src.size[0], cols = rows ? (int)(total_size / rows) : 0; if ((stype != CV_8UC1 && stype != CV_16SC1) || !mask.empty() || @@ -748,7 +750,9 @@ void cv::minMaxIdx(InputArray _src, double* minVal, { CV_INSTRUMENT_REGION(); - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemType depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); CV_Assert( (cn == 1 && (_mask.empty() || _mask.type() == CV_8U)) || (cn > 1 && _mask.empty() && !minIdx && !maxIdx) ); diff --git a/modules/core/src/norm.cpp b/modules/core/src/norm.cpp index e0642ea3d919..417bee2a2500 100644 --- a/modules/core/src/norm.cpp +++ b/modules/core/src/norm.cpp @@ -395,7 +395,7 @@ CV_DEF_NORM_ALL(64f, double, double, double, double) typedef int (*NormFunc)(const uchar*, const uchar*, uchar*, int, int); typedef int (*NormDiffFunc)(const uchar*, const uchar*, const uchar*, uchar*, int, int); -static NormFunc getNormFunc(int normType, int depth) +static NormFunc getNormFunc(int normType, ElemType depth) { static NormFunc normTab[3][8] = { @@ -416,7 +416,7 @@ static NormFunc getNormFunc(int normType, int depth) return normTab[normType][depth]; } -static NormDiffFunc getNormDiffFunc(int normType, int depth) +static NormDiffFunc getNormDiffFunc(int normType, ElemType depth) { static NormDiffFunc normDiffTab[3][8] = { @@ -456,7 +456,8 @@ static bool ocl_norm( InputArray _src, int normType, InputArray _mask, double & const int cn = _src.channels(); if (cn > 4) return false; - int type = _src.type(), depth = CV_MAT_DEPTH(type); + ElemType type = _src.type(); + ElemType depth = CV_MAT_DEPTH(type); bool doubleSupport = d.doubleFPConfig() > 0, haveMask = _mask.kind() != _InputArray::NONE; @@ -469,7 +470,7 @@ static bool ocl_norm( InputArray _src, int normType, InputArray _mask, double & if (normType == NORM_INF) { if (!ocl_minMaxIdx(_src, NULL, &result, NULL, NULL, _mask, - std::max(depth, CV_32S), depth != CV_8U && depth != CV_16U)) + CV_MAX_DEPTH(depth, CV_32S), depth != CV_8U && depth != CV_16U)) return false; } else if (normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR) @@ -508,7 +509,7 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result) if( !mask.empty() ) { IppiSize sz = { cols, rows }; - int type = src.type(); + ElemType type = src.type(); typedef IppStatus (CV_STDCALL* ippiMaskNormFuncC1)(const void *, int, const void *, int, IppiSize, Ipp64f *); ippiMaskNormFuncC1 ippiNorm_C1MR = @@ -573,7 +574,7 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result) else { IppiSize sz = { cols*src.channels(), rows }; - int type = src.depth(); + ElemType type = src.depth(); typedef IppStatus (CV_STDCALL* ippiNormFuncHint)(const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint); typedef IppStatus (CV_STDCALL* ippiNormFuncNoHint)(const void *, int, IppiSize, Ipp64f *); @@ -645,7 +646,8 @@ double cv::norm( InputArray _src, int normType, InputArray _mask ) Mat src = _src.getMat(), mask = _mask.getMat(); CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_norm(src, normType, mask, _result), _result); - int depth = src.depth(), cn = src.channels(); + ElemType depth = src.depth(); + int cn = src.channels(); if( src.isContinuous() && mask.empty() ) { size_t len = src.total()*cn; @@ -819,7 +821,8 @@ static bool ocl_norm( InputArray _src1, InputArray _src2, int normType, InputArr int cn = _src1.channels(); if (cn > 4) return false; - int type = _src1.type(), depth = CV_MAT_DEPTH(type); + int type = _src1.type(); + ElemType depth = CV_MAT_DEPTH(type); bool relative = (normType & NORM_RELATIVE) != 0; normType &= ~NORM_RELATIVE; bool normsum = normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR; @@ -837,7 +840,7 @@ static bool ocl_norm( InputArray _src1, InputArray _src2, int normType, InputArr } else { - if (!ocl_minMaxIdx(_src1, NULL, &sc1[0], NULL, NULL, _mask, std::max(CV_32S, depth), + if (!ocl_minMaxIdx(_src1, NULL, &sc1[0], NULL, NULL, _mask, CV_MAX_DEPTH(CV_32S, depth), false, _src2, relative ? &sc2[0] : NULL)) return false; cn = 1; @@ -922,7 +925,7 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra else { IppiSize sz = { cols*src1.channels(), rows }; - int type = src1.depth(); + ElemType type = src1.depth(); typedef IppStatus (CV_STDCALL* ippiNormRelFuncHint)(const void *, int, const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint); typedef IppStatus (CV_STDCALL* ippiNormRelFuncNoHint)(const void *, int, const void *, int, IppiSize, Ipp64f *); @@ -1051,7 +1054,7 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra else { IppiSize sz = { cols*src1.channels(), rows }; - int type = src1.depth(); + ElemType type = src1.depth(); typedef IppStatus (CV_STDCALL* ippiNormDiffFuncHint)(const void *, int, const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint); typedef IppStatus (CV_STDCALL* ippiNormDiffFuncNoHint)(const void *, int, const void *, int, IppiSize, Ipp64f *); @@ -1125,7 +1128,8 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m } Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat(); - int depth = src1.depth(), cn = src1.channels(); + ElemType depth = src1.depth(); + int cn = src1.channels(); normType &= 7; CV_Assert( normType == NORM_INF || normType == NORM_L1 || diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index 50dd13b533ed..4bdfc031933e 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -1993,7 +1993,7 @@ struct Context::Impl }; cl_uint i, nd0 = 0, nd = 0; - int dtype = dtype0 & 15; + ElemType dtype = static_cast(dtype0 & 15); CV_OCL_DBG_CHECK(clGetDeviceIDs(pl, dtype, 0, 0, &nd0)); AutoBuffer dlistbuf(nd0*2+1); @@ -2007,9 +2007,9 @@ struct Context::Impl Device d(dlist[i]); if( !d.available() || !d.compilerAvailable() ) continue; - if( dtype0 == Device::TYPE_DGPU && d.hostUnifiedMemory() ) + if (dtype0 == static_cast(Device::TYPE_DGPU) && d.hostUnifiedMemory()) continue; - if( dtype0 == Device::TYPE_IGPU && !d.hostUnifiedMemory() ) + if( dtype0 == static_cast(Device::TYPE_IGPU) && !d.hostUnifiedMemory() ) continue; String name = d.name(); if( nd != 0 && name != name0 ) @@ -4515,7 +4515,7 @@ class OpenCLAllocator CV_FINAL : public MatAllocator flushCleanupQueue(); } - UMatData* defaultAllocate(int dims, const int* sizes, int type, void* data, size_t* step, + UMatData* defaultAllocate(int dims, const int* sizes, ElemType type, void* data, size_t* step, AccessFlag flags, UMatUsageFlags usageFlags) const { UMatData* u = matStdAllocator->allocate(dims, sizes, type, data, step, flags, usageFlags); @@ -4535,7 +4535,7 @@ class OpenCLAllocator CV_FINAL : public MatAllocator flags0 = UMatData::COPY_ON_MAP; } - UMatData* allocate(int dims, const int* sizes, int type, + UMatData* allocate(int dims, const int* sizes, ElemType type, void* data, size_t* step, AccessFlag flags, UMatUsageFlags usageFlags) const CV_OVERRIDE { if(!useOpenCL()) @@ -5703,7 +5703,7 @@ namespace cv { namespace ocl { /* // Convert OpenCL buffer memory to UMat */ -void convertFromBuffer(void* cl_mem_buffer, size_t step, int rows, int cols, int type, UMat& dst) +void convertFromBuffer(void* cl_mem_buffer, size_t step, int rows, int cols, ElemType type, UMat& dst) { int d = 2; int sizes[] = { rows, cols }; @@ -5712,7 +5712,7 @@ void convertFromBuffer(void* cl_mem_buffer, size_t step, int rows, int cols, int dst.release(); - dst.flags = (type & Mat::TYPE_MASK) | Mat::MAGIC_VAL; + dst.flags = static_cast(Mat::MAGIC_VAL | (type & Mat::TYPE_MASK)); dst.usageFlags = USAGE_DEFAULT; setSize(dst, d, sizes, 0, true); @@ -5765,7 +5765,7 @@ void convertFromImage(void* cl_mem_image, UMat& dst) cl_image_format fmt = { 0, 0 }; CV_OCL_CHECK(clGetImageInfo(clImage, CL_IMAGE_FORMAT, sizeof(cl_image_format), &fmt, 0)); - int depth = CV_8U; + ElemType depth = CV_8U; switch (fmt.image_channel_data_type) { case CL_UNORM_INT8: @@ -5983,7 +5983,8 @@ const char* typeToStr(int type) "double", "double2", "double3", "double4", 0, 0, 0, "double8", 0, 0, 0, 0, 0, 0, 0, "double16", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?" }; - int cn = CV_MAT_CN(type), depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); + ElemType depth = CV_MAT_DEPTH(type); return cn > 16 ? "?" : tab[depth*16 + cn-1]; } @@ -6000,7 +6001,8 @@ const char* memopTypeToStr(int type) "ulong", "ulong2", "ulong3", "ulong4", 0, 0, 0, "ulong8", 0, 0, 0, 0, 0, 0, 0, "ulong16", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?" }; - int cn = CV_MAT_CN(type), depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); + ElemType depth = CV_MAT_DEPTH(type); return cn > 16 ? "?" : tab[depth*16 + cn-1]; } @@ -6017,11 +6019,12 @@ const char* vecopTypeToStr(int type) "ulong", "ulong2", "ulong3", "ulong4", 0, 0, 0, "ulong8", 0, 0, 0, 0, 0, 0, 0, "ulong16", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?" }; - int cn = CV_MAT_CN(type), depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); + ElemType depth = CV_MAT_DEPTH(type); return cn > 16 ? "?" : tab[depth*16 + cn-1]; } -const char* convertTypeStr(int sdepth, int ddepth, int cn, char* buf) +const char* convertTypeStr(ElemType sdepth, ElemType ddepth, int cn, char* buf) { if( sdepth == ddepth ) return "noconvert"; @@ -6127,7 +6130,8 @@ const char* getOpenCLErrorString(int errorCode) template static std::string kerToStr(const Mat & k) { - int width = k.cols - 1, depth = k.depth(); + int width = k.cols - 1; + ElemType depth = k.depth(); const T * const data = k.ptr(); std::ostringstream stream; @@ -6156,12 +6160,12 @@ static std::string kerToStr(const Mat & k) return stream.str(); } -String kernelToStr(InputArray _kernel, int ddepth, const char * name) +String kernelToStr(InputArray _kernel, ElemType ddepth, const char * name) { Mat kernel = _kernel.getMat().reshape(1, 1); - int depth = kernel.depth(); - if (ddepth < 0) + ElemType depth = kernel.depth(); + if (ddepth == CV_TYPE_AUTO) ddepth = depth; if (ddepth != depth) @@ -6183,7 +6187,9 @@ String kernelToStr(InputArray _kernel, int ddepth, const char * name) { \ CV_Assert(src.isMat() || src.isUMat()); \ Size csize = src.size(); \ - int ctype = src.type(), ccn = CV_MAT_CN(ctype), cdepth = CV_MAT_DEPTH(ctype), \ + ElemType ctype = src.type(); \ + ElemType cdepth = CV_MAT_DEPTH(ctype); \ + int ccn = CV_MAT_CN(ctype), \ ckercn = vectorWidths[cdepth], cwidth = ccn * csize.width; \ if (cwidth < ckercn || ckercn <= 0) \ return 1; \ @@ -6271,7 +6277,8 @@ void buildOptionsAddMatrixDescription(String& buildOptions, const String& name, { if (!buildOptions.empty()) buildOptions += " "; - int type = _m.type(), depth = CV_MAT_DEPTH(type); + ElemType type = _m.type(); + ElemType depth = CV_MAT_DEPTH(type); buildOptions += format( "-D %s_T=%s -D %s_T1=%s -D %s_CN=%d -D %s_TSIZE=%d -D %s_T1SIZE=%d -D %s_DEPTH=%d", name.c_str(), ocl::typeToStr(type), @@ -6299,7 +6306,7 @@ struct Image2D::Impl clReleaseMemObject(handle); } - static cl_image_format getImageFormat(int depth, int cn, bool norm) + static cl_image_format getImageFormat(ElemType depth, int cn, bool norm) { cl_image_format format; static const int channelTypes[] = { CL_UNSIGNED_INT8, CL_SIGNED_INT8, CL_UNSIGNED_INT16, @@ -6350,7 +6357,9 @@ struct Image2D::Impl CV_Assert(!src.empty()); CV_Assert(ocl::Device::getDefault().imageSupport()); - int err, depth = src.depth(), cn = src.channels(); + int err; + ElemType depth = src.depth(); + int cn = src.channels(); CV_Assert(cn <= 4); cl_image_format format = getImageFormat(depth, cn, norm); @@ -6463,7 +6472,7 @@ bool Image2D::canCreateAlias(const UMat &m) return ret; } -bool Image2D::isFormatSupported(int depth, int cn, bool norm) +bool Image2D::isFormatSupported(ElemType depth, int cn, bool norm) { cl_image_format format = Impl::getImageFormat(depth, cn, norm); diff --git a/modules/core/src/opengl.cpp b/modules/core/src/opengl.cpp index dc122f2fd7a4..a002a4346d61 100644 --- a/modules/core/src/opengl.cpp +++ b/modules/core/src/opengl.cpp @@ -448,7 +448,7 @@ void cv::ogl::Buffer::Impl::unmapDevice(cudaStream_t stream) #endif // HAVE_OPENGL -cv::ogl::Buffer::Buffer() : rows_(0), cols_(0), type_(0) +cv::ogl::Buffer::Buffer() : rows_(0), cols_(0), type_(static_cast(0)) { #ifndef HAVE_OPENGL throw_no_ogl(); @@ -457,7 +457,7 @@ cv::ogl::Buffer::Buffer() : rows_(0), cols_(0), type_(0) #endif } -cv::ogl::Buffer::Buffer(int arows, int acols, int atype, unsigned int abufId, bool autoRelease) : rows_(0), cols_(0), type_(0) +cv::ogl::Buffer::Buffer(int arows, int acols, ElemType atype, unsigned int abufId, bool autoRelease) : rows_(0), cols_(0), type_(static_cast(0)) { #ifndef HAVE_OPENGL CV_UNUSED(arows); @@ -474,7 +474,7 @@ cv::ogl::Buffer::Buffer(int arows, int acols, int atype, unsigned int abufId, bo #endif } -cv::ogl::Buffer::Buffer(Size asize, int atype, unsigned int abufId, bool autoRelease) : rows_(0), cols_(0), type_(0) +cv::ogl::Buffer::Buffer(Size asize, ElemType atype, unsigned int abufId, bool autoRelease) : rows_(0), cols_(0), type_(static_cast(0)) { #ifndef HAVE_OPENGL CV_UNUSED(asize); @@ -490,7 +490,7 @@ cv::ogl::Buffer::Buffer(Size asize, int atype, unsigned int abufId, bool autoRel #endif } -cv::ogl::Buffer::Buffer(InputArray arr, Target target, bool autoRelease) : rows_(0), cols_(0), type_(0) +cv::ogl::Buffer::Buffer(InputArray arr, Target target, bool autoRelease) : rows_(0), cols_(0), type_(static_cast(0)) { #ifndef HAVE_OPENGL CV_UNUSED(arr); @@ -522,7 +522,7 @@ cv::ogl::Buffer::Buffer(InputArray arr, Target target, bool autoRelease) : rows_ #endif } -void cv::ogl::Buffer::create(int arows, int acols, int atype, Target target, bool autoRelease) +void cv::ogl::Buffer::create(int arows, int acols, ElemType atype, Target target, bool autoRelease) { #ifndef HAVE_OPENGL CV_UNUSED(arows); @@ -576,7 +576,7 @@ void cv::ogl::Buffer::copyFrom(InputArray arr, Target target, bool autoRelease) const int kind = arr.kind(); const Size asize = arr.size(); - const int atype = arr.type(); + const ElemType atype = arr.type(); create(asize, atype, target, autoRelease); switch (kind) @@ -977,9 +977,9 @@ cv::ogl::Texture2D::Texture2D(InputArray arr, bool autoRelease) : rows_(0), cols const int kind = arr.kind(); const Size asize = arr.size(); - const int atype = arr.type(); + const ElemType atype = arr.type(); - const int depth = CV_MAT_DEPTH(atype); + const ElemType depth = CV_MAT_DEPTH(atype); const int cn = CV_MAT_CN(atype); CV_Assert( depth <= CV_32F ); @@ -1089,9 +1089,9 @@ void cv::ogl::Texture2D::copyFrom(InputArray arr, bool autoRelease) const int kind = arr.kind(); const Size asize = arr.size(); - const int atype = arr.type(); + const ElemType atype = arr.type(); - const int depth = CV_MAT_DEPTH(atype); + const ElemType depth = CV_MAT_DEPTH(atype); const int cn = CV_MAT_CN(atype); CV_Assert( depth <= CV_32F ); @@ -1146,7 +1146,7 @@ void cv::ogl::Texture2D::copyFrom(InputArray arr, bool autoRelease) #endif } -void cv::ogl::Texture2D::copyTo(OutputArray arr, int ddepth, bool autoRelease) const +void cv::ogl::Texture2D::copyTo(OutputArray arr, ElemType ddepth, bool autoRelease) const { #ifndef HAVE_OPENGL CV_UNUSED(arr); @@ -1224,7 +1224,7 @@ unsigned int cv::ogl::Texture2D::texId() const void cv::ogl::Arrays::setVertexArray(InputArray vertex) { const int cn = vertex.channels(); - const int depth = vertex.depth(); + const ElemType depth = vertex.depth(); CV_Assert( cn == 2 || cn == 3 || cn == 4 ); CV_Assert( depth == CV_16S || depth == CV_32S || depth == CV_32F || depth == CV_64F ); @@ -1263,7 +1263,7 @@ void cv::ogl::Arrays::resetColorArray() void cv::ogl::Arrays::setNormalArray(InputArray normal) { const int cn = normal.channels(); - const int depth = normal.depth(); + const ElemType depth = normal.depth(); CV_Assert( cn == 3 ); CV_Assert( depth == CV_8S || depth == CV_16S || depth == CV_32S || depth == CV_32F || depth == CV_64F ); @@ -1282,7 +1282,7 @@ void cv::ogl::Arrays::resetNormalArray() void cv::ogl::Arrays::setTexCoordArray(InputArray texCoord) { const int cn = texCoord.channels(); - const int depth = texCoord.depth(); + const ElemType depth = texCoord.depth(); CV_Assert( cn >= 1 && cn <= 4 ); CV_Assert( depth == CV_16S || depth == CV_32S || depth == CV_32F || depth == CV_64F ); @@ -1515,7 +1515,7 @@ void cv::ogl::render(const ogl::Arrays& arr, InputArray indices, int mode, Scala { ogl::Buffer buf = indices.getOGlBuffer(); - const int depth = buf.depth(); + const ElemType depth = buf.depth(); CV_Assert( buf.channels() == 1 ); CV_Assert( depth <= CV_32S ); @@ -1541,7 +1541,7 @@ void cv::ogl::render(const ogl::Arrays& arr, InputArray indices, int mode, Scala { Mat mat = indices.getMat(); - const int depth = mat.depth(); + const ElemType depth = mat.depth(); CV_Assert( mat.channels() == 1 ); CV_Assert( depth <= CV_32S ); @@ -1755,7 +1755,7 @@ void convertFromGLTexture2D(const Texture2D& texture, OutputArray dst) NO_OPENCL_SHARING_ERROR; #else // check texture format - const int dtype = CV_8UC4; + const ElemType dtype = CV_8UC4; CV_Assert(texture.format() == Texture2D::RGBA); int textureType = dtype; @@ -1849,7 +1849,7 @@ UMat mapGLBuffer(const Buffer& buffer, AccessFlag accessFlags) size_t step = buffer.cols() * buffer.elemSize(); int rows = buffer.rows(); int cols = buffer.cols(); - int type = buffer.type(); + ElemType type = buffer.type(); UMat u; convertFromBuffer(clBuffer, step, rows, cols, type, u); diff --git a/modules/core/src/pca.cpp b/modules/core/src/pca.cpp index 79126a8f3601..08adaac7941e 100644 --- a/modules/core/src/pca.cpp +++ b/modules/core/src/pca.cpp @@ -94,7 +94,7 @@ PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, int maxComp if( len <= in_count ) covar_flags |= CV_COVAR_NORMAL; - int ctype = std::max(CV_32F, data.depth()); + ElemType ctype = CV_MAKETYPE(CV_MAX_DEPTH(CV_32F, data.depth()), 1); mean.create( mean_sz, ctype ); Mat covar( count, count, ctype ); @@ -106,7 +106,7 @@ PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, int maxComp covar_flags |= CV_COVAR_USE_AVG; } - calcCovarMatrix( data, covar, mean, covar_flags, ctype ); + calcCovarMatrix( data, covar, mean, covar_flags, CV_MAT_DEPTH(ctype) ); eigen( covar, eigenvalues, eigenvectors ); if( !(covar_flags & CV_COVAR_NORMAL) ) @@ -230,7 +230,7 @@ PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, double reta if( len <= in_count ) covar_flags |= CV_COVAR_NORMAL; - int ctype = std::max(CV_32F, data.depth()); + ElemType ctype = CV_MAKETYPE(CV_MAX_DEPTH(CV_32F, data.depth()), 1); mean.create( mean_sz, ctype ); Mat covar( count, count, ctype ); @@ -242,7 +242,7 @@ PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, double reta covar_flags |= CV_COVAR_USE_AVG; } - calcCovarMatrix( data, covar, mean, covar_flags, ctype ); + calcCovarMatrix( data, covar, mean, covar_flags, CV_MAT_DEPTH(ctype) ); eigen( covar, eigenvalues, eigenvectors ); if( !(covar_flags & CV_COVAR_NORMAL) ) @@ -295,7 +295,7 @@ void PCA::project(InputArray _data, OutputArray result) const CV_Assert( !mean.empty() && !eigenvectors.empty() && ((mean.rows == 1 && mean.cols == data.cols) || (mean.cols == 1 && mean.rows == data.rows))); Mat tmp_data, tmp_mean = repeat(mean, data.rows/mean.rows, data.cols/mean.cols); - int ctype = mean.type(); + ElemType ctype = mean.type(); if( data.type() != ctype || tmp_mean.data == mean.data ) { data.convertTo( tmp_data, ctype ); diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp index 30101dce062b..da829126517d 100644 --- a/modules/core/src/persistence.cpp +++ b/modules/core/src/persistence.cpp @@ -641,9 +641,9 @@ int icvCalcStructSize( const char* dt, int initial_size ) return size; } -int icvDecodeSimpleFormat( const char* dt ) +ElemType icvDecodeSimpleFormat(const char* dt) { - int elem_type = -1; + ElemType elem_type = CV_TYPE_AUTO; int fmt_pairs[CV_FS_MAX_FMT_PAIRS], fmt_pair_count; fmt_pair_count = icvDecodeFormat( dt, fmt_pairs, CV_FS_MAX_FMT_PAIRS ); diff --git a/modules/core/src/persistence.hpp b/modules/core/src/persistence.hpp index aa0acabd8ec9..010a49f9a027 100644 --- a/modules/core/src/persistence.hpp +++ b/modules/core/src/persistence.hpp @@ -264,7 +264,7 @@ int icvCalcElemSize( const char* dt, int initial_size ); void CV_NORETURN icvParseError( CvFileStorage* fs, const char* func_name, const char* err_msg, const char* source_file, int source_line ); char* icvEncodeFormat( int elem_type, char* dt ); int icvDecodeFormat( const char* dt, int* fmt_pairs, int max_len ); -int icvDecodeSimpleFormat( const char* dt ); +ElemType icvDecodeSimpleFormat(const char* dt); void icvWriteFileNode( CvFileStorage* fs, const char* name, const CvFileNode* node ); void icvWriteCollection( CvFileStorage* fs, const CvFileNode* node ); void switch_to_Base64_state( CvFileStorage* fs, base64::fs::State state ); diff --git a/modules/core/src/persistence_base64.cpp b/modules/core/src/persistence_base64.cpp index 8d6e6cc7d0bf..3c756b9646bc 100644 --- a/modules/core/src/persistence_base64.cpp +++ b/modules/core/src/persistence_base64.cpp @@ -745,7 +745,7 @@ class BinaryToCvSeqConvertor typedef size_t(*binary_to_t)(uchar const *, uchar *); struct binary_to_filenode_t { - size_t cv_type; + ElemType cv_type; size_t offset; binary_to_t func; }; diff --git a/modules/core/src/persistence_c.cpp b/modules/core/src/persistence_c.cpp index 7980a04bdd9e..5e2791e64dec 100644 --- a/modules/core/src/persistence_c.cpp +++ b/modules/core/src/persistence_c.cpp @@ -939,7 +939,7 @@ cvWriteRawData( CvFileStorage* fs, const void* _data, int len, const char* dt ) for( k = 0; k < fmt_pair_count; k++ ) { int i, count = fmt_pairs[k*2]; - int elem_type = fmt_pairs[k*2+1]; + ElemType elem_type = static_cast(fmt_pairs[k * 2 + 1]); int elem_size = CV_ELEM_SIZE(elem_type); const char* data, *ptr; diff --git a/modules/core/src/persistence_types.cpp b/modules/core/src/persistence_types.cpp index 2f4cc254dc47..8a5879e70e96 100644 --- a/modules/core/src/persistence_types.cpp +++ b/modules/core/src/persistence_types.cpp @@ -72,7 +72,8 @@ static void* icvReadMat( CvFileStorage* fs, CvFileNode* node ) CvMat* mat; const char* dt; CvFileNode* data; - int rows, cols, elem_type; + int rows, cols; + ElemType elem_type; rows = cvReadIntByName( fs, node, "rows", -1 ); cols = cvReadIntByName( fs, node, "cols", -1 ); @@ -151,7 +152,8 @@ static void* icvReadMatND( CvFileStorage* fs, CvFileNode* node ) const char* dt; CvFileNode* data; CvFileNode* sizes_node; - int sizes[CV_MAX_DIM] = {0}, dims, elem_type; + int sizes[CV_MAX_DIM] = { 0 }, dims; + ElemType elem_type; int i, total_size; sizes_node = cvGetFileNodeByName( fs, node, "sizes" ); @@ -302,7 +304,8 @@ static void* icvReadSparseMat( CvFileStorage* fs, CvFileNode* node ) CvFileNode* sizes_node; CvSeqReader reader; CvSeq* elements; - int sizes[CV_MAX_DIM], dims, elem_type, cn; + int sizes[CV_MAX_DIM], dims, cn; + ElemType elem_type; int i; sizes_node = cvGetFileNodeByName( fs, node, "sizes" ); @@ -381,7 +384,8 @@ static void icvWriteImage( CvFileStorage* fs, const char* name, const void* stru const IplImage* image = (const IplImage*)struct_ptr; char dt_buf[16], *dt; cv::Size size; - int y, depth; + int y; + ElemType depth; assert( CV_IS_IMAGE(image) ); @@ -407,7 +411,7 @@ static void icvWriteImage( CvFileStorage* fs, const char* name, const void* stru cvEndWriteStruct( fs ); } - depth = IPL2CV_DEPTH(image->depth); + depth = static_cast(IPL2CV_DEPTH(image->depth)); dt = icvEncodeFormat(depth, dt_buf); cvWriteString( fs, "dt", dt, 0 ); @@ -435,7 +439,9 @@ static void* icvReadImage( CvFileStorage* fs, CvFileNode* node ) CvFileNode* roi_node; CvSeqReader reader; cv::Rect roi; - int y, width, height, elem_type, coi, depth; + int y, width, height, coi; + ElemType elem_type; + ElemType depth; const char* origin, *data_order; width = cvReadIntByName( fs, node, "width", 0 ); @@ -459,7 +465,7 @@ static void* icvReadImage( CvFileStorage* fs, CvFileNode* node ) CV_Error( CV_StsUnmatchedSizes, "The matrix size does not match to the number of stored elements" ); - depth = cvIplDepth(elem_type); + depth = static_cast(cvIplDepth(elem_type)); image = cvCreateImage( cvSize(width,height), depth, CV_MAT_CN(elem_type) ); roi_node = cvGetFileNodeByName( fs, node, "roi" ); diff --git a/modules/core/src/precomp.hpp b/modules/core/src/precomp.hpp index 796edb98ec5c..9992564825dc 100644 --- a/modules/core/src/precomp.hpp +++ b/modules/core/src/precomp.hpp @@ -136,8 +136,8 @@ typedef void (*BinaryFuncC)(const uchar* src1, size_t step1, uchar* dst, size_t step, int width, int height, void*); -BinaryFunc getConvertFunc(int sdepth, int ddepth); -BinaryFunc getConvertScaleFunc(int sdepth, int ddepth); +BinaryFunc getConvertFunc(ElemType sdepth, ElemType ddepth); +BinaryFunc getConvertScaleFunc(ElemType sdepth, ElemType ddepth); BinaryFunc getCopyMaskFunc(size_t esz); /* default memory block for sparse array elements */ @@ -149,10 +149,10 @@ BinaryFunc getCopyMaskFunc(size_t esz); /* maximal average node_count/hash_size ratio beyond which hash table is resized */ #define CV_SPARSE_HASH_RATIO 3 -inline Size getContinuousSize_( int flags, int cols, int rows, int widthScale ) +inline Size getContinuousSize_( MagicFlag flags, int cols, int rows, int widthScale ) { int64 sz = (int64)cols * rows * widthScale; - return (flags & Mat::CONTINUOUS_FLAG) != 0 && + return !!(flags & static_cast(Mat::CONTINUOUS_FLAG)) && (int)sz == sz ? Size((int)sz, 1) : Size(cols * widthScale, rows); } @@ -193,7 +193,7 @@ inline Size getContinuousSize( const Mat& m1, const Mat& m2, void setSize( Mat& m, int _dims, const int* _sz, const size_t* _steps, bool autoSteps=false ); void finalizeHdr(Mat& m); -int updateContinuityFlag(int flags, int dims, const int* size, const size_t* step); +MagicFlag updateContinuityFlag(MagicFlag flags, int dims, const int* size, const size_t* step); struct NoVec { diff --git a/modules/core/src/rand.cpp b/modules/core/src/rand.cpp index bcc6ff157c77..4e72aa1cf81e 100644 --- a/modules/core/src/rand.cpp +++ b/modules/core/src/rand.cpp @@ -394,7 +394,8 @@ void RNG::fill( InputOutputArray _mat, int disttype, CV_Assert(!_mat.empty()); Mat mat = _mat.getMat(), _param1 = _param1arg.getMat(), _param2 = _param2arg.getMat(); - int depth = mat.depth(), cn = mat.channels(); + ElemType depth = mat.depth(); + int cn = mat.channels(); AutoBuffer _parambuf; int j, k; bool fast_int_mode = false; diff --git a/modules/core/src/split.cpp b/modules/core/src/split.cpp index 92a6bbabbed0..100c0824eefa 100644 --- a/modules/core/src/split.cpp +++ b/modules/core/src/split.cpp @@ -220,7 +220,7 @@ void split64s(const int64* src, int64** dst, int len, int cn ) typedef void (*SplitFunc)(const uchar* src, uchar** dst, int len, int cn); -static SplitFunc getSplitFunc(int depth) +static SplitFunc getSplitFunc(ElemType depth) { static SplitFunc splitTab[] = { @@ -291,7 +291,8 @@ void cv::split(const Mat& src, Mat* mv) { CV_INSTRUMENT_REGION(); - int k, depth = src.depth(), cn = src.channels(); + int k, cn = src.channels(); + ElemType depth = src.depth(); if( cn == 1 ) { src.copyTo(mv[0]); @@ -347,7 +348,9 @@ namespace cv { static bool ocl_split( InputArray _m, OutputArrayOfArrays _mv ) { - int type = _m.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), + ElemType type = _m.type(); + ElemType depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1; String dstargs, processelem, indexdecl; @@ -401,9 +404,10 @@ void cv::split(InputArray _m, OutputArrayOfArrays _mv) return; } - CV_Assert( !_mv.fixedType() || _mv.empty() || _mv.type() == m.depth() ); + CV_Assert( !_mv.fixedType() || _mv.empty() || _mv.type() == CV_MAKETYPE(m.depth(), 1) ); - int depth = m.depth(), cn = m.channels(); + ElemType depth = m.depth(); + int cn = m.channels(); _mv.create(cn, 1, depth); for (int i = 0; i < cn; ++i) _mv.create(m.dims, m.size.p, depth, i); diff --git a/modules/core/src/stat.hpp b/modules/core/src/stat.hpp index 23ef0688e3d1..868548a9d3a4 100644 --- a/modules/core/src/stat.hpp +++ b/modules/core/src/stat.hpp @@ -16,7 +16,7 @@ enum { OCL_OP_SUM = 0, OCL_OP_SUM_ABS = 1, OCL_OP_SUM_SQR = 2 }; bool ocl_sum( InputArray _src, Scalar & res, int sum_op, InputArray _mask = noArray(), InputArray _src2 = noArray(), bool calc2 = false, const Scalar & res2 = Scalar() ); bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int* minLoc, int* maxLoc, InputArray _mask, - int ddepth = -1, bool absValues = false, InputArray _src2 = noArray(), double * maxVal2 = NULL); + ElemType ddepth = CV_TYPE_AUTO, bool absValues = false, InputArray _src2 = noArray(), double * maxVal2 = NULL); template Scalar ocl_part_sum(Mat m) { @@ -36,7 +36,7 @@ template Scalar ocl_part_sum(Mat m) #endif typedef int (*SumFunc)(const uchar*, const uchar* mask, uchar*, int, int); -SumFunc getSumFunc(int depth); +SumFunc getSumFunc(ElemType depth); } diff --git a/modules/core/src/sum.cpp b/modules/core/src/sum.cpp index 30cee85b4c12..39427e0d1ee9 100644 --- a/modules/core/src/sum.cpp +++ b/modules/core/src/sum.cpp @@ -429,7 +429,7 @@ static int sum32f( const float* src, const uchar* mask, double* dst, int len, in static int sum64f( const double* src, const uchar* mask, double* dst, int len, int cn ) { return sum_(src, mask, dst, len, cn); } -SumFunc getSumFunc(int depth) +SumFunc getSumFunc(ElemType depth) { static SumFunc sumTab[] = { @@ -454,7 +454,9 @@ bool ocl_sum( InputArray _src, Scalar & res, int sum_op, InputArray _mask, bool doubleSupport = dev.doubleFPConfig() > 0, haveMask = _mask.kind() != _InputArray::NONE, haveSrc2 = _src2.kind() != _InputArray::NONE; - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), + ElemType type = _src.type(); + ElemType depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), kercn = cn == 1 && !haveMask ? ocl::predictOptimalVectorWidth(_src, _src2) : 1, mcn = std::max(cn, kercn); CV_Assert(!haveSrc2 || _src2.type() == type); @@ -466,8 +468,8 @@ bool ocl_sum( InputArray _src, Scalar & res, int sum_op, InputArray _mask, int ngroups = dev.maxComputeUnits(), dbsize = ngroups * (calc2 ? 2 : 1); size_t wgs = dev.maxWorkGroupSize(); - int ddepth = std::max(sum_op == OCL_OP_SUM_SQR ? CV_32F : CV_32S, depth), - dtype = CV_MAKE_TYPE(ddepth, cn); + ElemType ddepth = CV_MAX_DEPTH(sum_op == OCL_OP_SUM_SQR ? (CV_32F) : (CV_32S), depth); + ElemType dtype = CV_MAKE_TYPE(ddepth, cn); CV_Assert(!haveMask || _mask.type() == CV_8UC1); int wgs2_aligned = 1; @@ -552,7 +554,7 @@ static bool ipp_sum(Mat &src, Scalar &_res) if( src.dims == 2 || (src.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) ) { IppiSize sz = { cols, rows }; - int type = src.type(); + ElemType type = src.type(); typedef IppStatus (CV_STDCALL* ippiSumFuncHint)(const void*, int, IppiSize, double *, IppHintAlgorithm); typedef IppStatus (CV_STDCALL* ippiSumFuncNoHint)(const void*, int, IppiSize, double *); ippiSumFuncHint ippiSumHint = @@ -612,7 +614,8 @@ cv::Scalar cv::sum( InputArray _src ) Mat src = _src.getMat(); CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_sum(src, _res), _res); - int k, cn = src.channels(), depth = src.depth(); + int k, cn = src.channels(); + ElemType depth = src.depth(); SumFunc func = getSumFunc(depth); CV_Assert( cn <= 4 && func != 0 ); diff --git a/modules/core/src/umatrix.cpp b/modules/core/src/umatrix.cpp index 5e60d2c1ba3a..d86c34550661 100644 --- a/modules/core/src/umatrix.cpp +++ b/modules/core/src/umatrix.cpp @@ -400,7 +400,7 @@ UMat Mat::getUMat(AccessFlag accessFlags, UMatUsageFlags usageFlags) const return hdr; } -void UMat::create(int d, const int* _sizes, int _type, UMatUsageFlags _usageFlags) +void UMat::create(int d, const int* _sizes, ElemType _type, UMatUsageFlags _usageFlags) { this->usageFlags = _usageFlags; @@ -430,7 +430,7 @@ void UMat::create(int d, const int* _sizes, int _type, UMatUsageFlags _usageFlag release(); if( d == 0 ) return; - flags = (_type & CV_MAT_TYPE_MASK) | MAGIC_VAL; + flags = static_cast(MAGIC_VAL) | (_type & CV_MAT_TYPE_MASK); setSize(*this, d, _sizes, 0, true); offset = 0; @@ -460,7 +460,7 @@ void UMat::create(int d, const int* _sizes, int _type, UMatUsageFlags _usageFlag addref(); } -void UMat::create(const std::vector& _sizes, int _type, UMatUsageFlags _usageFlags) +void UMat::create(const std::vector& _sizes, ElemType _type, UMatUsageFlags _usageFlags) { create((int)_sizes.size(), _sizes.data(), _type, _usageFlags); } @@ -492,7 +492,7 @@ void UMat::deallocate() UMat::UMat(const UMat& m, const Range& _rowRange, const Range& _colRange) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows) { CV_Assert( m.dims >= 2 ); if( m.dims > 2 ) @@ -512,7 +512,7 @@ UMat::UMat(const UMat& m, const Range& _rowRange, const Range& _colRange) CV_Assert( 0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows ); rows = _rowRange.size(); offset += step*_rowRange.start; - flags |= SUBMATRIX_FLAG; + flags |= static_cast(SUBMATRIX_FLAG); } if( _colRange != Range::all() && _colRange != Range(0,cols) ) @@ -520,7 +520,7 @@ UMat::UMat(const UMat& m, const Range& _rowRange, const Range& _colRange) CV_Assert( 0 <= _colRange.start && _colRange.start <= _colRange.end && _colRange.end <= m.cols ); cols = _colRange.size(); offset += _colRange.start*elemSize(); - flags |= SUBMATRIX_FLAG; + flags |= static_cast(SUBMATRIX_FLAG); } updateContinuityFlag(); @@ -546,7 +546,7 @@ UMat::UMat(const UMat& m, const Rect& roi) if( u ) CV_XADD(&(u->urefcount), 1); if( roi.width < m.cols || roi.height < m.rows ) - flags |= SUBMATRIX_FLAG; + flags |= static_cast(SUBMATRIX_FLAG); step[0] = m.step[0]; step[1] = esz; updateContinuityFlag(); @@ -560,7 +560,7 @@ UMat::UMat(const UMat& m, const Rect& roi) UMat::UMat(const UMat& m, const Range* ranges) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows) { int i, d = m.dims; @@ -578,14 +578,14 @@ UMat::UMat(const UMat& m, const Range* ranges) { size.p[i] = r.end - r.start; offset += r.start*step.p[i]; - flags |= SUBMATRIX_FLAG; + flags |= static_cast(SUBMATRIX_FLAG); } } updateContinuityFlag(); } UMat::UMat(const UMat& m, const std::vector& ranges) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows) { int i, d = m.dims; @@ -603,7 +603,7 @@ UMat::UMat(const UMat& m, const std::vector& ranges) { size.p[i] = r.end - r.start; offset += r.start*step.p[i]; - flags |= SUBMATRIX_FLAG; + flags |= static_cast(SUBMATRIX_FLAG); } } updateContinuityFlag(); @@ -635,7 +635,7 @@ UMat UMat::diag(int d) const m.updateContinuityFlag(); if( size() != Size(1,1) ) - m.flags |= SUBMATRIX_FLAG; + m.flags |= static_cast(SUBMATRIX_FLAG); return m; } @@ -751,9 +751,9 @@ UMat UMat::diag(const UMat& d) return m; } -int UMat::checkVector(int _elemChannels, int _depth, bool _requireContinuous) const +int UMat::checkVector(int _elemChannels, ElemType _depth, bool _requireContinuous) const { - return (depth() == _depth || _depth <= 0) && + return (depth() == _depth || _depth <= CV_8U) && (isContinuous() || !_requireContinuous) && ((dims == 2 && (((rows == 1 || cols == 1) && channels() == _elemChannels) || (cols == _elemChannels && channels() == 1))) || @@ -882,7 +882,7 @@ void UMat::copyTo(OutputArray _dst) const } #endif - int dtype = _dst.type(); + ElemType dtype = _dst.type(); if( _dst.fixedType() && dtype != type() ) { CV_Assert( channels() == CV_MAT_CN(dtype) ); @@ -934,7 +934,10 @@ void UMat::copyTo(OutputArray _dst, InputArray _mask) const return; } #ifdef HAVE_OPENCL - int cn = channels(), mtype = _mask.type(), mdepth = CV_MAT_DEPTH(mtype), mcn = CV_MAT_CN(mtype); + int cn = channels(); + ElemType mtype = _mask.type(); + ElemType mdepth = CV_MAT_DEPTH(mtype); + int mcn = CV_MAT_CN(mtype); CV_Assert( mdepth == CV_8U && (mcn == 1 || mcn == cn) ); if (ocl::useOpenCL() && _dst.isUMat() && dims <= 2) @@ -973,31 +976,32 @@ void UMat::copyTo(OutputArray _dst, InputArray _mask) const src.copyTo(_dst, _mask); } -void UMat::convertTo(OutputArray _dst, int _type, double alpha, double beta) const +void UMat::convertTo(OutputArray _dst, ElemType ddepth, double alpha, double beta) const { CV_INSTRUMENT_REGION(); bool noScale = std::fabs(alpha - 1) < DBL_EPSILON && std::fabs(beta) < DBL_EPSILON; - int stype = type(), cn = CV_MAT_CN(stype); + ElemType stype = type(); - if( _type < 0 ) - _type = _dst.fixedType() ? _dst.type() : stype; - else - _type = CV_MAKETYPE(CV_MAT_DEPTH(_type), cn); + if (ddepth == CV_TYPE_AUTO) + ddepth = _dst.fixedType() ? _dst.depth() : depth(); + ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ - int sdepth = CV_MAT_DEPTH(stype), ddepth = CV_MAT_DEPTH(_type); + ElemType sdepth = CV_MAT_DEPTH(stype); if( sdepth == ddepth && noScale ) { copyTo(_dst); return; } #ifdef HAVE_OPENCL + int cn = CV_MAT_CN(stype); bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; bool needDouble = sdepth == CV_64F || ddepth == CV_64F; if( dims <= 2 && cn && _dst.isUMat() && ocl::useOpenCL() && ((needDouble && doubleSupport) || !needDouble) ) { - int wdepth = std::max(CV_32F, sdepth), rowsPerWI = 4; + ElemType wdepth = CV_MAX_DEPTH(CV_32F, sdepth); + int rowsPerWI = 4; char cvt[2][40]; ocl::Kernel k("convertTo", ocl::core::convert_oclsrc, @@ -1009,7 +1013,7 @@ void UMat::convertTo(OutputArray _dst, int _type, double alpha, double beta) con if (!k.empty()) { UMat src = *this; - _dst.create( size(), _type ); + _dst.create(size(), CV_MAKETYPE(ddepth, cn)); UMat dst = _dst.getUMat(); float alphaf = (float)alpha, betaf = (float)beta; @@ -1035,7 +1039,7 @@ void UMat::convertTo(OutputArray _dst, int _type, double alpha, double beta) con UMat src = *this; // Fake reference to itself. // Resolves issue 8693 in case of src == dst. Mat m = getMat(ACCESS_READ); - m.convertTo(_dst, _type, alpha, beta); + m.convertTo(_dst, ddepth, alpha, beta); } UMat& UMat::setTo(InputArray _value, InputArray _mask) @@ -1044,7 +1048,9 @@ UMat& UMat::setTo(InputArray _value, InputArray _mask) bool haveMask = !_mask.empty(); #ifdef HAVE_OPENCL - int tp = type(), cn = CV_MAT_CN(tp), d = CV_MAT_DEPTH(tp); + ElemType tp = type(); + int cn = CV_MAT_CN(tp); + ElemType d = CV_MAT_DEPTH(tp); if( dims <= 2 && cn <= 4 && CV_MAT_DEPTH(tp) < CV_64F && ocl::useOpenCL() ) { @@ -1130,8 +1136,9 @@ static bool ocl_dot( InputArray _src1, InputArray _src2, double & res ) { UMat src1 = _src1.getUMat().reshape(1), src2 = _src2.getUMat().reshape(1); - int type = src1.type(), depth = CV_MAT_DEPTH(type), - kercn = ocl::predictOptimalVectorWidth(src1, src2); + ElemType type = src1.type(); + ElemType depth = CV_MAT_DEPTH(type); + int kercn = ocl::predictOptimalVectorWidth(src1, src2); bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; if ( !doubleSupport && depth == CV_64F ) @@ -1139,7 +1146,7 @@ static bool ocl_dot( InputArray _src1, InputArray _src2, double & res ) int dbsize = ocl::Device::getDefault().maxComputeUnits(); size_t wgs = ocl::Device::getDefault().maxWorkGroupSize(); - int ddepth = std::max(CV_32F, depth); + ElemType ddepth = CV_MAX_DEPTH(CV_32F, depth); int wgs2_aligned = 1; while (wgs2_aligned < (int)wgs) @@ -1192,42 +1199,42 @@ double UMat::dot(InputArray m) const return getMat(ACCESS_READ).dot(m); } -UMat UMat::zeros(int rows, int cols, int type) +UMat UMat::zeros(int rows, int cols, ElemType type) { return UMat(rows, cols, type, Scalar::all(0)); } -UMat UMat::zeros(Size size, int type) +UMat UMat::zeros(Size size, ElemType type) { return UMat(size, type, Scalar::all(0)); } -UMat UMat::zeros(int ndims, const int* sz, int type) +UMat UMat::zeros(int ndims, const int* sz, ElemType type) { return UMat(ndims, sz, type, Scalar::all(0)); } -UMat UMat::ones(int rows, int cols, int type) +UMat UMat::ones(int rows, int cols, ElemType type) { return UMat::ones(Size(cols, rows), type); } -UMat UMat::ones(Size size, int type) +UMat UMat::ones(Size size, ElemType type) { return UMat(size, type, Scalar(1)); } -UMat UMat::ones(int ndims, const int* sz, int type) +UMat UMat::ones(int ndims, const int* sz, ElemType type) { return UMat(ndims, sz, type, Scalar(1)); } -UMat UMat::eye(int rows, int cols, int type) +UMat UMat::eye(int rows, int cols, ElemType type) { return UMat::eye(Size(cols, rows), type); } -UMat UMat::eye(Size size, int type) +UMat UMat::eye(Size size, ElemType type) { UMat m(size, type); setIdentity(m); diff --git a/modules/core/src/va_intel.cpp b/modules/core/src/va_intel.cpp index ac74f0c5337d..15bed6afbe53 100644 --- a/modules/core/src/va_intel.cpp +++ b/modules/core/src/va_intel.cpp @@ -489,7 +489,7 @@ void convertToVASurface(VADisplay display, InputArray src, VASurfaceID surface, #if !defined(HAVE_VA) NO_VA_SUPPORT_ERROR; #else // !HAVE_VA - const int stype = CV_8UC3; + const ElemType stype = CV_8UC3; int srcType = src.type(); CV_Assert(srcType == stype); @@ -593,7 +593,7 @@ void convertFromVASurface(VADisplay display, VASurfaceID surface, Size size, Out #if !defined(HAVE_VA) NO_VA_SUPPORT_ERROR; #else // !HAVE_VA - const int dtype = CV_8UC3; + const ElemType dtype = CV_8UC3; // TODO Need to specify ACCESS_WRITE here somehow to prevent useless data copying! dst.create(size, dtype); diff --git a/modules/core/test/test_countnonzero.cpp b/modules/core/test/test_countnonzero.cpp index f75deb01db42..ac04440cb2d6 100644 --- a/modules/core/test/test_countnonzero.cpp +++ b/modules/core/test/test_countnonzero.cpp @@ -82,7 +82,7 @@ CV_CountNonZeroTest::~CV_CountNonZeroTest() {} void CV_CountNonZeroTest::generate_src_data(cv::Size size, int type) { - src.create(size, CV_MAKETYPE(type, 1)); + src.create(size, type); for (int j = 0; j < size.width; ++j) for (int i = 0; i < size.height; ++i) @@ -101,7 +101,7 @@ void CV_CountNonZeroTest::generate_src_data(cv::Size size, int type) void CV_CountNonZeroTest::generate_src_data(cv::Size size, int type, int count_non_zero) { - src = Mat::zeros(size, CV_MAKETYPE(type, 1)); + src = Mat::zeros(size, type); int n = 0; RNG& rng = ts->get_rng(); @@ -127,7 +127,7 @@ void CV_CountNonZeroTest::generate_src_data(cv::Size size, int type, int count_n void CV_CountNonZeroTest::generate_src_stat_data(cv::Size size, int type, int distribution) { - src.create(size, CV_MAKETYPE(type, 1)); + src.create(size, type); double mean = 0.0, sigma = 1.0; double left = -1.0, right = 1.0; @@ -261,7 +261,7 @@ TEST_P (CountNonZeroND, ndim) vector sizes(dims); fill(sizes.begin(), sizes.end(), ONE_SIZE); - Mat data(sizes, CV_MAKETYPE(type, 1)); + Mat data(sizes, type); data = 0; EXPECT_EQ(0, cv::countNonZero(data)); data = Scalar::all(1); diff --git a/modules/java/generator/gen_java.py b/modules/java/generator/gen_java.py index c2f6e8514c5b..69bf63bcf5c5 100755 --- a/modules/java/generator/gen_java.py +++ b/modules/java/generator/gen_java.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python import sys, re, os.path, errno, fnmatch import json From 9d1377c2e5205d8bdf7387af406d895999ee3ee4 Mon Sep 17 00:00:00 2001 From: Hamdi Sahloul Date: Wed, 12 Sep 2018 23:23:20 +0900 Subject: [PATCH 02/10] objdetect: int to MagicFlag casting --- modules/objdetect/src/cascadedetect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/objdetect/src/cascadedetect.cpp b/modules/objdetect/src/cascadedetect.cpp index 213cfe9f3733..124bfdce3236 100644 --- a/modules/objdetect/src/cascadedetect.cpp +++ b/modules/objdetect/src/cascadedetect.cpp @@ -644,7 +644,7 @@ void HaarEvaluator::computeChannels(int scaleIdx, InputArray img) int sqy = sy + (sqofs / sbufSize.width); UMat sum(usbuf, Rect(sx, sy, s.szi.width, s.szi.height)); UMat sqsum(usbuf, Rect(sx, sqy, s.szi.width, s.szi.height)); - sqsum.flags = (sqsum.flags & ~UMat::DEPTH_MASK) | CV_32S; + sqsum.flags = (sqsum.flags & static_cast(~UMat::DEPTH_MASK)) | CV_32SC1; if (hasTiltedFeatures) { From 5efa116c659ca3d298cc5e6af877d523b986d03c Mon Sep 17 00:00:00 2001 From: Hamdi Sahloul Date: Wed, 12 Sep 2018 22:27:24 +0900 Subject: [PATCH 03/10] Refactor Python module --- modules/python/src2/cv2.cpp | 22 ++++++++++++---------- modules/python/src2/gen2.py | 2 +- modules/python/test/tst_scene_render.py | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index 5ae963a94fca..9905c95b744f 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -239,7 +239,7 @@ class NumpyAllocator : public MatAllocator NumpyAllocator() { stdAllocator = Mat::getStdAllocator(); } ~NumpyAllocator() {} - UMatData* allocate(PyObject* o, int dims, const int* sizes, int type, size_t* step) const + UMatData* allocate(PyObject* o, int dims, const int* sizes, ElemType type, size_t* step) const { UMatData* u = new UMatData(this); u->data = u->origdata = (uchar*)PyArray_DATA((PyArrayObject*) o); @@ -252,7 +252,7 @@ class NumpyAllocator : public MatAllocator return u; } - UMatData* allocate(int dims0, const int* sizes, int type, void* data, size_t* step, AccessFlag flags, UMatUsageFlags usageFlags) const CV_OVERRIDE + UMatData* allocate(int dims0, const int* sizes, ElemType type, void* data, size_t* step, AccessFlag flags, UMatUsageFlags usageFlags) const CV_OVERRIDE { if( data != 0 ) { @@ -262,7 +262,7 @@ class NumpyAllocator : public MatAllocator } PyEnsureGIL gil; - int depth = CV_MAT_DEPTH(type); + ElemType depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type); const int f = (int)(sizeof(size_t)/8); int typenum = depth == CV_8U ? NPY_UBYTE : depth == CV_8S ? NPY_BYTE : @@ -363,16 +363,16 @@ static bool pyopencv_to(PyObject* o, Mat& m, const ArgInfo info) bool needcopy = false, needcast = false; int typenum = PyArray_TYPE(oarr), new_typenum = typenum; - int type = typenum == NPY_UBYTE ? CV_8U : + ElemType type = typenum == NPY_UBYTE ? CV_8U : typenum == NPY_BYTE ? CV_8S : typenum == NPY_USHORT ? CV_16U : typenum == NPY_SHORT ? CV_16S : typenum == NPY_INT ? CV_32S : typenum == NPY_INT32 ? CV_32S : typenum == NPY_FLOAT ? CV_32F : - typenum == NPY_DOUBLE ? CV_64F : -1; + typenum == NPY_DOUBLE ? CV_64F : CV_TYPE_AUTO; - if( type < 0 ) + if( type == CV_TYPE_AUTO ) { if( typenum == NPY_INT64 || typenum == NPY_UINT64 || typenum == NPY_LONG ) { @@ -1148,8 +1148,9 @@ template struct pyopencvVecConverter int i, j, n = (int)PySequence_Fast_GET_SIZE(seq); value.resize(n); - int type = traits::Type<_Tp>::value; - int depth = CV_MAT_DEPTH(type), channels = CV_MAT_CN(type); + ElemType type = traits::Type<_Tp>::value; + ElemType depth = CV_MAT_DEPTH(type); + int channels = CV_MAT_CN(type); PyObject** items = PySequence_Fast_ITEMS(seq); for( i = 0; i < n; i++ ) @@ -1232,8 +1233,9 @@ template struct pyopencvVecConverter if(value.empty()) return PyTuple_New(0); int type = traits::Type<_Tp>::value; - int depth = CV_MAT_DEPTH(type), channels = CV_MAT_CN(type); - Mat src((int)value.size(), channels, depth, (uchar*)&value[0]); + ElemType depth = CV_MAT_DEPTH(type); + int channels = CV_MAT_CN(type); + Mat src((int)value.size(), channels, CV_MAKETYPE(depth, 1), (uchar*)&value[0]); return pyopencv_from(src); } }; diff --git a/modules/python/src2/gen2.py b/modules/python/src2/gen2.py index 9830d9637ce0..c7f5171a32bf 100755 --- a/modules/python/src2/gen2.py +++ b/modules/python/src2/gen2.py @@ -863,7 +863,7 @@ def clear(self): self.classes = {} self.namespaces = {} self.consts = {} - self.enumTypes = [] + self.enumTypes = ["ElemType", ] self.code_include = StringIO() self.code_types = StringIO() self.code_funcs = StringIO() diff --git a/modules/python/test/tst_scene_render.py b/modules/python/test/tst_scene_render.py index 2dd6309ce1a3..4610b417818d 100644 --- a/modules/python/test/tst_scene_render.py +++ b/modules/python/test/tst_scene_render.py @@ -95,7 +95,7 @@ def getNextFrame(self): if self.noise: noise = np.zeros(self.sceneBg.shape, np.int8) cv.randn(noise, np.zeros(3), np.ones(3)*255*self.noise) - img = cv.add(img, noise, dtype=cv.CV_8UC3) + img = cv.add(img, noise, ddepth=cv.CV_8U) return img def resetTime(self): From 4daee184bfcd49c06ab518d4a67c23705bad1fcc Mon Sep 17 00:00:00 2001 From: Hamdi Sahloul Date: Wed, 12 Sep 2018 22:38:07 +0900 Subject: [PATCH 04/10] Refactor Java module --- modules/java/generator/gen_java.py | 11 ++--- modules/java/generator/src/cpp/Mat.cpp | 60 ++++++++++++++------------ 2 files changed, 39 insertions(+), 32 deletions(-) diff --git a/modules/java/generator/gen_java.py b/modules/java/generator/gen_java.py index 69bf63bcf5c5..0dbd4a5c0784 100755 --- a/modules/java/generator/gen_java.py +++ b/modules/java/generator/gen_java.py @@ -64,7 +64,8 @@ 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" }, } # Defines a rule to add extra prefixes for names from specific namespaces. @@ -562,7 +563,7 @@ def gen_func(self, ci, fi, prop_name=''): cpp_code = ci.cpp_code # c_decl - # e.g: void add(Mat src1, Mat src2, Mat dst, Mat mask = Mat(), int dtype = -1) + # e.g: void add(Mat src1, Mat src2, Mat dst, Mat mask = Mat(), ElemType ddepth = CV_TYPE_AUTO) if prop_name: c_decl = "%s %s::%s" % (fi.ctype, fi.classname, prop_name) else: @@ -720,7 +721,7 @@ def gen_func(self, ci, fi, prop_name=''): # java part: # private java NATIVE method decl # e.g. - # private static native void add_0(long src1, long src2, long dst, long mask, int dtype); + # private static native void add_0(long src1, long src2, long dst, long mask, ElemType ddepth); jn_code.write( Template(\ " private static native $type $name($args);\n").substitute(\ type = type_dict[fi.ctype].get("jn_type", "double[]"), \ @@ -746,8 +747,8 @@ def gen_func(self, ci, fi, prop_name=''): # public java wrapper method impl (calling native one above) # e.g. - # public static void add( Mat src1, Mat src2, Mat dst, Mat mask, int dtype ) - # { add_0( src1.nativeObj, src2.nativeObj, dst.nativeObj, mask.nativeObj, dtype ); } + # public static void add( Mat src1, Mat src2, Mat dst, Mat mask, ElemType ddepth ) + # { add_0( src1.nativeObj, src2.nativeObj, dst.nativeObj, mask.nativeObj, ddepth ); } ret_type = fi.ctype if fi.ctype.endswith('*'): ret_type = ret_type[:-1] diff --git a/modules/java/generator/src/cpp/Mat.cpp b/modules/java/generator/src/cpp/Mat.cpp index db9f1936da4b..e8fb351e96b0 100644 --- a/modules/java/generator/src/cpp/Mat.cpp +++ b/modules/java/generator/src/cpp/Mat.cpp @@ -65,7 +65,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__IIILjava_nio_ByteBuffer static const char method_name[] = "Mat::n_1Mat__IIILByteBuffer()"; try { LOGD("%s", method_name); - return (jlong) new Mat( rows, cols, type, (void*)env->GetDirectBufferAddress(data) ); + return (jlong) new Mat( rows, cols, static_cast(type), (void*)env->GetDirectBufferAddress(data) ); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -90,7 +90,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__III static const char method_name[] = "Mat::n_1Mat__III()"; try { LOGD("%s", method_name); - return (jlong) new Mat( rows, cols, type ); + return (jlong) new Mat(rows, cols, static_cast(type)); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -116,7 +116,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__DDI try { LOGD("%s", method_name); Size size((int)size_width, (int)size_height); - return (jlong) new Mat( size, type ); + return (jlong) new Mat(size, static_cast(type)); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -143,7 +143,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__IIIDDDD try { LOGD("%s", method_name); Scalar s(s_val0, s_val1, s_val2, s_val3); - return (jlong) new Mat( rows, cols, type, s ); + return (jlong) new Mat(rows, cols, static_cast(type), s); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -170,7 +170,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__DDIDDDD LOGD("%s", method_name); Size size((int)size_width, (int)size_height); Scalar s(s_val0, s_val1, s_val2, s_val3); - return (jlong) new Mat( size, type, s ); + return (jlong) new Mat( size, static_cast(type), s ); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -258,20 +258,20 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1adjustROI // -// void Mat::assignTo(Mat m, int type = -1) +// void Mat::assignTo(Mat m, ElemType depth = CV_TYPE_AUTO) // JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1assignTo__JJI (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint type); JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1assignTo__JJI - (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint type) + (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint depth) { static const char method_name[] = "Mat::n_1assignTo__JJI()"; try { LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL - me->assignTo( (*(Mat*)m_nativeObj), type ); + me->assignTo((*(Mat*)m_nativeObj), static_cast(depth)); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -327,7 +327,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1channels // -// int Mat::checkVector(int elemChannels, int depth = -1, bool requireContinuous = true) +// int Mat::checkVector(int elemChannels, ElemType depth = -1, bool requireContinuous = true) // JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JIIZ @@ -340,7 +340,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JIIZ try { LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL - return me->checkVector( elemChannels, depth, requireContinuous ); + return me->checkVector(elemChannels, static_cast(depth), requireContinuous); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -362,7 +362,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JII try { LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL - return me->checkVector( elemChannels, depth ); + return me->checkVector(elemChannels, static_cast(depth)); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -531,21 +531,21 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1cols // -// void Mat::convertTo(Mat& m, int rtype, double alpha = 1, double beta = 0) +// void Mat::convertTo(Mat& m, ElemType ddepth, double alpha = 1, double beta = 0) // JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJIDD (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint rtype, jdouble alpha, jdouble beta); JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJIDD - (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint rtype, jdouble alpha, jdouble beta) + (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint depth, jdouble alpha, jdouble beta) { static const char method_name[] = "Mat::n_1convertTo__JJIDD()"; try { LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); - me->convertTo( m, rtype, alpha, beta ); + me->convertTo(m, static_cast(depth), alpha, beta); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -558,14 +558,14 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJID (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint rtype, jdouble alpha); JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJID - (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint rtype, jdouble alpha) + (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint rdepth, jdouble alpha) { static const char method_name[] = "Mat::n_1convertTo__JJID()"; try { LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); - me->convertTo( m, rtype, alpha ); + me->convertTo(m, static_cast(rdepth), alpha); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -585,7 +585,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJI LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); - me->convertTo( m, rtype ); + me->convertTo( m, static_cast(rtype) ); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -660,7 +660,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1create__JIII try { LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL - me->create( rows, cols, type ); + me->create(rows, cols, static_cast(type)); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -685,7 +685,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1create__JDDI LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Size size((int)size_width, (int)size_height); - me->create( size, type ); + me->create(size, static_cast(type)); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -938,7 +938,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1eye__III static const char method_name[] = "Mat::n_1eye__III()"; try { LOGD("%s", method_name); - Mat _retval_ = Mat::eye( rows, cols, type ); + Mat _retval_ = Mat::eye(rows, cols, static_cast(type)); return (jlong) new Mat(_retval_); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); @@ -965,7 +965,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1eye__DDI try { LOGD("%s", method_name); Size size((int)size_width, (int)size_height); - Mat _retval_ = Mat::eye( size, type ); + Mat _retval_ = Mat::eye(size, static_cast(type)); return (jlong) new Mat(_retval_); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); @@ -1171,7 +1171,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1ones__III static const char method_name[] = "Mat::n_1ones__III()"; try { LOGD("%s", method_name); - Mat _retval_ = Mat::ones( rows, cols, type ); + Mat _retval_ = Mat::ones(rows, cols, static_cast(type)); return (jlong) new Mat(_retval_); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); @@ -1198,7 +1198,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1ones__DDI try { LOGD("%s", method_name); Size size((int)size_width, (int)size_height); - Mat _retval_ = Mat::ones( size, type ); + Mat _retval_ = Mat::ones(size, static_cast(type)); return (jlong) new Mat(_retval_); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); @@ -1724,7 +1724,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1zeros__III static const char method_name[] = "Mat::n_1zeros__III()"; try { LOGD("%s", method_name); - Mat _retval_ = Mat::zeros( rows, cols, type ); + Mat _retval_ = Mat::zeros(rows, cols, static_cast(type)); return (jlong) new Mat(_retval_); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); @@ -1751,7 +1751,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1zeros__DDI try { LOGD("%s", method_name); Size size((int)size_width, (int)size_height); - Mat _retval_ = Mat::zeros( size, type ); + Mat _retval_ = Mat::zeros(size, static_cast(type)); return (jlong) new Mat(_retval_); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); @@ -1840,7 +1840,7 @@ template static jint java_mat_put(JNIEnv* env, jlong self, jint row LOGD("%s", method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind - if(me->depth() != JavaOpenCVTrait::cvtype_1 && me->depth() != JavaOpenCVTrait::cvtype_2) return 0; // incompatible type + if(static_cast(me->depth()) != JavaOpenCVTrait::cvtype_1 && static_cast(me->depth()) != JavaOpenCVTrait::cvtype_2) return 0; // incompatible type if(me->rows<=row || me->cols<=col) return 0; // indexes out of range char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0); @@ -1935,6 +1935,8 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutD case CV_32S: PUT_ITEM(int, row, c); break; case CV_32F: PUT_ITEM(float, row, c); break; case CV_64F: PUT_ITEM(double, row, c); break; + default: + break; //unhandled } } @@ -1949,6 +1951,8 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutD case CV_32S: PUT_ITEM(int, r, c); break; case CV_32F: PUT_ITEM(float, r, c); break; case CV_64F: PUT_ITEM(double, r, c); break; + default: + break; //unhandled } } @@ -2001,7 +2005,7 @@ template static jint java_mat_get(JNIEnv* env, jlong self, jint row LOGD("%s", method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind - if(me->depth() != JavaOpenCVTrait::cvtype_1 && me->depth() != JavaOpenCVTrait::cvtype_2) return 0; // incompatible type + if(static_cast(me->depth()) != JavaOpenCVTrait::cvtype_1 && static_cast(me->depth()) != JavaOpenCVTrait::cvtype_2) return 0; // incompatible type if(me->rows<=row || me->cols<=col) return 0; // indexes out of range char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0); @@ -2089,6 +2093,8 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_nGet case CV_32S: for(i=0; ichannels(); i++) buff[i] = *((int*) me->ptr(row, col) + i); break; case CV_32F: for(i=0; ichannels(); i++) buff[i] = *((float*) me->ptr(row, col) + i); break; case CV_64F: for(i=0; ichannels(); i++) buff[i] = *((double*) me->ptr(row, col) + i); break; + default: + break; //unhandled } env->SetDoubleArrayRegion(res, 0, me->channels(), buff); } From fd05b7865bed4e50291ae62be770e58dd3683cac Mon Sep 17 00:00:00 2001 From: Hamdi Sahloul Date: Thu, 13 Sep 2018 15:21:35 +0900 Subject: [PATCH 05/10] Refactor JS module --- modules/js/src/core_bindings.cpp | 70 ++++++++++++++++---------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/modules/js/src/core_bindings.cpp b/modules/js/src/core_bindings.cpp index e8f0ee7f856a..5f8d9aa91f0f 100644 --- a/modules/js/src/core_bindings.cpp +++ b/modules/js/src/core_bindings.cpp @@ -97,7 +97,7 @@ namespace binding_utils return emscripten::val(emscripten::memory_view(mat.step1(1), mat.ptr(i,j))); } - cv::Mat* createMat(int rows, int cols, int type, intptr_t data, size_t step) + cv::Mat* createMat(int rows, int cols, ElemType type, intptr_t data, size_t step) { return new cv::Mat(rows, cols, type, reinterpret_cast(data), step); } @@ -120,29 +120,29 @@ namespace binding_utils return step; } - static Mat matEye(int rows, int cols, int type) + static Mat matEye(int rows, int cols, ElemType type) { return Mat(cv::Mat::eye(rows, cols, type)); } - static Mat matEye(Size size, int type) + static Mat matEye(Size size, ElemType type) { return Mat(cv::Mat::eye(size, type)); } - void convertTo(const Mat& obj, Mat& m, int rtype, double alpha, double beta) + void convertTo(const Mat& obj, Mat& m, ElemType ddepth, double alpha, double beta) { - obj.convertTo(m, rtype, alpha, beta); + obj.convertTo(m, ddepth, alpha, beta); } - void convertTo(const Mat& obj, Mat& m, int rtype) + void convertTo(const Mat& obj, Mat& m, ElemType ddepth) { - obj.convertTo(m, rtype); + obj.convertTo(m, ddepth); } - void convertTo(const Mat& obj, Mat& m, int rtype, double alpha) + void convertTo(const Mat& obj, Mat& m, ElemType ddepth, double alpha) { - obj.convertTo(m, rtype, alpha); + obj.convertTo(m, ddepth, alpha); } Size matSize(const cv::Mat& mat) @@ -150,24 +150,24 @@ namespace binding_utils return mat.size(); } - cv::Mat matZeros(int arg0, int arg1, int arg2) + cv::Mat matZeros(int cols, int rows, ElemType type) { - return cv::Mat::zeros(arg0, arg1, arg2); + return cv::Mat::zeros(cols, rows, type); } - cv::Mat matZeros(cv::Size arg0, int arg1) + cv::Mat matZeros(cv::Size size, ElemType type) { - return cv::Mat::zeros(arg0,arg1); + return cv::Mat::zeros(size, type); } - cv::Mat matOnes(int arg0, int arg1, int arg2) + cv::Mat matOnes(int cols, int rows, ElemType type) { - return cv::Mat::ones(arg0, arg1, arg2); + return cv::Mat::ones(cols, rows, type); } - cv::Mat matOnes(cv::Size arg0, int arg1) + cv::Mat matOnes(cv::Size size, ElemType type) { - return cv::Mat::ones(arg0, arg1); + return cv::Mat::ones(size, type); } double matDot(const cv::Mat& obj, const Mat& mat) @@ -185,9 +185,9 @@ namespace binding_utils return Mat(obj.t()); } - Mat matInv(const cv::Mat& obj, int type) + Mat matInv(const cv::Mat& obj, int method) { - return Mat(obj.inv(type)); + return Mat(obj.inv(method)); } void matCopyTo(const cv::Mat& obj, cv::Mat& mat) @@ -331,17 +331,17 @@ EMSCRIPTEN_BINDINGS(binding_utils) emscripten::class_("Mat") .constructor<>() .constructor() - .constructor() - .constructor() - .constructor() + .constructor() + .constructor() + .constructor() .constructor(&binding_utils::createMat, allow_raw_pointers()) - .class_function("eye", select_overload(&binding_utils::matEye)) - .class_function("eye", select_overload(&binding_utils::matEye)) - .class_function("ones", select_overload(&binding_utils::matOnes)) - .class_function("ones", select_overload(&binding_utils::matOnes)) - .class_function("zeros", select_overload(&binding_utils::matZeros)) - .class_function("zeros", select_overload(&binding_utils::matZeros)) + .class_function("eye", select_overload(&binding_utils::matEye)) + .class_function("eye", select_overload(&binding_utils::matEye)) + .class_function("ones", select_overload(&binding_utils::matOnes)) + .class_function("ones", select_overload(&binding_utils::matOnes)) + .class_function("zeros", select_overload(&binding_utils::matZeros)) + .class_function("zeros", select_overload(&binding_utils::matZeros)) .property("rows", &cv::Mat::rows) .property("cols", &cv::Mat::cols) @@ -358,24 +358,24 @@ EMSCRIPTEN_BINDINGS(binding_utils) .function("elemSize", select_overload(&cv::Mat::elemSize)) .function("elemSize1", select_overload(&cv::Mat::elemSize1)) .function("channels", select_overload(&cv::Mat::channels)) - .function("convertTo", select_overload(&binding_utils::convertTo)) - .function("convertTo", select_overload(&binding_utils::convertTo)) - .function("convertTo", select_overload(&binding_utils::convertTo)) + .function("convertTo", select_overload(&binding_utils::convertTo)) + .function("convertTo", select_overload(&binding_utils::convertTo)) + .function("convertTo", select_overload(&binding_utils::convertTo)) .function("total", select_overload(&cv::Mat::total)) .function("row", select_overload(&cv::Mat::row)) - .function("create", select_overload(&cv::Mat::create)) - .function("create", select_overload(&cv::Mat::create)) + .function("create", select_overload(&cv::Mat::create)) + .function("create", select_overload(&cv::Mat::create)) .function("rowRange", select_overload(&cv::Mat::rowRange)) .function("rowRange", select_overload(&cv::Mat::rowRange)) .function("copyTo", select_overload(&binding_utils::matCopyTo)) .function("copyTo", select_overload(&binding_utils::matCopyTo)) - .function("type", select_overload(&cv::Mat::type)) + .function("type", select_overload(&cv::Mat::type)) .function("empty", select_overload(&cv::Mat::empty)) .function("colRange", select_overload(&cv::Mat::colRange)) .function("colRange", select_overload(&cv::Mat::colRange)) .function("step1", select_overload(&cv::Mat::step1)) .function("clone", select_overload(&cv::Mat::clone)) - .function("depth", select_overload(&cv::Mat::depth)) + .function("depth", select_overload(&cv::Mat::depth)) .function("col", select_overload(&cv::Mat::col)) .function("dot", select_overload(&binding_utils::matDot)) .function("mul", select_overload(&binding_utils::matMul)) From e9739d8182c9eefa5d8969a33947ab470e38fbe2 Mon Sep 17 00:00:00 2001 From: Hamdi Sahloul Date: Thu, 13 Sep 2018 13:31:06 +0900 Subject: [PATCH 06/10] Support core legacy API --- CMakeLists.txt | 2 +- modules/core/include/opencv2/core.hpp | 102 +++++ modules/core/include/opencv2/core/base.hpp | 121 ++++++ modules/core/include/opencv2/core/check.hpp | 48 +++ modules/core/include/opencv2/core/cuda.hpp | 155 +++++++ .../core/include/opencv2/core/cuda.inl.hpp | 32 ++ modules/core/include/opencv2/core/cvdef.h | 13 + modules/core/include/opencv2/core/hal/hal.hpp | 20 + .../core/include/opencv2/core/hal/interface.h | 11 + modules/core/include/opencv2/core/mat.hpp | 407 +++++++++++++++++- modules/core/include/opencv2/core/ocl.hpp | 31 ++ modules/core/include/opencv2/core/opengl.hpp | 49 +++ .../include/opencv2/core/private.cuda.hpp | 13 + modules/core/include/opencv2/core/private.hpp | 7 + modules/core/src/matrix_expressions.cpp | 43 ++ 15 files changed, 1050 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a8e88bcde643..ecef7dfb5886 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -352,7 +352,7 @@ else() endif() if(ENABLE_COMPATIBLE_API) - add_definitions(-DCV_COMPATIBLE_API) + add_definitions(-DCV_TYPE_COMPATIBLE_API) endif() if(ENABLE_IMPL_COLLECTION) diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index 443a1a29b249..48d643636583 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -342,6 +342,14 @@ output array to be changed. */ CV_EXPORTS_W void add(InputArray src1, InputArray src2, OutputArray dst, InputArray mask = noArray(), ElemType ddepth = CV_TYPE_AUTO); +#ifdef CV_TYPE_COMPATIBLE_API +CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) +static inline void add(InputArray src1, InputArray src2, OutputArray dst, + InputArray mask, int ddepth) +{ + add(src1, src2, dst, mask, static_cast(ddepth)); +} +#endif // CV_TYPE_COMPATIBLE_API /** @brief Calculates the per-element difference between two arrays or array and a scalar. @@ -382,6 +390,14 @@ of the output array to be changed. */ CV_EXPORTS_W void subtract(InputArray src1, InputArray src2, OutputArray dst, InputArray mask = noArray(), ElemType ddepth = CV_TYPE_AUTO); +#ifdef CV_TYPE_COMPATIBLE_API +CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) +static inline void subtract(InputArray src1, InputArray src2, OutputArray dst, + InputArray mask, int ddepth) +{ + subtract(src1, src2, dst, mask, static_cast(ddepth)); +} +#endif // CV_TYPE_COMPATIBLE_API /** @brief Calculates the per-element scaled product of two arrays. @@ -407,6 +423,14 @@ Mat::convertTo */ CV_EXPORTS_W void multiply(InputArray src1, InputArray src2, OutputArray dst, double scale = 1, ElemType ddepth = CV_TYPE_AUTO); +#ifdef CV_TYPE_COMPATIBLE_API +CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) +static inline void multiply(InputArray src1, InputArray src2, + OutputArray dst, double scale, int ddepth) +{ + multiply(src1, src2, dst, scale, static_cast(ddepth)); +} +#endif // CV_TYPE_COMPATIBLE_API /** @brief Performs per-element division of two arrays or a scalar by an array. @@ -430,10 +454,26 @@ case of an array-by-array division, you can only pass -1 when src1.depth()==src2 */ CV_EXPORTS_W void divide(InputArray src1, InputArray src2, OutputArray dst, double scale = 1, ElemType ddepth = CV_TYPE_AUTO); +#ifdef CV_TYPE_COMPATIBLE_API +CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) +static inline void divide(InputArray src1, InputArray src2, OutputArray dst, + double scale, int ddepth) +{ + divide(src1, src2, dst, scale, static_cast(ddepth)); +} +#endif // CV_TYPE_COMPATIBLE_API /** @overload */ CV_EXPORTS_W void divide(double scale, InputArray src2, OutputArray dst, ElemType ddepth = CV_TYPE_AUTO); +#ifdef CV_TYPE_COMPATIBLE_API +CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) +static inline void divide(double scale, InputArray src2, + OutputArray dst, int ddepth) +{ + divide(scale, src2, dst, static_cast(ddepth)); +} +#endif // CV_TYPE_COMPATIBLE_API /** @brief Calculates the sum of a scaled array and another array. @@ -483,6 +523,14 @@ can be set to CV_TYPE_AUTO, which will be equivalent to src1.depth(). */ CV_EXPORTS_W void addWeighted(InputArray src1, double alpha, InputArray src2, double beta, double gamma, OutputArray dst, ElemType ddepth = CV_TYPE_AUTO); +#ifdef CV_TYPE_COMPATIBLE_API +CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) +static inline void addWeighted(InputArray src1, double alpha, InputArray src2, + double beta, double gamma, OutputArray dst, int ddepth) +{ + addWeighted(src1, alpha, src2, beta, gamma, dst, static_cast(ddepth)); +} +#endif // CV_TYPE_COMPATIBLE_API /** @brief Scales, calculates absolute values, and converts the result to 8-bit. @@ -710,6 +758,18 @@ CV_EXPORTS_W void batchDistance(InputArray src1, InputArray src2, int normType = NORM_L2, int K = 0, InputArray mask = noArray(), int update = 0, bool crosscheck = false); +#ifdef CV_TYPE_COMPATIBLE_API +CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, dtype) +static inline void batchDistance(InputArray src1, InputArray src2, + OutputArray dist, int dtype, OutputArray nidx, + int normType = NORM_L2, int K = 0, + InputArray mask = noArray(), int update = 0, + bool crosscheck = false) +{ + batchDistance(src1, src2, dist, static_cast(dtype), nidx, normType, K, mask, update, crosscheck); +} +#endif // CV_TYPE_COMPATIBLE_API + /** @brief Normalizes the norm or value range of an array. @@ -770,6 +830,14 @@ normalization. */ CV_EXPORTS_W void normalize( InputArray src, InputOutputArray dst, double alpha = 1, double beta = 0, int norm_type = NORM_L2, ElemType ddepth = CV_TYPE_AUTO, InputArray mask = noArray()); +#ifdef CV_TYPE_COMPATIBLE_API +CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) +static inline void normalize( InputArray src, InputOutputArray dst, double alpha, double beta, + int norm_type, int ddepth, InputArray mask = noArray()) +{ + normalize(src, dst, alpha, beta, norm_type, static_cast(ddepth), mask); +} +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param src input array. @@ -865,7 +933,15 @@ a single row. 1 means that the matrix is reduced to a single column. otherwise, its type will be CV_MAKE_TYPE(ddepth, src.channels()). @sa repeat */ + CV_EXPORTS_W void reduce(InputArray src, OutputArray dst, int dim, int rtype, ElemType ddepth = CV_TYPE_AUTO); +#ifdef CV_TYPE_COMPATIBLE_API +CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) +static inline void reduce(InputArray src, OutputArray dst, int dim, int rtype, int ddepth) +{ + reduce(src, dst, dim, rtype, static_cast(ddepth)); +} +#endif // CV_TYPE_COMPATIBLE_API /** @brief Creates one multi-channel array out of several single-channel ones. @@ -1658,6 +1734,15 @@ and the output type will be CV_MAKE_TYPE(ddepth, src.channels()). CV_EXPORTS_W void mulTransposed( InputArray src, OutputArray dst, bool aTa, InputArray delta = noArray(), double scale = 1, ElemType ddepth = CV_TYPE_AUTO); +#ifdef CV_TYPE_COMPATIBLE_API +CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) +static inline void mulTransposed(InputArray src, OutputArray dst, bool aTa, + InputArray delta, + double scale, int ddepth) +{ + mulTransposed(src, dst, aTa, delta, scale, static_cast(ddepth)); +} +#endif // CV_TYPE_COMPATIBLE_API /** @brief Transposes a matrix. @@ -1946,6 +2031,14 @@ the set of input vectors. */ CV_EXPORTS void calcCovarMatrix( const Mat* samples, int nsamples, Mat& covar, Mat& mean, int flags, ElemType cdepth = CV_64F); +#ifdef CV_TYPE_COMPATIBLE_API +CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(ctype, ctype) +static inline void calcCovarMatrix(const Mat* samples, int nsamples, Mat& covar, Mat& mean, + int flags, int ctype) +{ + calcCovarMatrix(samples, nsamples, covar, mean, flags, static_cast(ctype)); +} +#endif // CV_TYPE_COMPATIBLE_API /** @overload @note use #COVAR_ROWS or #COVAR_COLS flag @@ -1957,6 +2050,15 @@ CV_EXPORTS void calcCovarMatrix( const Mat* samples, int nsamples, Mat& covar, M */ CV_EXPORTS_W void calcCovarMatrix( InputArray samples, OutputArray covar, InputOutputArray mean, int flags, ElemType cdepth = CV_64F); +#ifdef CV_TYPE_COMPATIBLE_API +CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(ctype, ctype) +static inline void calcCovarMatrix(InputArray samples, OutputArray covar, + InputOutputArray mean, int flags, int ctype) +{ + calcCovarMatrix(samples, covar, mean, flags, static_cast(ctype)); +} +#endif // CV_TYPE_COMPATIBLE_API + /** wrap PCA::operator() */ CV_EXPORTS_W void PCACompute(InputArray data, InputOutputArray mean, diff --git a/modules/core/include/opencv2/core/base.hpp b/modules/core/include/opencv2/core/base.hpp index e5770553f701..42d08b03d423 100644 --- a/modules/core/include/opencv2/core/base.hpp +++ b/modules/core/include/opencv2/core/base.hpp @@ -57,6 +57,127 @@ #include "opencv2/core/cvdef.h" #include "opencv2/core/cvstd.hpp" +#ifdef CV_TYPE_COMPATIBLE_API + +#define CV_DEPRECATED_MAX_DEPTH_DEPTH "use `CV_MAX_DEPTH(...)` instead" +#define CV_DEPRECATED_MAX_DEPTH_INT "max() between `ElemType` and `int` is deprecated" +#define CV_DEPRECATED_MIN_DEPTH_DEPTH "use `CV_MIN_DEPTH(...)` instead" +#define CV_DEPRECATED_MIN_DEPTH_INT "min() between `ElemType` and `int` is deprecated" +#define CV_DEPRECATED_ELEMTYPE_CMP_INT "comparing `ElemType` directly with `int` is deprecated. " +#define CV_DEPRECATED_PARAM(depr_type, depr_var, new_type, new_var) \ + "parameter `" CV_STR(depr_type) " " CV_STR(depr_var) "` is deprecated. " \ + "Use `" CV_STR(new_type) " " CV_STR(new_var) "` instead" + + +#ifdef OPENCV_ENABLE_DEPRECATED_WARNING_ELEMTYPE_OVERLOAD +# define CV_DEPRECATED_MAX_DEPTH_DEPTH_ATTR CV_DEPRECATED_MSG(CV_DEPRECATED_MAX_DEPTH_DEPTH) +# define CV_DEPRECATED_MIN_DEPTH_DEPTH_ATTR CV_DEPRECATED_MSG(CV_DEPRECATED_MIN_DEPTH_DEPTH) +#else +# define CV_DEPRECATED_MAX_DEPTH_DEPTH_ATTR /* nothing, default */ +# define CV_DEPRECATED_MIN_DEPTH_DEPTH_ATTR /* nothing, default */ +#endif + +#ifndef OPENCV_DISABLE_DEPRECATED_WARNING_INT_ELEMTYPE_OVERLOAD +# define CV_DEPRECATED_MAX_DEPTH_INT_ATTR CV_DEPRECATED_MSG(CV_DEPRECATED_MAX_DEPTH_INT) +# define CV_DEPRECATED_MIN_DEPTH_INT_ATTR CV_DEPRECATED_MSG(CV_DEPRECATED_MIN_DEPTH_INT) +# define CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR CV_DEPRECATED_MSG(CV_DEPRECATED_ELEMTYPE_CMP_INT) +# define CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(depr_var, new_var) CV_DEPRECATED_MSG(CV_DEPRECATED_PARAM(int, depr_var, ElemType, new_var)) +#else +# define CV_DEPRECATED_MAX_DEPTH_INT_ATTR /* nothing */ +# define CV_DEPRECATED_MIN_DEPTH_INT_ATTR /* nothing */ +# define CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR /* nothing */ +# define CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(depr_var, new_var) /* nothing */ +#endif + +namespace std +{ + CV_DEPRECATED_MAX_DEPTH_INT_ATTR static inline int max(const ElemType left, const int right) + { + return static_cast(CV_MAX_DEPTH(left, right)); + } + + CV_DEPRECATED_MAX_DEPTH_INT_ATTR static inline int max(const int left, const ElemType right) + { + return static_cast(CV_MAX_DEPTH(left, right)); + } + + CV_DEPRECATED_MAX_DEPTH_DEPTH_ATTR static inline int max(const ElemType left, const ElemType right) + { + return static_cast(CV_MAX_DEPTH(left, right)); + } + + CV_DEPRECATED_MIN_DEPTH_INT_ATTR static inline int min(const ElemType left, const int right) + { + return static_cast(CV_MIN_DEPTH(left, right)); + } + + CV_DEPRECATED_MIN_DEPTH_INT_ATTR static inline int min(const int left, const ElemType right) + { + return static_cast(CV_MIN_DEPTH(left, right)); + } + + CV_DEPRECATED_MIN_DEPTH_DEPTH_ATTR static inline int min(const ElemType left, const ElemType right) + { + return static_cast(CV_MIN_DEPTH(left, right)); + } +} + +#define CV_OPERATOR_LOGICAL_EQ(LType, RType, ATTRIBUTES) \ +ATTRIBUTES static inline bool operator==(const LType left, const RType right) \ +{ \ + return static_cast(left) == static_cast(right); \ +} \ + +#define CV_OPERATOR_LOGICAL_NOT_EQ(LType, RType, ATTRIBUTES) \ +ATTRIBUTES static inline bool operator!=(const LType left, const RType right) \ +{ \ + return static_cast(left) != static_cast(right); \ +} \ + +#define CV_OPERATOR_LE(LType, RType, ATTRIBUTES) \ +ATTRIBUTES static inline bool operator<=(const LType left, const RType right) \ +{ \ + return static_cast(left) <= static_cast(right); \ +} \ + +#define CV_OPERATOR_LT(LType, RType, ATTRIBUTES) \ +ATTRIBUTES static inline bool operator<(const LType left, const RType right) \ +{ \ + return static_cast(left) < static_cast(right); \ +} \ + +#define CV_OPERATOR_GE(LType, RType, ATTRIBUTES) \ +ATTRIBUTES static inline bool operator>=(const LType left, const RType right) \ +{ \ + return static_cast(left) >= static_cast(right); \ +} \ + +#define CV_OPERATOR_GT(LType, RType, ATTRIBUTES) \ +ATTRIBUTES static inline bool operator>(const LType left, const RType right) \ +{ \ + return static_cast(left) > static_cast(right); \ +} \ + +//CV_OPERATOR_LOGICAL_EQ(ElemType, int, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); +//CV_OPERATOR_LOGICAL_EQ(int, ElemType, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); + +//CV_OPERATOR_LOGICAL_NOT_EQ(ElemType, int, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); +//CV_OPERATOR_LOGICAL_NOT_EQ(int, ElemType, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); + +CV_OPERATOR_LE(ElemType, int, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); +CV_OPERATOR_LE(int, ElemType, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); + +CV_OPERATOR_LT(ElemType, int, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); +CV_OPERATOR_LT(int, ElemType, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); + +CV_OPERATOR_GE(ElemType, int, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); +CV_OPERATOR_GE(int, ElemType, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); + +CV_OPERATOR_GT(ElemType, int, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); +CV_OPERATOR_GT(int, ElemType, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); + +#endif // CV_TYPE_COMPATIBLE_API + namespace cv { diff --git a/modules/core/include/opencv2/core/check.hpp b/modules/core/include/opencv2/core/check.hpp index 2db6e39f1c96..9a8d495db201 100644 --- a/modules/core/include/opencv2/core/check.hpp +++ b/modules/core/include/opencv2/core/check.hpp @@ -11,9 +11,21 @@ namespace cv { /** Returns string of cv::Mat depth value: CV_8U -> "CV_8U" or "" */ CV_EXPORTS const char* depthToString(ElemType depth); +#ifdef CV_TRANSNATIONAL_API +static inline const char* depthToString(int depth) +{ + return depthToString(static_cast(depth)); +} +#endif // CV_TRANSNATIONAL_API /** Returns string of cv::Mat depth value: CV_8UC3 -> "CV_8UC3" or "" */ CV_EXPORTS const String typeToString(ElemType type); +#ifdef CV_TRANSNATIONAL_API +static inline const String typeToString(int type) +{ + return typeToString(static_cast(type)); +} +#endif // CV_TRANSNATIONAL_API //! @cond IGNORED @@ -21,9 +33,21 @@ namespace detail { /** Returns string of cv::Mat depth value: CV_8U -> "CV_8U" or NULL */ CV_EXPORTS const char* depthToString_(ElemType depth); +#ifdef CV_TRANSNATIONAL_API +static inline const char* depthToString_(int depth) +{ + return depthToString_(static_cast(depth)); +} +#endif // CV_TRANSNATIONAL_API /** Returns string of cv::Mat depth value: CV_8UC3 -> "CV_8UC3" or cv::String() */ CV_EXPORTS const cv::String typeToString_(ElemType type); +#ifdef CV_TRANSNATIONAL_API +static inline const cv::String typeToString_(int type) +{ + return typeToString_(static_cast(type)); +} +#endif // CV_TRANSNATIONAL_API enum TestOp { TEST_CUSTOM = 0, @@ -70,7 +94,19 @@ CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v1, const size_t v2, CV_EXPORTS void CV_NORETURN check_failed_auto(const float v1, const float v2, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const double v1, const double v2, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const ElemType v1, const ElemType v2, const CheckContext& ctx); +#ifdef CV_TRANSNATIONAL_API +static inline void CV_NORETURN check_failed_MatDepth(const int v1, const int v2, const CheckContext& ctx) +{ + check_failed_MatDepth(static_cast(v1), static_cast(v2), ctx); +} +#endif // CV_TRANSNATIONAL_API CV_EXPORTS void CV_NORETURN check_failed_MatType(const ElemType v1, const ElemType v2, const CheckContext& ctx); +#ifdef CV_TRANSNATIONAL_API +static inline void CV_NORETURN check_failed_MatType(const int v1, const int v2, const CheckContext& ctx) +{ + check_failed_MatType(static_cast(v1), static_cast(v2), ctx); +} +#endif // CV_TRANSNATIONAL_API CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v1, const int v2, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const int v, const CheckContext& ctx); @@ -78,7 +114,19 @@ CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v, const CheckContext CV_EXPORTS void CV_NORETURN check_failed_auto(const float v, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const double v, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const ElemType v, const CheckContext& ctx); +#ifdef CV_TRANSNATIONAL_API +static inline void CV_NORETURN check_failed_MatDepth(const int v, const CheckContext& ctx) +{ + check_failed_MatDepth(static_cast(v), ctx); +} +#endif // CV_TRANSNATIONAL_API CV_EXPORTS void CV_NORETURN check_failed_MatType(const ElemType v, const CheckContext& ctx); +#ifdef CV_TRANSNATIONAL_API +static inline void CV_NORETURN check_failed_MatType(const int v, const CheckContext& ctx) +{ + check_failed_MatType(static_cast(v), ctx); +} +#endif // CV_TRANSNATIONAL_API CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v, const CheckContext& ctx); diff --git a/modules/core/include/opencv2/core/cuda.hpp b/modules/core/include/opencv2/core/cuda.hpp index d765dba734ef..34e8a8438f9b 100644 --- a/modules/core/include/opencv2/core/cuda.hpp +++ b/modules/core/include/opencv2/core/cuda.hpp @@ -124,18 +124,60 @@ class CV_EXPORTS_W GpuMat //! constructs GpuMat of the specified size and type CV_WRAP GpuMat(int rows, int cols, ElemType type, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline GpuMat(int _rows, int _cols, int _type, GpuMat::Allocator* _allocator = GpuMat::defaultAllocator()) + : GpuMat(_rows, _cols, static_cast(_type), _allocator) + { + } +#endif // CV_TYPE_COMPATIBLE_API CV_WRAP GpuMat(Size size, ElemType type, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline GpuMat(Size _size, int _type, GpuMat::Allocator* _allocator = GpuMat::defaultAllocator()) + : GpuMat(_size, static_cast(_type), _allocator) + { + } +#endif // CV_TYPE_COMPATIBLE_API //! constucts GpuMat and fills it with the specified value _s CV_WRAP GpuMat(int rows, int cols, ElemType type, Scalar s, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline GpuMat(int _rows, int _cols, int _type, Scalar s, GpuMat::Allocator* _allocator = GpuMat::defaultAllocator()) + : GpuMat(_rows, _cols, static_cast(_type), s, _allocator) + { + } +#endif // CV_TYPE_COMPATIBLE_API CV_WRAP GpuMat(Size size, ElemType type, Scalar s, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline GpuMat(Size _size, int _type, Scalar s, GpuMat::Allocator* _allocator = GpuMat::defaultAllocator()) + : GpuMat(_size, static_cast(_type), s, _allocator) + { + } +#endif // CV_TYPE_COMPATIBLE_API //! copy constructor CV_WRAP GpuMat(const GpuMat& m); //! constructor for GpuMat headers pointing to user-allocated data CV_WRAP GpuMat(int rows, int cols, ElemType type, void* data, size_t step = Mat::AUTO_STEP); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline GpuMat(int _rows, int _cols, int _type, void* _data, size_t _step = Mat::AUTO_STEP) + : GpuMat(_rows, _cols, static_cast(_type), _data, _step) + { + } +#endif // CV_TYPE_COMPATIBLE_API CV_WRAP GpuMat(Size size, ElemType type, void* data, size_t step = Mat::AUTO_STEP); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline GpuMat(Size _size, int _type, void* _data, size_t _step = Mat::AUTO_STEP) + : GpuMat(_size, static_cast(_type), _data, _step) + { + } +#endif // CV_TYPE_COMPATIBLE_API //! creates a GpuMat header for a part of the bigger matrix CV_WRAP GpuMat(const GpuMat& m, Range rowRange, Range colRange); @@ -152,7 +194,21 @@ class CV_EXPORTS_W GpuMat //! allocates new GpuMat data unless the GpuMat already has specified size and type CV_WRAP void create(int rows, int cols, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline void create(int _rows, int _cols, int _type) + { + create(_rows, _cols, static_cast(_type)); + } +#endif // CV_TYPE_COMPATIBLE_API CV_WRAP void create(Size size, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline void create(Size _size, int _type) + { + create(_size, static_cast(_type)); + } +#endif // CV_TYPE_COMPATIBLE_API //! decreases reference counter, deallocate the data when reference counter reaches 0 void release(); @@ -223,20 +279,63 @@ class CV_EXPORTS_W GpuMat //! converts GpuMat to another datatype (Blocking call) CV_WRAP void convertTo(OutputArray dst, ElemType ddepth) const; +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) + inline void convertTo(OutputArray dst, int ddepth) const + { + convertTo(dst, static_cast(ddepth)); + } +#endif // CV_TYPE_COMPATIBLE_API //! converts GpuMat to another datatype (Non-Blocking call) CV_WRAP void convertTo(OutputArray dst, ElemType ddepth, Stream& stream) const; +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) + inline void convertTo(OutputArray dst, int ddepth, Stream& stream) const + { + convertTo(dst, static_cast(ddepth), stream); + } +#endif // CV_TYPE_COMPATIBLE_API //! converts GpuMat to another datatype with scaling (Blocking call) CV_WRAP void convertTo(OutputArray dst, ElemType ddepth, double alpha, double beta = 0.0) const; +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) + inline void convertTo(OutputArray dst, int ddepth, double alpha, double beta = 0.0) const + { + convertTo(dst, static_cast(ddepth), alpha, beta ); + } +#endif // CV_TYPE_COMPATIBLE_API //! converts GpuMat to another datatype with scaling (Non-Blocking call) CV_WRAP void convertTo(OutputArray dst, ElemType ddepth, double alpha, Stream& stream) const; +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) + inline void convertTo(OutputArray dst, int ddepth, double alpha, Stream& stream) const + { + convertTo(dst, static_cast(ddepth), alpha, stream); + } +#endif // CV_TYPE_COMPATIBLE_API //! converts GpuMat to another datatype with scaling (Non-Blocking call) CV_WRAP void convertTo(OutputArray dst, ElemType ddepth, double alpha, double beta, Stream& stream) const; +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) + inline void convertTo(OutputArray dst, int ddepth, double alpha, double beta, Stream& stream) const + { + convertTo(dst, static_cast(ddepth), alpha, beta, stream); + } +#endif // CV_TYPE_COMPATIBLE_API + CV_WRAP void assignTo(GpuMat& m, ElemType depth = CV_TYPE_AUTO) const; +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + inline void assignTo(GpuMat& m, int _depth) const + { + assignTo(m, static_cast(_depth) ); + } +#endif // CV_TYPE_COMPATIBLE_API //! returns pointer to y-th row uchar* ptr(int y = 0); @@ -349,6 +448,13 @@ Matrix is called continuous if its elements are stored continuously, that is, wi end of each row. */ CV_EXPORTS_W void createContinuous(int rows, int cols, ElemType type, OutputArray arr); +#ifdef CV_TYPE_COMPATIBLE_API +CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) +static inline void createContinuous(int _rows, int _cols, int _type, OutputArray arr) +{ + createContinuous(_rows, _cols, static_cast(_type), arr); +} +#endif // CV_TYPE_COMPATIBLE_API /** @brief Ensures that the size of a matrix is big enough and the matrix has a proper type. @@ -360,6 +466,13 @@ CV_EXPORTS_W void createContinuous(int rows, int cols, ElemType type, OutputArra The function does not reallocate memory if the matrix has proper attributes already. */ CV_EXPORTS_W void ensureSizeIsEnough(int rows, int cols, ElemType type, OutputArray arr); +#ifdef CV_TYPE_COMPATIBLE_API +CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) +static inline void ensureSizeIsEnough(int _rows, int _cols, int _type, OutputArray arr) +{ + ensureSizeIsEnough(_rows, _cols, static_cast(_type), arr); +} +#endif // CV_TYPE_COMPATIBLE_API /** @brief BufferPool for use with CUDA streams @@ -487,9 +600,23 @@ class CV_EXPORTS_W BufferPool //! Allocates a new GpuMat of given size and type. CV_WRAP GpuMat getBuffer(int rows, int cols, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline GpuMat getBuffer(int _rows, int _cols, int _type) + { + return getBuffer(_rows, _cols, static_cast(_type)); + } +#endif // CV_TYPE_COMPATIBLE_API //! Allocates a new GpuMat of given size and type. CV_WRAP GpuMat getBuffer(Size size, ElemType type) { return getBuffer(size.height, size.width, type); } +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline GpuMat getBuffer(Size _size, int _type) + { + return getBuffer(_size, static_cast(_type)); + } +#endif // CV_TYPE_COMPATIBLE_API //! Returns the allocator associated with the stream. CV_WRAP Ptr getAllocator() const { return allocator_; } @@ -533,7 +660,21 @@ class CV_EXPORTS_W HostMem HostMem(const HostMem& m); CV_WRAP HostMem(int rows, int cols, ElemType type, HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline HostMem(int _rows, int _cols, int _type, HostMem::AllocType _alloc_type = HostMem::AllocType::PAGE_LOCKED) + : HostMem(_rows, _cols, static_cast(_type), _alloc_type) + { + } +#endif // CV_TYPE_COMPATIBLE_API CV_WRAP HostMem(Size size, ElemType type, HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline HostMem(Size _size, int _type, HostMem::AllocType _alloc_type = HostMem::AllocType::PAGE_LOCKED) + : HostMem(_size, static_cast(_type), _alloc_type) + { + } +#endif // CV_TYPE_COMPATIBLE_API //! creates from host memory with coping data CV_WRAP explicit HostMem(InputArray arr, HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); @@ -550,7 +691,21 @@ class CV_EXPORTS_W HostMem //! allocates new matrix data unless the matrix already has specified size and type. CV_WRAP void create(int rows, int cols, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline void create(int _rows, int _cols, int _type) + { + create(_rows, _cols, static_cast(_type)); + } +#endif // CV_TYPE_COMPATIBLE_API void create(Size size, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline void create(Size _size, int _type) + { + create(_size, static_cast(_type)); + } +#endif // CV_TYPE_COMPATIBLE_API //! creates alternative HostMem header for the same data, with different //! number of channels and/or different number of rows diff --git a/modules/core/include/opencv2/core/cuda.inl.hpp b/modules/core/include/opencv2/core/cuda.inl.hpp index 2d614c92f418..263db8b88682 100644 --- a/modules/core/include/opencv2/core/cuda.inl.hpp +++ b/modules/core/include/opencv2/core/cuda.inl.hpp @@ -351,12 +351,28 @@ GpuMat createContinuous(int rows, int cols, ElemType type) return m; } +#ifdef CV_TRANSNATIONAL_API +static inline +GpuMat createContinuous(int rows, int cols, int type) +{ + return createContinuous(rows, cols, static_cast(type)); +} +#endif // CV_TRANSNATIONAL_API + static inline void createContinuous(Size size, ElemType type, OutputArray arr) { createContinuous(size.height, size.width, type, arr); } +#ifdef CV_TRANSNATIONAL_API +static inline +void createContinuous(Size size, int type, OutputArray arr) +{ + createContinuous(size, static_cast(type), arr); +} +#endif // CV_TRANSNATIONAL_API + static inline GpuMat createContinuous(Size size, ElemType type) { @@ -365,12 +381,28 @@ GpuMat createContinuous(Size size, ElemType type) return m; } +#ifdef CV_TRANSNATIONAL_API +static inline +GpuMat createContinuous(Size size, int type) +{ + return createContinuous(size, static_cast(type)); +} +#endif // CV_TRANSNATIONAL_API + static inline void ensureSizeIsEnough(Size size, ElemType type, OutputArray arr) { ensureSizeIsEnough(size.height, size.width, type, arr); } +#ifdef CV_TRANSNATIONAL_API +static inline +void ensureSizeIsEnough(Size size, int type, OutputArray arr) +{ + ensureSizeIsEnough(size, static_cast(type), arr); +} +#endif // CV_TRANSNATIONAL_API + static inline void swap(GpuMat& a, GpuMat& b) { diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h index 908058580df0..339d26cbf6d3 100644 --- a/modules/core/include/opencv2/core/cvdef.h +++ b/modules/core/include/opencv2/core/cvdef.h @@ -69,6 +69,9 @@ namespace cv { namespace debug_build_guard { } using namespace debug_build_guard #include "cvconfig.h" #endif +#define CV_STR_HELPER(x) #x +#define CV_STR(x) CV_STR_HELPER(x) + #ifndef __CV_EXPAND #define __CV_EXPAND(x) x #endif @@ -277,6 +280,16 @@ Cv64suf; # endif #endif +#ifndef CV_DEPRECATED_MSG +# if defined(__GNUC__) +# define CV_DEPRECATED_MSG(msg) __attribute__ ((deprecated(msg))) +# elif defined(_MSC_VER) +# define CV_DEPRECATED_MSG(msg) __declspec(deprecated(msg)) +# else +# define CV_DEPRECATED_MSG(msg) +# endif +#endif + #ifndef CV_EXTERN_C # ifdef __cplusplus # define CV_EXTERN_C extern "C" diff --git a/modules/core/include/opencv2/core/hal/hal.hpp b/modules/core/include/opencv2/core/hal/hal.hpp index 3b0e75c6d047..6abc7307332b 100644 --- a/modules/core/include/opencv2/core/hal/hal.hpp +++ b/modules/core/include/opencv2/core/hal/hal.hpp @@ -204,6 +204,12 @@ CV_EXPORTS void addRNGBias64f( double* arr, const double* scaleBiasPairs, int le struct CV_EXPORTS DFT1D { static Ptr create(int len, int count, ElemType depth, int flags, bool * useBuffer = 0); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + static inline Ptr create(int len, int count, int depth, int flags, bool * useBuffer = 0) + { return create(len, count, static_cast(depth), flags, useBuffer); + } +#endif // CV_TYPE_COMPATIBLE_API virtual void apply(const uchar *src, uchar *dst) = 0; virtual ~DFT1D() {} }; @@ -213,6 +219,14 @@ struct CV_EXPORTS DFT2D static Ptr create(int width, int height, ElemType depth, int src_channels, int dst_channels, int flags, int nonzero_rows = 0); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + static inline Ptr create(int width, int height, int depth, + int src_channels, int dst_channels, + int flags, int nonzero_rows = 0) + { return create(width, height, static_cast(depth), src_channels, dst_channels, flags, nonzero_rows); + } +#endif // CV_TYPE_COMPATIBLE_API virtual void apply(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step) = 0; virtual ~DFT2D() {} }; @@ -220,6 +234,12 @@ struct CV_EXPORTS DFT2D struct CV_EXPORTS DCT2D { static Ptr create(int width, int height, ElemType depth, int flags); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + static inline Ptr create(int width, int height, int depth, int flags) + { return create(width, height, static_cast(depth), flags); + } +#endif // CV_TYPE_COMPATIBLE_API virtual void apply(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step) = 0; virtual ~DCT2D() {} }; diff --git a/modules/core/include/opencv2/core/hal/interface.h b/modules/core/include/opencv2/core/hal/interface.h index 8525d2dfa860..db8539d59748 100644 --- a/modules/core/include/opencv2/core/hal/interface.h +++ b/modules/core/include/opencv2/core/hal/interface.h @@ -89,6 +89,17 @@ typedef signed char schar; #define CV_MAKETYPE(depth,cn) static_cast(__CV_MAKETYPE(depth,cn)) #define CV_MAKE_TYPE CV_MAKETYPE +//Define transnational API availble only when Compatible API is set +#ifdef CV_TYPE_COMPATIBLE_API +# define CV_TRANSNATIONAL_API +#endif +//TODO: Remove above block after whole library factorization + + +//#define OPENCV_ENABLE_DEPRECATED_WARNING_ELEMDEPTH_ELEMTYPE_OVERLOAD +//#define OPENCV_DISABLE_DEPRECATED_WARNING_INT_ELEMTYPE_OVERLOAD + + #if defined(CV_TYPE_SAFE_API) && defined(__cplusplus) enum MagicFlag { CV_MAGIC_FLAG_NONE = 0 diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index 521f242cde79..ef19db46c413 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -68,7 +68,7 @@ enum AccessFlag }; CV_ENUM_FLAGS(AccessFlag); __CV_ENUM_FLAGS_BITWISE_AND(AccessFlag, MagicFlag, AccessFlag); -#if defined(CV_TYPE_SAFE_API) +#ifdef CV_TYPE_SAFE_API CV_ENUM_FLAGS(MagicFlag); CV_ENUM_FLAGS(ElemType); __CV_ENUM_FLAGS_BITWISE_OR(MagicFlag, int, MagicFlag); @@ -80,7 +80,6 @@ __CV_ENUM_FLAGS_BITWISE_OR_EQ(MagicFlag, ElemType); __CV_ENUM_FLAGS_BITWISE_AND(ElemType, MagicFlag, ElemType); __CV_ENUM_FLAGS_BITWISE_AND_EQ(MagicFlag, ElemType); - __CV_ENUM_FLAGS_BITWISE_OR(MagicFlag, ElemType, AccessFlag); __CV_ENUM_FLAGS_BITWISE_OR(MagicFlag, MagicFlag, AccessFlag); #endif @@ -282,7 +281,7 @@ class CV_EXPORTS _InputArray CV_ENUM_FLAGS(_InputArray::KindFlag); __CV_ENUM_FLAGS_BITWISE_AND(_InputArray::KindFlag, MagicFlag, _InputArray::KindFlag); __CV_ENUM_FLAGS_BITWISE_OR_EQ(MagicFlag, _InputArray::KindFlag); -#if defined(CV_TYPE_SAFE_API) +#ifdef CV_TYPE_SAFE_API __CV_ENUM_FLAGS_BITWISE_OR(MagicFlag, MagicFlag, _InputArray::KindFlag); __CV_ENUM_FLAGS_BITWISE_OR(MagicFlag, _InputArray::KindFlag, ElemType); __CV_ENUM_FLAGS_BITWISE_OR(MagicFlag, _InputArray::KindFlag, AccessFlag); @@ -387,9 +386,37 @@ class CV_EXPORTS _OutputArray : public _InputArray ogl::Buffer& getOGlBufferRef() const; cuda::HostMem& getHostMemRef() const; void create(Size sz, ElemType type, int i = -1, bool allowTransposed = false, _OutputArray::DepthMask fixedDepthMask = static_cast<_OutputArray::DepthMask>(0)) const; +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline void create(Size _sz, int _type, int i = -1, bool allowTransposed = false, _OutputArray::DepthMask fixedDepthMask = static_cast<_OutputArray::DepthMask>(0)) const + { + create(_sz, static_cast(_type), i, allowTransposed, fixedDepthMask); + } +#endif // CV_TYPE_COMPATIBLE_API void create(int rows, int cols, ElemType type, int i = -1, bool allowTransposed = false, _OutputArray::DepthMask fixedDepthMask = static_cast<_OutputArray::DepthMask>(0)) const; +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline void create(int _rows, int _cols, int _type, int i = -1, bool allowTransposed = false, _OutputArray::DepthMask fixedDepthMask = static_cast<_OutputArray::DepthMask>(0)) const + { + create(_rows, _cols, static_cast(_type), i, allowTransposed, fixedDepthMask); + } +#endif // CV_TYPE_COMPATIBLE_API void create(int dims, const int* size, ElemType type, int i = -1, bool allowTransposed = false, _OutputArray::DepthMask fixedDepthMask = static_cast<_OutputArray::DepthMask>(0)) const; +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline void create(int _dims, const int* _size, int _type, int i = -1, bool allowTransposed = false, _OutputArray::DepthMask fixedDepthMask = static_cast<_OutputArray::DepthMask>(0)) const + { + create(_dims, _size, static_cast(_type), i, allowTransposed, fixedDepthMask); + } +#endif // CV_TYPE_COMPATIBLE_API void createSameSize(const _InputArray& arr, ElemType mtype) const; +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(mtype, mtype) + inline void createSameSize(const _InputArray& arr, int mtype) const + { + createSameSize(arr, static_cast(mtype)); + } +#endif // CV_TYPE_COMPATIBLE_API void release() const; void clear() const; void setTo(const _InputArray& value, const _InputArray & mask = _InputArray()) const; @@ -498,6 +525,13 @@ class CV_EXPORTS MatAllocator //virtual void deallocate(int* refcount, uchar* datastart, uchar* data) = 0; virtual UMatData* allocate(int dims, const int* sizes, ElemType type, void* data, size_t* step, AccessFlag flags, UMatUsageFlags usageFlags) const = 0; +#ifdef CV_TRANSNATIONAL_API + inline virtual UMatData* allocate(int dims, const int* _sizes, int _type, + void* _data, size_t* _step, AccessFlag flags, UMatUsageFlags _usageFlags) const + { + return allocate(dims, _sizes, static_cast(_type), _data, _step, flags, _usageFlags); + } +#endif // CV_TRANSNATIONAL_API virtual bool allocate(UMatData* data, AccessFlag accessflags, UMatUsageFlags usageFlags) const = 0; virtual void deallocate(UMatData* data) const = 0; virtual void map(UMatData* data, AccessFlag accessflags) const; @@ -836,6 +870,13 @@ class CV_EXPORTS Mat CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. */ Mat(int rows, int cols, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline Mat(int _rows, int _cols, int _type) + : Mat(_rows, _cols, static_cast(_type)) + { + } +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the @@ -844,6 +885,13 @@ class CV_EXPORTS Mat CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. */ Mat(Size size, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline Mat(Size _size, int _type) + : Mat(_size, static_cast(_type)) + { + } +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param rows Number of rows in a 2D array. @@ -855,6 +903,13 @@ class CV_EXPORTS Mat Mat::operator=(const Scalar& value) . */ Mat(int rows, int cols, ElemType type, const Scalar& s); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline Mat(int _rows, int _cols, int _type, const Scalar& s) + : Mat(_rows, _cols, static_cast(_type), s) + { + } +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the @@ -866,6 +921,13 @@ class CV_EXPORTS Mat Mat::operator=(const Scalar& value) . */ Mat(Size size, ElemType type, const Scalar& s); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline Mat(Size _size, int _type, const Scalar& s) + : Mat(_size, static_cast(_type), s) + { + } +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param ndims Array dimensionality. @@ -874,6 +936,13 @@ class CV_EXPORTS Mat CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. */ Mat(int ndims, const int* sizes, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline Mat(int ndims, const int* _sizes, int _type) + : Mat(ndims, _sizes, static_cast(_type)) + { + } +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param sizes Array of integers specifying an n-dimensional array shape. @@ -881,6 +950,13 @@ class CV_EXPORTS Mat CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. */ Mat(const std::vector& sizes, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline Mat(const std::vector& _sizes, int _type) + : Mat(_sizes, static_cast(_type)) + { + } +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param ndims Array dimensionality. @@ -892,6 +968,13 @@ class CV_EXPORTS Mat Mat::operator=(const Scalar& value) . */ Mat(int ndims, const int* sizes, ElemType type, const Scalar& s); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline Mat(int ndims, const int* _sizes, int _type, const Scalar& s) + : Mat(ndims, _sizes, static_cast(_type), s) + { + } +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param sizes Array of integers specifying an n-dimensional array shape. @@ -902,6 +985,13 @@ class CV_EXPORTS Mat Mat::operator=(const Scalar& value) . */ Mat(const std::vector& sizes, ElemType type, const Scalar& s); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline Mat(const std::vector& _sizes, int _type, const Scalar& s) + : Mat(_sizes, static_cast(_type), s) + { + } +#endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -928,6 +1018,13 @@ class CV_EXPORTS Mat and the actual step is calculated as cols*elemSize(). See Mat::elemSize. */ Mat(int rows, int cols, ElemType type, void* data, size_t step = AUTO_STEP); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline Mat(int _rows, int _cols, int _type, void* _data, size_t _step = AUTO_STEP) + : Mat(_rows, _cols, static_cast(_type), _data, _step) + { + } +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the @@ -944,6 +1041,13 @@ class CV_EXPORTS Mat and the actual step is calculated as cols*elemSize(). See Mat::elemSize. */ Mat(Size size, ElemType type, void* data, size_t step = AUTO_STEP); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline Mat(Size _size, int _type, void* _data, size_t _step = AUTO_STEP) + : Mat(_size, static_cast(_type), _data, _step) + { + } +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param ndims Array dimensionality. @@ -959,6 +1063,13 @@ class CV_EXPORTS Mat set to the element size). If not specified, the matrix is assumed to be continuous. */ Mat(int ndims, const int* sizes, ElemType type, void* data, const size_t* steps = 0); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline Mat(int ndims, const int* _sizes, int _type, void* _data, const size_t* steps = 0) + : Mat(ndims, _sizes, static_cast(_type), _data, steps) + { + } +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param sizes Array of integers specifying an n-dimensional array shape. @@ -973,6 +1084,13 @@ class CV_EXPORTS Mat set to the element size). If not specified, the matrix is assumed to be continuous. */ Mat(const std::vector& sizes, ElemType type, void* data, const size_t* steps = 0); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline Mat(const std::vector& _sizes, int _type, void* _data, const size_t* steps = 0) + : Mat(_sizes, static_cast(_type), _data, steps) + { + } +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param m Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied @@ -1255,6 +1373,13 @@ class CV_EXPORTS Mat @param beta optional delta added to the scaled values. */ void convertTo(OutputArray m, ElemType ddepth, double alpha = 1, double beta = 0) const; +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) + inline void convertTo(OutputArray m, int ddepth, double alpha = 1, double beta = 0) const + { + convertTo(m, static_cast(ddepth), alpha, beta); + } +#endif // CV_TYPE_COMPATIBLE_API /** @brief Provides a functional form of convertTo. @@ -1262,7 +1387,15 @@ class CV_EXPORTS Mat @param m Destination array. @param depth Desired destination array depth (or CV_TYPE_AUTO if it should be the same as the source type). */ + void assignTo(Mat& m, ElemType depth = CV_TYPE_AUTO) const; +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + inline void assignTo(Mat& m, int _depth) const + { + assignTo(m, static_cast(_depth)); + } +#endif // CV_TYPE_COMPATIBLE_API /** @brief Sets all or some of the array elements to the specified value. @param s Assigned scalar converted to the actual array type. @@ -1379,12 +1512,20 @@ class CV_EXPORTS Mat @param type Created matrix type. */ static MatExpr zeros(int rows, int cols, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + static MatExpr zeros(int rows, int cols, int _type); +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param size Alternative to the matrix size specification Size(cols, rows) . @param type Created matrix type. */ static MatExpr zeros(Size size, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + static MatExpr zeros(Size size, int _type); +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param ndims Array dimensionality. @@ -1392,6 +1533,10 @@ class CV_EXPORTS Mat @param type Created matrix type. */ static MatExpr zeros(int ndims, const int* sz, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + static MatExpr zeros(int ndims, const int* sz, int _type); +#endif // CV_TYPE_COMPATIBLE_API /** @brief Returns an array of all 1's of the specified size and type. @@ -1410,12 +1555,20 @@ class CV_EXPORTS Mat @param type Created matrix type. */ static MatExpr ones(int rows, int cols, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + static MatExpr ones(int rows, int cols, int _type); +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param size Alternative to the matrix size specification Size(cols, rows) . @param type Created matrix type. */ static MatExpr ones(Size size, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + static MatExpr ones(Size size, int _type); +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param ndims Array dimensionality. @@ -1423,6 +1576,10 @@ class CV_EXPORTS Mat @param type Created matrix type. */ static MatExpr ones(int ndims, const int* sz, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + static MatExpr ones(int ndims, const int* sz, int _type); +#endif // CV_TYPE_COMPATIBLE_API /** @brief Returns an identity matrix of the specified size and type. @@ -1439,12 +1596,20 @@ class CV_EXPORTS Mat @param type Created matrix type. */ static MatExpr eye(int rows, int cols, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + static MatExpr eye(int rows, int cols, int _type); +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param size Alternative matrix size specification as Size(cols, rows) . @param type Created matrix type. */ static MatExpr eye(Size size, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + static MatExpr eye(Size size, int _type); +#endif // CV_TYPE_COMPATIBLE_API /** @brief Allocates new array data if needed. @@ -1480,12 +1645,26 @@ class CV_EXPORTS Mat @param type New matrix type. */ void create(int rows, int cols, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline void create(int _rows, int _cols, int _type) + { + create(_rows, _cols, static_cast(_type)); + } +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param size Alternative new matrix size specification: Size(cols, rows) @param type New matrix type. */ void create(Size size, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline void create(Size _size, int _type) + { + create(_size, static_cast(_type)); + } +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param ndims New array dimensionality. @@ -1493,12 +1672,26 @@ class CV_EXPORTS Mat @param type New matrix type. */ void create(int ndims, const int* sizes, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline void create(int ndims, const int* _sizes, int _type) + { + create(ndims, _sizes, static_cast(_type)); + } +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param sizes Array of integers specifying a new array shape. @param type New matrix type. */ void create(const std::vector& sizes, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline void create(const std::vector& sizes, int _type) + { + create(sizes, static_cast(_type)); + } +#endif // CV_TYPE_COMPATIBLE_API /** @brief Increments the reference counter. @@ -1850,7 +2043,15 @@ class CV_EXPORTS Mat * The following code demonstrates its usage for a 3-d matrix: * @snippet snippets/core_mat_checkVector.cpp example-3d */ + int checkVector(int elemChannels, ElemType depth = CV_TYPE_AUTO, bool requireContinuous = true) const; +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + inline int checkVector(int elemChannels, int _depth, bool requireContinuous = true) const + { + return checkVector(elemChannels, static_cast(_depth), requireContinuous); + } +#endif // CV_TYPE_COMPATIBLE_API /** @brief Returns a pointer to the specified matrix row. @@ -2423,14 +2624,56 @@ class CV_EXPORTS UMat //! constructs 2D matrix of the specified size and type // (_type is CV_8UC1, CV_64FC3, CV_32SC(12) etc.) UMat(int rows, int cols, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline UMat(int _rows, int _cols, int _type, UMatUsageFlags _usageFlags = USAGE_DEFAULT) + : UMat(_rows, _cols, static_cast(_type), _usageFlags) + { + } +#endif // CV_TYPE_COMPATIBLE_API UMat(Size size, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline UMat(Size _size, int _type, UMatUsageFlags _usageFlags = USAGE_DEFAULT) + : UMat(_size, static_cast(_type), _usageFlags) + { + } +#endif // CV_TYPE_COMPATIBLE_API //! constucts 2D matrix and fills it with the specified value _s. UMat(int rows, int cols, ElemType type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline UMat(int _rows, int _cols, int _type, const Scalar& s, UMatUsageFlags _usageFlags = USAGE_DEFAULT) + : UMat(_rows, _cols, static_cast(_type), s, _usageFlags) + { + } +#endif // CV_TYPE_COMPATIBLE_API UMat(Size size, ElemType type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline UMat(Size _size, int _type, const Scalar& s, UMatUsageFlags _usageFlags = USAGE_DEFAULT) + : UMat(_size, static_cast(_type), s, _usageFlags) + { + } +#endif // CV_TYPE_COMPATIBLE_API //! constructs n-dimensional matrix UMat(int ndims, const int* sizes, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline UMat(int ndims, const int* _sizes, int _type, UMatUsageFlags _usageFlags = USAGE_DEFAULT) + : UMat(ndims, _sizes, static_cast(_type), _usageFlags) + { + } +#endif // CV_TYPE_COMPATIBLE_API UMat(int ndims, const int* sizes, ElemType type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline UMat(int ndims, const int* _sizes, int _type, const Scalar& s, UMatUsageFlags _usageFlags = USAGE_DEFAULT) + : UMat(ndims, _sizes, static_cast(_type), s, _usageFlags) + { + } +#endif // CV_TYPE_COMPATIBLE_API //! copy constructor UMat(const UMat& m); @@ -2488,8 +2731,23 @@ class CV_EXPORTS UMat void copyTo( OutputArray m, InputArray mask ) const; //! converts matrix to another datatype with optional scaling. See cvConvertScale. void convertTo(OutputArray m, ElemType ddepth, double alpha = 1, double beta = 0) const; +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) + inline void convertTo(OutputArray m, int ddepth, double alpha = 1, double beta = 0) const + { + convertTo(m, static_cast(ddepth), alpha, beta); + } +#endif // CV_TYPE_COMPATIBLE_API + void assignTo(UMat& m, ElemType depth = CV_TYPE_AUTO) const; +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + inline void assignTo(UMat& m, int _depth) const + { + assignTo(m, static_cast(_depth)); + } +#endif // CV_TYPE_COMPATIBLE_API //! sets every matrix element to s UMat& operator = (const Scalar& s); @@ -2512,20 +2770,104 @@ class CV_EXPORTS UMat //! Matlab-style matrix initialization static UMat zeros(int rows, int cols, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + static inline UMat zeros(int _rows, int _cols, int _type) + { + return zeros(_rows, _cols, static_cast(_type)); + } +#endif // CV_TYPE_COMPATIBLE_API static UMat zeros(Size size, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + static inline UMat zeros(Size _size, int _type) + { + return zeros(_size, static_cast(_type)); + } +#endif // CV_TYPE_COMPATIBLE_API static UMat zeros(int ndims, const int* sz, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + static inline UMat zeros(int ndims, const int* _sz, int _type) + { + return zeros(ndims, _sz, static_cast(_type)); + } +#endif // CV_TYPE_COMPATIBLE_API static UMat ones(int rows, int cols, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + static inline UMat ones(int _rows, int _cols, int _type) + { + return ones(_rows, _cols, static_cast(_type)); + } +#endif // CV_TYPE_COMPATIBLE_API static UMat ones(Size size, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + static inline UMat ones(Size _size, int _type) + { + return ones(_size, static_cast(_type)); + } +#endif // CV_TYPE_COMPATIBLE_API static UMat ones(int ndims, const int* sz, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + static inline UMat ones(int ndims, const int* _sz, int _type) + { + return ones(ndims, _sz, static_cast(_type)); + } +#endif // CV_TYPE_COMPATIBLE_API static UMat eye(int rows, int cols, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + static inline UMat eye(int _rows, int _cols, int _type) + { + return eye(_rows, _cols, static_cast(_type)); + } +#endif // CV_TYPE_COMPATIBLE_API static UMat eye(Size size, ElemType type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + static inline UMat eye(Size _size, int _type) + { + return eye(_size, static_cast(_type)); + } +#endif // CV_TYPE_COMPATIBLE_API //! allocates new matrix data unless the matrix already has specified size and type. // previous data is unreferenced if needed. void create(int rows, int cols, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline void create(int _rows, int _cols, int _type, UMatUsageFlags _usageFlags = USAGE_DEFAULT) + { + create(_rows, _cols, static_cast(_type), _usageFlags); + } +#endif // CV_TYPE_COMPATIBLE_API void create(Size size, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline void create(Size _size, int _type, UMatUsageFlags _usageFlags = USAGE_DEFAULT) + { + create(_size, static_cast(_type), _usageFlags); + } +#endif // CV_TYPE_COMPATIBLE_API void create(int ndims, const int* sizes, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline void create(int ndims, const int* _sizes, int _type, UMatUsageFlags _usageFlags = USAGE_DEFAULT) + { + create(ndims, _sizes, static_cast(_type), _usageFlags); + } +#endif // CV_TYPE_COMPATIBLE_API void create(const std::vector& sizes, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) + inline void create(const std::vector& sizes, int _type, UMatUsageFlags _usageFlags = USAGE_DEFAULT) + { + create(sizes, static_cast(_type), _usageFlags); + } +#endif // CV_TYPE_COMPATIBLE_API //! increases the reference counter; use with care to avoid memleaks void addref(); @@ -2576,7 +2918,15 @@ class CV_EXPORTS UMat size_t total() const; //! returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel (1 x N) or (N x 1); negative number otherwise + int checkVector(int elemChannels, ElemType depth = CV_TYPE_AUTO, bool requireContinuous = true) const; +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + inline int checkVector(int elemChannels, int _depth, bool requireContinuous = true) const + { + return checkVector(elemChannels, static_cast(_depth), requireContinuous ); + } +#endif // CV_TYPE_COMPATIBLE_API UMat(UMat&& m); UMat& operator = (UMat&& m); @@ -2733,6 +3083,13 @@ class CV_EXPORTS SparseMat struct CV_EXPORTS Hdr { Hdr(int _dims, const int* _sizes, ElemType _type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(_type, _type) + inline Hdr(int _dims, const int* _sizes, int _type) + : Hdr(_dims, _sizes, static_cast(_type)) + { + } +#endif // CV_TYPE_COMPATIBLE_API void clear(); int refcount; int dims; @@ -2766,6 +3123,13 @@ class CV_EXPORTS SparseMat @param _type Sparse matrix data type. */ SparseMat(int dims, const int* _sizes, ElemType _type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(_type, _type) + inline SparseMat(int _dims, const int* _sizes, int _type) + : SparseMat(_dims, _sizes, static_cast(_type)) + { + } +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param m Source matrix for copy constructor. If m is dense matrix (ocvMat) then it will be converted @@ -2796,6 +3160,13 @@ class CV_EXPORTS SparseMat void copyTo( Mat& m ) const; //! multiplies all the matrix elements by the specified scale factor alpha and converts the results to the specified data type void convertTo(SparseMat& m, ElemType ddepth, double alpha = 1) const; +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) + inline void convertTo(SparseMat& m, int ddepth, double alpha = 1) const + { + convertTo(m, static_cast(ddepth), alpha ); + } +#endif // CV_TYPE_COMPATIBLE_API //! converts sparse matrix to dense n-dim matrix with optional type conversion and scaling. /*! @param [out] m - output matrix; if it does not have a proper size or type before the operation, @@ -2805,9 +3176,24 @@ class CV_EXPORTS SparseMat @param [in] beta - optional delta added to the scaled values */ void convertTo(Mat& m, ElemType ddepth, double alpha = 1, double beta = 0) const; +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) + inline void convertTo(Mat& m, int ddepth, double alpha = 1, double beta = 0) const + { + convertTo(m, static_cast(ddepth), alpha, beta ); + } +#endif // CV_TYPE_COMPATIBLE_API // not used now + void assignTo(SparseMat& m, ElemType depth = CV_TYPE_AUTO) const; +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + inline void assignTo(SparseMat& m, int _depth) const + { + assignTo(m, static_cast(_depth) ); + } +#endif // CV_TYPE_COMPATIBLE_API //! reallocates sparse matrix. /*! @@ -2816,6 +3202,13 @@ class CV_EXPORTS SparseMat the old matrix is released (using release()) and the new one is allocated. */ void create(int dims, const int* _sizes, ElemType _type); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(_type, _type) + inline void create(int _dims, const int* _sizes, int _type) + { + create(_dims, _sizes, static_cast(_type)); + } +#endif // CV_TYPE_COMPATIBLE_API //! sets all the sparse matrix elements to 0, which means clearing the hash table. void clear(); //! manually increments the reference counter to the header. @@ -3491,7 +3884,15 @@ class CV_EXPORTS MatOp virtual ~MatOp(); virtual bool elementWise(const MatExpr& expr) const; + virtual void assign(const MatExpr& expr, Mat& m, ElemType depth = CV_TYPE_AUTO) const = 0; +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + inline virtual void assign(const MatExpr& expr, Mat& m, int _depth) const + { + assign(expr, m, static_cast(_depth)); + } +#endif // CV_TYPE_COMPATIBLE_API virtual void roi(const MatExpr& expr, const Range& rowRange, const Range& colRange, MatExpr& res) const; virtual void diag(const MatExpr& expr, int d, MatExpr& res) const; diff --git a/modules/core/include/opencv2/core/ocl.hpp b/modules/core/include/opencv2/core/ocl.hpp index eca391902af8..f970ebe8ca7b 100644 --- a/modules/core/include/opencv2/core/ocl.hpp +++ b/modules/core/include/opencv2/core/ocl.hpp @@ -308,6 +308,13 @@ CV_EXPORTS void attachContext(const String& platformName, void* platformID, void @param dst destination UMat */ CV_EXPORTS void convertFromBuffer(void* cl_mem_buffer, size_t step, int rows, int cols, ElemType type, UMat& dst); +#ifdef CV_TYPE_COMPATIBLE_API +CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) +static inline void convertFromBuffer(void* cl_mem_buffer, size_t step, int rows, int cols, int type, UMat& dst) +{ + convertFromBuffer(cl_mem_buffer, step, rows, cols, static_cast(type), dst); +} +#endif // CV_TYPE_COMPATIBLE_API /** @brief Convert OpenCL image2d_t to UMat @note @@ -729,11 +736,28 @@ class CV_EXPORTS PlatformInfo }; CV_EXPORTS const char* convertTypeStr(ElemType sdepth, ElemType ddepth, int cn, char* buf); +#ifdef CV_TYPE_COMPATIBLE_API +# ifndef OPENCV_DISABLE_DEPRECATED_WARNING_INT_ELEMTYPE_OVERLOAD +CV_DEPRECATED_MSG(CV_DEPRECATED_PARAM(int, stype, ElemType, sdepth) ". Similarly, " CV_DEPRECATED_PARAM(int, dtype, ElemType, ddepth)) +# endif +static inline const char* convertTypeStr(int sdepth, int ddepth, int cn, char* buf) +{ + return convertTypeStr(static_cast(sdepth), static_cast(ddepth), cn, buf); +} +#endif // CV_TYPE_COMPATIBLE_API CV_EXPORTS const char* typeToStr(int t); CV_EXPORTS const char* memopTypeToStr(int t); CV_EXPORTS const char* vecopTypeToStr(int t); CV_EXPORTS const char* getOpenCLErrorString(int errorCode); + CV_EXPORTS String kernelToStr(InputArray _kernel, ElemType ddepth = CV_TYPE_AUTO, const char * name = NULL); +#ifdef CV_TYPE_COMPATIBLE_API +CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) +static inline String kernelToStr(InputArray _kernel, int ddepth, const char * name = NULL) +{ + return kernelToStr(_kernel, static_cast(ddepth), name); +} +#endif // CV_TYPE_COMPATIBLE_API CV_EXPORTS void getPlatfomsInfo(std::vector& platform_info); @@ -792,6 +816,13 @@ class CV_EXPORTS Image2D /** Indicates if the image format is supported. */ static bool isFormatSupported(ElemType depth, int cn, bool norm); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + static inline bool isFormatSupported(int depth, int cn, bool norm) + { + return isFormatSupported(static_cast(depth), cn, norm); + } +#endif // CV_TYPE_COMPATIBLE_API void* ptr() const; protected: diff --git a/modules/core/include/opencv2/core/opengl.hpp b/modules/core/include/opencv2/core/opengl.hpp index 883afa8813d2..65a503615ebb 100644 --- a/modules/core/include/opencv2/core/opengl.hpp +++ b/modules/core/include/opencv2/core/opengl.hpp @@ -111,6 +111,13 @@ class CV_EXPORTS Buffer @param autoRelease Auto release mode (if true, release will be called in object's destructor). */ Buffer(int arows, int acols, ElemType atype, unsigned int abufId, bool autoRelease = false); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(atype, atype) + inline Buffer(int arows, int acols, int atype, unsigned int abufId, bool autoRelease = false) + : Buffer(arows, acols, static_cast(atype), abufId, autoRelease) + { + } +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param asize 2D array size. @@ -119,6 +126,13 @@ class CV_EXPORTS Buffer @param autoRelease Auto release mode (if true, release will be called in object's destructor). */ Buffer(Size asize, ElemType atype, unsigned int abufId, bool autoRelease = false); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(atype, atype) + inline Buffer(Size asize, int atype, unsigned int abufId, bool autoRelease = false) + : Buffer(asize, static_cast(atype), abufId, autoRelease) + { + } +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param arows Number of rows in a 2D array. @@ -128,6 +142,13 @@ class CV_EXPORTS Buffer @param autoRelease Auto release mode (if true, release will be called in object's destructor). */ Buffer(int arows, int acols, ElemType atype, Target target = ARRAY_BUFFER, bool autoRelease = false); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(atype, atype) + inline Buffer(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false) + : Buffer(arows, acols, static_cast(atype), target, autoRelease) + { + } +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param asize 2D array size. @@ -136,6 +157,13 @@ class CV_EXPORTS Buffer @param autoRelease Auto release mode (if true, release will be called in object's destructor). */ Buffer(Size asize, ElemType atype, Target target = ARRAY_BUFFER, bool autoRelease = false); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(atype, atype) + inline Buffer(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false) + : Buffer(asize, static_cast(atype), target, autoRelease) + { + } +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ). @@ -153,6 +181,13 @@ class CV_EXPORTS Buffer @param autoRelease Auto release mode (if true, release will be called in object's destructor). */ void create(int arows, int acols, ElemType atype, Target target = ARRAY_BUFFER, bool autoRelease = false); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(atype, atype) + inline void create(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false) + { + create(arows, acols, static_cast(atype), target, autoRelease); + } +#endif // CV_TYPE_COMPATIBLE_API /** @overload @param asize 2D array size. @@ -161,6 +196,13 @@ class CV_EXPORTS Buffer @param autoRelease Auto release mode (if true, release will be called in object's destructor). */ void create(Size asize, ElemType atype, Target target = ARRAY_BUFFER, bool autoRelease = false); +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(atype, atype) + inline void create(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false) + { + create(asize, static_cast(atype), target, autoRelease); + } +#endif // CV_TYPE_COMPATIBLE_API /** @brief Decrements the reference counter and destroys the buffer object if needed. @@ -375,6 +417,13 @@ class CV_EXPORTS Texture2D @param autoRelease Auto release mode for destination buffer (if arr is OpenGL buffer or texture). */ void copyTo(OutputArray arr, ElemType ddepth = CV_32F, bool autoRelease = false) const; +#ifdef CV_TYPE_COMPATIBLE_API + CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) + inline void copyTo(OutputArray arr, int ddepth, bool autoRelease = false) const + { + copyTo(arr, static_cast(ddepth), autoRelease ); + } +#endif // CV_TYPE_COMPATIBLE_API /** @brief Binds texture to current active texture unit for GL_TEXTURE_2D target. */ diff --git a/modules/core/include/opencv2/core/private.cuda.hpp b/modules/core/include/opencv2/core/private.cuda.hpp index 7fd419616014..c39a5fbe05bd 100644 --- a/modules/core/include/opencv2/core/private.cuda.hpp +++ b/modules/core/include/opencv2/core/private.cuda.hpp @@ -94,11 +94,24 @@ namespace cv { namespace cuda { CV_EXPORTS GpuMat getInputMat(InputArray _src, Stream& stream); CV_EXPORTS GpuMat getOutputMat(OutputArray _dst, int rows, int cols, ElemType type, Stream& stream); +#ifdef CV_TRANSNATIONAL_API + static inline GpuMat getOutputMat(OutputArray _dst, int rows, int cols, int type, Stream& stream) + { + return getOutputMat(_dst, rows, cols, static_cast(type), stream); + } +#endif // CV_TRANSNATIONAL_API static inline GpuMat getOutputMat(OutputArray _dst, Size size, ElemType type, Stream& stream) { return getOutputMat(_dst, size.height, size.width, type, stream); } +#ifdef CV_TRANSNATIONAL_API + static inline GpuMat getOutputMat(OutputArray _dst, Size size, int type, Stream& stream) + { + return getOutputMat(_dst, size, static_cast(type), stream); + } +#endif // CV_TRANSNATIONAL_API + CV_EXPORTS void syncOutput(const GpuMat& dst, OutputArray _dst, Stream& stream); }} diff --git a/modules/core/include/opencv2/core/private.hpp b/modules/core/include/opencv2/core/private.hpp index ab9971b230dd..f6fe2741674d 100644 --- a/modules/core/include/opencv2/core/private.hpp +++ b/modules/core/include/opencv2/core/private.hpp @@ -326,6 +326,13 @@ static inline IppDataType ippiGetDataType(ElemType depth) (IppDataType)-1; } +#ifdef CV_TRANSNATIONAL_API +static inline IppDataType ippiGetDataType(int depth) +{ + return ippiGetDataType(static_cast(depth)); +} +#endif // CV_TRANSNATIONAL_API + static inline int ippiSuggestThreadsNum(size_t width, size_t height, size_t elemSize, double multiplier) { int threads = cv::getNumThreads(); diff --git a/modules/core/src/matrix_expressions.cpp b/modules/core/src/matrix_expressions.cpp index 7181abfd9891..150293f9a154 100644 --- a/modules/core/src/matrix_expressions.cpp +++ b/modules/core/src/matrix_expressions.cpp @@ -1757,4 +1757,47 @@ MatExpr Mat::eye(Size size, ElemType type) return e; } +//MatExpr is incomplete type, thus inline functions does not work! +#ifdef CV_TYPE_COMPATIBLE_API +MatExpr Mat::zeros(int rows, int cols, int type) +{ + return zeros(rows, cols, static_cast(type)); +} + +MatExpr Mat::zeros(Size size, int type) +{ + return zeros(size, static_cast(type)); +} + +MatExpr Mat::zeros(int ndims, const int* sz, int type) +{ + return zeros(ndims, sz, static_cast(type)); +} + +MatExpr Mat::ones(int rows, int cols, int type) +{ + return ones(rows, cols, static_cast(type)); +} + +MatExpr Mat::ones(Size size, int type) +{ + return ones(size, static_cast(type)); +} + +MatExpr Mat::ones(int ndims, const int* sz, int type) +{ + return ones(ndims, sz, static_cast(type)); +} + +MatExpr Mat::eye(int rows, int cols, int type) +{ + return eye(rows, cols, static_cast(type)); +} + +MatExpr Mat::eye(Size size, int type) +{ + return eye(size, static_cast(type)); +} +#endif // CV_TYPE_COMPATIBLE_API + } // cv:: From 27b4466f84aa469c697c8122842d547ce0e4ff2c Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 13 Sep 2018 11:13:25 +0000 Subject: [PATCH 07/10] cmake: change type safe flags defaults - propagate CV_TYPE_SAFE_API/CV_TYPE_COMPATIBLE_API for user apps - special fix for CUDA --- CMakeLists.txt | 18 ++++++------------ cmake/OpenCVDetectCUDA.cmake | 6 ++++++ modules/core/CMakeLists.txt | 6 ++++++ .../core/include/opencv2/core/hal/interface.h | 9 +++++++++ modules/java/jni/CMakeLists.txt | 7 +++++++ 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ecef7dfb5886..e941df496a82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -315,8 +315,8 @@ OCV_OPTION(INSTALL_TESTS "Install accuracy and performance test binar # OpenCV build options # =================================================== -OCV_OPTION(ENABLE_TYPE_SAFE_API "Enable enum-based type-safe API? If disabled, int types will be utilized" ON) -OCV_OPTION(ENABLE_COMPATIBLE_API "Enable backwards compatibility with legacy API?" ON IF ENABLE_TYPE_SAFE_API) +OCV_OPTION(DISABLE_TYPE_SAFE_API "Disable enum-based type-safe API? If disabled, 'int' types will be utilized" OFF) +OCV_OPTION(DISABLE_TYPE_COMPATIBLE_API "Disable backwards compatibility with legacy API?" OFF IF NOT DISABLE_TYPE_SAFE_API) OCV_OPTION(ENABLE_CCACHE "Use ccache" (UNIX AND NOT IOS AND (CMAKE_GENERATOR MATCHES "Makefile" OR CMAKE_GENERATOR MATCHES "Ninja")) ) OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" ON IF (MSVC OR (NOT IOS AND NOT CMAKE_CROSSCOMPILING) ) ) OCV_OPTION(ENABLE_SOLUTION_FOLDERS "Solution folder in Visual Studio or in other IDEs" (MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode) ) @@ -345,14 +345,8 @@ OCV_OPTION(CV_TRACE "Enable OpenCV code trace" ON) OCV_OPTION(ENABLE_PYLINT "Add target with Pylint checks" (BUILD_DOCS OR BUILD_EXAMPLES) IF (NOT CMAKE_CROSSCOMPILING AND NOT APPLE_FRAMEWORK) ) OCV_OPTION(ENABLE_FLAKE8 "Add target with Python flake8 checker" (BUILD_DOCS OR BUILD_EXAMPLES) IF (NOT CMAKE_CROSSCOMPILING AND NOT APPLE_FRAMEWORK) ) -if(ENABLE_TYPE_SAFE_API) - add_definitions(-DCV_TYPE_SAFE_API) -else() - set(ENABLE_COMPATIBLE_API OFF) -endif() - -if(ENABLE_COMPATIBLE_API) - add_definitions(-DCV_TYPE_COMPATIBLE_API) +if(DISABLE_TYPE_SAFE_API) + ocv_assert(DISABLE_TYPE_COMPATIBLE_API) endif() if(ENABLE_IMPL_COLLECTION) @@ -1032,8 +1026,8 @@ else() endif() status(" ccache:" OPENCV_COMPILER_IS_CCACHE THEN YES ELSE NO) status(" Precompiled headers:" PCHSupport_FOUND AND ENABLE_PRECOMPILED_HEADERS THEN YES ELSE NO) -status(" Type-safe API:" ENABLE_TYPE_SAFE_API THEN "YES" ELSE "NO") -status(" Compatible API:" ENABLE_COMPATIBLE_API THEN "YES" ELSE "NO") +status(" Type-safe API:" DISABLE_TYPE_SAFE_API THEN "NO" ELSE "YES") +status(" Compatible type API:" DISABLE_TYPE_COMPATIBLE_API THEN "NO" ELSE "YES") # ========================== Dependencies ============================ diff --git a/cmake/OpenCVDetectCUDA.cmake b/cmake/OpenCVDetectCUDA.cmake index 27bf79bd8ee8..47f01eac05bc 100644 --- a/cmake/OpenCVDetectCUDA.cmake +++ b/cmake/OpenCVDetectCUDA.cmake @@ -263,6 +263,12 @@ if(CUDA_FOUND) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wunused-but-set-variable) endif() + if(DISABLE_TYPE_SAFE_API) + set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler -DCV_DISABLE_TYPE_SAFE_API=1) + elseif(DISABLE_TYPE_COMPATIBLE_API) + set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler -DCV_DISABLE_TYPE_COMPATIBLE_API=1) + endif() + CUDA_COMPILE(${VAR} ${ARGN}) foreach(var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG) diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt index 73acbdd02230..3f8491c5de7d 100644 --- a/modules/core/CMakeLists.txt +++ b/modules/core/CMakeLists.txt @@ -85,6 +85,12 @@ if(HAVE_CUDA) ocv_target_compile_definitions(${the_module} PUBLIC OPENCV_TRAITS_ENABLE_DEPRECATED) endif() +if(DISABLE_TYPE_SAFE_API) + ocv_target_compile_definitions(${the_module} PUBLIC CV_DISABLE_TYPE_SAFE_API=1) +elseif(DISABLE_TYPE_COMPATIBLE_API) + ocv_target_compile_definitions(${the_module} PUBLIC CV_DISABLE_TYPE_COMPATIBLE_API=1) +endif() + ocv_add_accuracy_tests() ocv_add_perf_tests() diff --git a/modules/core/include/opencv2/core/hal/interface.h b/modules/core/include/opencv2/core/hal/interface.h index db8539d59748..a58be32b4324 100644 --- a/modules/core/include/opencv2/core/hal/interface.h +++ b/modules/core/include/opencv2/core/hal/interface.h @@ -89,6 +89,15 @@ typedef signed char schar; #define CV_MAKETYPE(depth,cn) static_cast(__CV_MAKETYPE(depth,cn)) #define CV_MAKE_TYPE CV_MAKETYPE +#define CV_TYPE_SAFE_API +#define CV_TYPE_COMPATIBLE_API +#ifdef CV_DISABLE_TYPE_SAFE_API +# undef CV_TYPE_SAFE_API +#endif +#ifdef CV_DISABLE_TYPE_COMPATIBLE_API +# undef CV_TYPE_COMPATIBLE_API +#endif + //Define transnational API availble only when Compatible API is set #ifdef CV_TYPE_COMPATIBLE_API # define CV_TRANSNATIONAL_API diff --git a/modules/java/jni/CMakeLists.txt b/modules/java/jni/CMakeLists.txt index bfb948bfb7e2..7ea1951235a7 100644 --- a/modules/java/jni/CMakeLists.txt +++ b/modules/java/jni/CMakeLists.txt @@ -82,6 +82,13 @@ endif() set(__install_export "") if(BUILD_FAT_JAVA_LIB) + # libopencv_java.so is used during native Android builds (without opencv_core) + if(DISABLE_TYPE_SAFE_API) + ocv_target_compile_definitions(${the_module} PUBLIC CV_DISABLE_TYPE_SAFE_API=1) + elseif(DISABLE_TYPE_COMPATIBLE_API) + ocv_target_compile_definitions(${the_module} PUBLIC CV_DISABLE_TYPE_COMPATIBLE_API=1) + endif() + set(__install_export EXPORT OpenCVModules) endif() From 4bea02603f4d7d2fa26da45189e4b6ad5ddf78bc Mon Sep 17 00:00:00 2001 From: Hamdi Sahloul Date: Thu, 20 Sep 2018 00:35:10 +0900 Subject: [PATCH 08/10] Clear all warnings --- modules/calib3d/src/fisheye.cpp | 10 +++++----- modules/core/include/opencv2/core/hal/interface.h | 2 +- modules/imgproc/src/colormap.cpp | 3 ++- modules/imgproc/src/featureselect.cpp | 6 +++--- modules/imgproc/test/test_goodfeaturetotrack.cpp | 2 +- modules/imgproc/test/test_imgwarp.cpp | 2 +- modules/imgproc/test/test_imgwarp_strict.cpp | 3 +++ modules/ts/src/ts_func.cpp | 2 ++ 8 files changed, 18 insertions(+), 12 deletions(-) diff --git a/modules/calib3d/src/fisheye.cpp b/modules/calib3d/src/fisheye.cpp index fdd8aad18ff4..2a05d647745b 100644 --- a/modules/calib3d/src/fisheye.cpp +++ b/modules/calib3d/src/fisheye.cpp @@ -429,7 +429,7 @@ void cv::fisheye::initUndistortRectifyMap( InputArray K, InputArray D, InputArra CV_Assert( m1type == CV_16SC2 || m1type == CV_32F || m1type <=0 ); map1.create( size, m1type <= 0 ? CV_16SC2 : m1type ); - map2.create( size, map1.type() == CV_16SC2 ? CV_16UC1 : CV_32F ); + map2.create( size, map1.type() == CV_16SC2 ? CV_16UC1 : CV_32FC1 ); CV_Assert((K.depth() == CV_32F || K.depth() == CV_64F) && (D.depth() == CV_32F || D.depth() == CV_64F)); CV_Assert((P.empty() || P.depth() == CV_32F || P.depth() == CV_64F) && (R.empty() || R.depth() == CV_32F || R.depth() == CV_64F)); @@ -664,9 +664,9 @@ void cv::fisheye::stereoRectify( InputArray K1, InputArray D1, InputArray K2, In // apply to both views Matx33d ri1 = wr * r_r.t(); - Mat(ri1, false).convertTo(R1, R1.empty() ? CV_64F : R1.type()); + Mat(ri1, false).convertTo(R1, R1.empty() ? CV_64F : R1.depth()); Matx33d ri2 = wr * r_r; - Mat(ri2, false).convertTo(R2, R2.empty() ? CV_64F : R2.type()); + Mat(ri2, false).convertTo(R2, R2.empty() ? CV_64F : R2.depth()); Vec3d tnew = ri2 * tvec; // calculate projection/camera matrices. these contain the relevant rectified image internal params (fx, fy=fx, cx, cy) @@ -687,11 +687,11 @@ void cv::fisheye::stereoRectify( InputArray K1, InputArray D1, InputArray K2, In Mat(Matx34d(fc_new, 0, cc_new[0].x, 0, 0, fc_new, cc_new[0].y, 0, - 0, 0, 1, 0), false).convertTo(P1, P1.empty() ? CV_64F : P1.type()); + 0, 0, 1, 0), false).convertTo(P1, P1.empty() ? CV_64F : P1.depth()); Mat(Matx34d(fc_new, 0, cc_new[1].x, tnew[0]*fc_new, // baseline * focal length;, 0, fc_new, cc_new[1].y, 0, - 0, 0, 1, 0), false).convertTo(P2, P2.empty() ? CV_64F : P2.type()); + 0, 0, 1, 0), false).convertTo(P2, P2.empty() ? CV_64F : P2.depth()); if (Q.needed()) Mat(Matx44d(1, 0, 0, -cc_new[0].x, diff --git a/modules/core/include/opencv2/core/hal/interface.h b/modules/core/include/opencv2/core/hal/interface.h index a58be32b4324..3c6a9d8fd030 100644 --- a/modules/core/include/opencv2/core/hal/interface.h +++ b/modules/core/include/opencv2/core/hal/interface.h @@ -106,7 +106,7 @@ typedef signed char schar; //#define OPENCV_ENABLE_DEPRECATED_WARNING_ELEMDEPTH_ELEMTYPE_OVERLOAD -//#define OPENCV_DISABLE_DEPRECATED_WARNING_INT_ELEMTYPE_OVERLOAD +#define OPENCV_DISABLE_DEPRECATED_WARNING_INT_ELEMTYPE_OVERLOAD #if defined(CV_TYPE_SAFE_API) && defined(__cplusplus) diff --git a/modules/imgproc/src/colormap.cpp b/modules/imgproc/src/colormap.cpp index 8658595300bb..c2f28951faec 100644 --- a/modules/imgproc/src/colormap.cpp +++ b/modules/imgproc/src/colormap.cpp @@ -126,8 +126,9 @@ static Mat interp1(InputArray _x, InputArray _Y, InputArray _xi) case CV_32SC1: return interp1_(x,Y,xi); break; case CV_32FC1: return interp1_(x,Y,xi); break; case CV_64FC1: return interp1_(x,Y,xi); break; + default: + CV_Error(Error::StsUnsupportedFormat, ""); } - CV_Error(Error::StsUnsupportedFormat, ""); } namespace colormap diff --git a/modules/imgproc/src/featureselect.cpp b/modules/imgproc/src/featureselect.cpp index 772764414590..53dc541944ac 100644 --- a/modules/imgproc/src/featureselect.cpp +++ b/modules/imgproc/src/featureselect.cpp @@ -257,7 +257,7 @@ static bool ocl_goodFeaturesToTrack( InputArray _image, OutputArray _corners, } } - Mat(corners).convertTo(_corners, _corners.fixedType() ? _corners.type() : CV_32F); + Mat(corners).convertTo(_corners, _corners.fixedType() ? _corners.depth() : CV_32F); return true; } @@ -330,7 +330,7 @@ static bool openvx_harris(Mat image, OutputArray _corners, keypoints.push_back(Point2f((float)kp.x, (float)kp.y)); } - Mat(keypoints).convertTo(_corners, _corners.fixedType() ? _corners.type() : CV_32F); + Mat(keypoints).convertTo(_corners, _corners.fixedType() ? _corners.depth() : CV_32F); #ifdef VX_VERSION_1_1 //we should take user memory back before release @@ -508,7 +508,7 @@ void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners, } } - Mat(corners).convertTo(_corners, _corners.fixedType() ? _corners.type() : CV_32F); + Mat(corners).convertTo(_corners, _corners.fixedType() ? _corners.depth() : CV_32F); } CV_IMPL void diff --git a/modules/imgproc/test/test_goodfeaturetotrack.cpp b/modules/imgproc/test/test_goodfeaturetotrack.cpp index 1a339bea55eb..47c4a036f120 100644 --- a/modules/imgproc/test/test_goodfeaturetotrack.cpp +++ b/modules/imgproc/test/test_goodfeaturetotrack.cpp @@ -300,7 +300,7 @@ test_goodFeaturesToTrack( InputArray _image, OutputArray _corners, } } - Mat(corners).convertTo(_corners, _corners.fixedType() ? _corners.type() : CV_32F); + Mat(corners).convertTo(_corners, _corners.fixedType() ? _corners.depth() : CV_32F); } diff --git a/modules/imgproc/test/test_imgwarp.cpp b/modules/imgproc/test/test_imgwarp.cpp index 400426af15a6..13dce6e02b9e 100644 --- a/modules/imgproc/test/test_imgwarp.cpp +++ b/modules/imgproc/test/test_imgwarp.cpp @@ -1028,7 +1028,7 @@ void CV_UndistortMapTest::get_test_array_types_and_sizes( int test_case_idx, vec types[INPUT][0] = types[INPUT][1] = depth; dualChannel = cvtest::randInt(rng)%2 == 0; types[OUTPUT][0] = types[OUTPUT][1] = - types[REF_OUTPUT][0] = types[REF_OUTPUT][1] = dualChannel ? CV_32FC2 : CV_32F; + types[REF_OUTPUT][0] = types[REF_OUTPUT][1] = dualChannel ? CV_32FC2 : CV_32FC1; sizes[INPUT][0] = cvSize(3,3); sizes[INPUT][1] = cvtest::randInt(rng)%2 ? cvSize(4,1) : cvSize(1,4); diff --git a/modules/imgproc/test/test_imgwarp_strict.cpp b/modules/imgproc/test/test_imgwarp_strict.cpp index 31869f1d752f..de0ece5fcbe0 100644 --- a/modules/imgproc/test/test_imgwarp_strict.cpp +++ b/modules/imgproc/test/test_imgwarp_strict.cpp @@ -782,6 +782,9 @@ void CV_Remap_Test::generate_test_data() *begin_y = static_cast(rng.uniform(0, 1024)); } break; + + default: + CV_CheckType(mapy.type(), mapy.type() == CV_16UC1 || mapy.type() == CV_16SC1, ""); } } } diff --git a/modules/ts/src/ts_func.cpp b/modules/ts/src/ts_func.cpp index c404759fd4eb..587be637fb59 100644 --- a/modules/ts/src/ts_func.cpp +++ b/modules/ts/src/ts_func.cpp @@ -326,6 +326,8 @@ void convert(const Mat& src, cv::OutputArray _dst, int dtype, double alpha, doub case CV_64F: convertTo((const double*)sptr, dptr, dtype, total, alpha, beta); break; + case CV_16F: + break; //unhandled } } } From 074b57df58e8d42e5ef064c523ff3b685cbfdfa2 Mon Sep 17 00:00:00 2001 From: Hamdi Sahloul Date: Sat, 22 Sep 2018 05:59:55 +0900 Subject: [PATCH 09/10] Add ElemDepth enum --- modules/core/include/opencv2/core.hpp | 66 ++++++++--------- modules/core/include/opencv2/core/affine.hpp | 4 +- modules/core/include/opencv2/core/base.hpp | 16 ++-- modules/core/include/opencv2/core/check.hpp | 16 ++-- modules/core/include/opencv2/core/cuda.hpp | 28 +++---- .../core/include/opencv2/core/cuda.inl.hpp | 14 ++-- .../core/include/opencv2/core/cvstd.inl.hpp | 2 +- modules/core/include/opencv2/core/eigen.hpp | 20 ++--- modules/core/include/opencv2/core/hal/hal.hpp | 12 +-- .../core/include/opencv2/core/hal/interface.h | 19 +++-- modules/core/include/opencv2/core/mat.hpp | 56 +++++++------- modules/core/include/opencv2/core/mat.inl.hpp | 30 ++++---- modules/core/include/opencv2/core/matx.hpp | 12 +-- modules/core/include/opencv2/core/ocl.hpp | 14 ++-- modules/core/include/opencv2/core/opengl.hpp | 8 +- .../core/include/opencv2/core/operations.hpp | 8 +- modules/core/include/opencv2/core/private.hpp | 4 +- modules/core/include/opencv2/core/traits.hpp | 26 +++---- modules/core/include/opencv2/core/types.hpp | 40 +++++----- modules/core/include/opencv2/core/types_c.h | 2 +- .../core/misc/java/src/cpp/core_manual.hpp | 8 +- modules/core/misc/python/pyopencv_core.hpp | 3 + modules/core/src/arithm.cpp | 74 +++++++++---------- modules/core/src/array.cpp | 8 +- modules/core/src/batch_distance.cpp | 36 ++++----- modules/core/src/channels.cpp | 12 +-- modules/core/src/check.cpp | 10 +-- modules/core/src/convert.cpp | 12 +-- modules/core/src/convert_c.cpp | 2 +- modules/core/src/convert_scale.cpp | 20 ++--- modules/core/src/copy.cpp | 6 +- modules/core/src/count_non_zero.cpp | 8 +- modules/core/src/cuda/gpu_mat.cu | 14 ++-- modules/core/src/cuda_gpu_mat.cpp | 4 +- modules/core/src/downhill_simplex.cpp | 2 +- modules/core/src/dxt.cpp | 44 +++++------ modules/core/src/hal_replacement.hpp | 8 +- modules/core/src/lapack.cpp | 6 +- modules/core/src/lda.cpp | 18 ++--- modules/core/src/lut.cpp | 4 +- modules/core/src/mathfuncs.cpp | 34 ++++----- modules/core/src/matmul.cpp | 64 ++++++++-------- modules/core/src/matrix.cpp | 2 +- modules/core/src/matrix_c.cpp | 2 +- modules/core/src/matrix_expressions.cpp | 61 ++++++++------- modules/core/src/matrix_operations.cpp | 32 ++++---- modules/core/src/matrix_sparse.cpp | 10 +-- modules/core/src/matrix_wrap.cpp | 2 +- modules/core/src/mean.cpp | 10 +-- modules/core/src/merge.cpp | 8 +- modules/core/src/minmax.cpp | 10 +-- modules/core/src/norm.cpp | 18 ++--- modules/core/src/ocl.cpp | 28 +++---- modules/core/src/opengl.cpp | 16 ++-- modules/core/src/pca.cpp | 12 +-- modules/core/src/persistence_base64.cpp | 2 +- modules/core/src/persistence_types.cpp | 8 +- modules/core/src/precomp.hpp | 4 +- modules/core/src/rand.cpp | 6 +- modules/core/src/split.cpp | 8 +- modules/core/src/stat.hpp | 4 +- modules/core/src/sum.cpp | 8 +- modules/core/src/umatrix.cpp | 20 ++--- modules/java/generator/gen_java.py | 7 +- modules/java/generator/src/cpp/Mat.cpp | 18 ++--- modules/js/src/core_bindings.cpp | 14 ++-- modules/python/src2/cv2.cpp | 28 +++---- modules/python/src2/gen2.py | 2 +- 68 files changed, 570 insertions(+), 564 deletions(-) diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index 48d643636583..726b34f65eda 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -327,7 +327,7 @@ The input arrays and the output array can all have the same or different depths. can add a 16-bit unsigned array to a 8-bit signed array and store the sum as a 32-bit floating-point array. Depth of the output array is determined by the ddepth parameter. In the second and third cases above, as well as in the first case, when src1.depth() == src2.depth(), ddepth can -be set to the default CV_TYPE_AUTO. In this case, the output array will have the same depth as the input +be set to the default CV_DEPTH_AUTO. In this case, the output array will have the same depth as the input array, be it src1, src2 or both. @note Saturation is not applied when the output array has the depth CV_32S. You may even get result of an incorrect sign in the case of overflow. @@ -341,13 +341,13 @@ output array to be changed. @sa subtract, addWeighted, scaleAdd, Mat::convertTo */ CV_EXPORTS_W void add(InputArray src1, InputArray src2, OutputArray dst, - InputArray mask = noArray(), ElemType ddepth = CV_TYPE_AUTO); + InputArray mask = noArray(), ElemDepth ddepth = CV_DEPTH_AUTO); #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) static inline void add(InputArray src1, InputArray src2, OutputArray dst, InputArray mask, int ddepth) { - add(src1, src2, dst, mask, static_cast(ddepth)); + add(src1, src2, dst, mask, static_cast(ddepth)); } #endif // CV_TYPE_COMPATIBLE_API @@ -376,7 +376,7 @@ The first function in the list above can be replaced with matrix expressions: The input arrays and the output array can all have the same or different depths. For example, you can subtract to 8-bit unsigned arrays and store the difference in a 16-bit signed array. Depth of the output array is determined by ddepth parameter. In the second and third cases above, as well as -in the first case, when src1.depth() == src2.depth(), ddepth can be set to the default CV_TYPE_AUTO. In this +in the first case, when src1.depth() == src2.depth(), ddepth can be set to the default CV_DEPTH_AUTO. In this case the output array will have the same depth as the input array, be it src1, src2 or both. @note Saturation is not applied when the output array has the depth CV_32S. You may even get result of an incorrect sign in the case of overflow. @@ -389,13 +389,13 @@ of the output array to be changed. @sa add, addWeighted, scaleAdd, Mat::convertTo */ CV_EXPORTS_W void subtract(InputArray src1, InputArray src2, OutputArray dst, - InputArray mask = noArray(), ElemType ddepth = CV_TYPE_AUTO); + InputArray mask = noArray(), ElemDepth ddepth = CV_DEPTH_AUTO); #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) static inline void subtract(InputArray src1, InputArray src2, OutputArray dst, InputArray mask, int ddepth) { - subtract(src1, src2, dst, mask, static_cast(ddepth)); + subtract(src1, src2, dst, mask, static_cast(ddepth)); } #endif // CV_TYPE_COMPATIBLE_API @@ -422,13 +422,13 @@ overflow. Mat::convertTo */ CV_EXPORTS_W void multiply(InputArray src1, InputArray src2, - OutputArray dst, double scale = 1, ElemType ddepth = CV_TYPE_AUTO); + OutputArray dst, double scale = 1, ElemDepth ddepth = CV_DEPTH_AUTO); #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) static inline void multiply(InputArray src1, InputArray src2, OutputArray dst, double scale, int ddepth) { - multiply(src1, src2, dst, scale, static_cast(ddepth)); + multiply(src1, src2, dst, scale, static_cast(ddepth)); } #endif // CV_TYPE_COMPATIBLE_API @@ -448,30 +448,30 @@ result of an incorrect sign in the case of overflow. @param src2 second input array of the same size and type as src1. @param scale scalar factor. @param dst output array of the same size and type as src2. -@param ddepth optional depth of the output array; if CV_TYPE_AUTO, dst will have depth src2.depth(), but in +@param ddepth optional depth of the output array; if CV_DEPTH_AUTO, dst will have depth src2.depth(), but in case of an array-by-array division, you can only pass -1 when src1.depth()==src2.depth(). @sa multiply, add, subtract */ CV_EXPORTS_W void divide(InputArray src1, InputArray src2, OutputArray dst, - double scale = 1, ElemType ddepth = CV_TYPE_AUTO); + double scale = 1, ElemDepth ddepth = CV_DEPTH_AUTO); #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) static inline void divide(InputArray src1, InputArray src2, OutputArray dst, double scale, int ddepth) { - divide(src1, src2, dst, scale, static_cast(ddepth)); + divide(src1, src2, dst, scale, static_cast(ddepth)); } #endif // CV_TYPE_COMPATIBLE_API /** @overload */ CV_EXPORTS_W void divide(double scale, InputArray src2, - OutputArray dst, ElemType ddepth = CV_TYPE_AUTO); + OutputArray dst, ElemDepth ddepth = CV_DEPTH_AUTO); #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) static inline void divide(double scale, InputArray src2, OutputArray dst, int ddepth) { - divide(scale, src2, dst, static_cast(ddepth)); + divide(scale, src2, dst, static_cast(ddepth)); } #endif // CV_TYPE_COMPATIBLE_API @@ -518,17 +518,17 @@ result of an incorrect sign in the case of overflow. @param gamma scalar added to each sum. @param dst output array that has the same size and number of channels as the input arrays. @param ddepth optional depth of the output array; when both input arrays have the same depth, ddepth -can be set to CV_TYPE_AUTO, which will be equivalent to src1.depth(). +can be set to CV_DEPTH_AUTO, which will be equivalent to src1.depth(). @sa add, subtract, scaleAdd, Mat::convertTo */ CV_EXPORTS_W void addWeighted(InputArray src1, double alpha, InputArray src2, - double beta, double gamma, OutputArray dst, ElemType ddepth = CV_TYPE_AUTO); + double beta, double gamma, OutputArray dst, ElemDepth ddepth = CV_DEPTH_AUTO); #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) static inline void addWeighted(InputArray src1, double alpha, InputArray src2, double beta, double gamma, OutputArray dst, int ddepth) { - addWeighted(src1, alpha, src2, beta, gamma, dst, static_cast(ddepth)); + addWeighted(src1, alpha, src2, beta, gamma, dst, static_cast(ddepth)); } #endif // CV_TYPE_COMPATIBLE_API @@ -754,19 +754,19 @@ see http://en.wikipedia.org/wiki/Nearest_neighbor_search @todo document */ CV_EXPORTS_W void batchDistance(InputArray src1, InputArray src2, - OutputArray dist, ElemType dtype, OutputArray nidx, + OutputArray dist, ElemDepth ddepth, OutputArray nidx, int normType = NORM_L2, int K = 0, InputArray mask = noArray(), int update = 0, bool crosscheck = false); #ifdef CV_TYPE_COMPATIBLE_API -CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, dtype) +CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(dtype, ddepth) static inline void batchDistance(InputArray src1, InputArray src2, - OutputArray dist, int dtype, OutputArray nidx, + OutputArray dist, int ddepth, OutputArray nidx, int normType = NORM_L2, int K = 0, InputArray mask = noArray(), int update = 0, bool crosscheck = false) { - batchDistance(src1, src2, dist, static_cast(dtype), nidx, normType, K, mask, update, crosscheck); + batchDistance(src1, src2, dist, static_cast(ddepth), nidx, normType, K, mask, update, crosscheck); } #endif // CV_TYPE_COMPATIBLE_API @@ -824,18 +824,18 @@ normalization. @param beta upper range boundary in case of the range normalization; it is not used for the norm normalization. @param norm_type normalization type (see cv::NormTypes). -@param ddepth desired output matrix depth. when it is CV_TYPE_AUTO, the output array has the same type as src. +@param ddepth desired output matrix depth. when it is CV_DEPTH_AUTO, the output array has the same type as src. @param mask optional operation mask. @sa norm, Mat::convertTo, SparseMat::convertTo */ CV_EXPORTS_W void normalize( InputArray src, InputOutputArray dst, double alpha = 1, double beta = 0, - int norm_type = NORM_L2, ElemType ddepth = CV_TYPE_AUTO, InputArray mask = noArray()); + int norm_type = NORM_L2, ElemDepth ddepth = CV_DEPTH_AUTO, InputArray mask = noArray()); #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) static inline void normalize( InputArray src, InputOutputArray dst, double alpha, double beta, int norm_type, int ddepth, InputArray mask = noArray()) { - normalize(src, dst, alpha, beta, norm_type, static_cast(ddepth), mask); + normalize(src, dst, alpha, beta, norm_type, static_cast(ddepth), mask); } #endif // CV_TYPE_COMPATIBLE_API @@ -929,17 +929,17 @@ And the following code demonstrates its usage for a two-channel matrix. @param dim dimension index along which the matrix is reduced. 0 means that the matrix is reduced to a single row. 1 means that the matrix is reduced to a single column. @param rtype reduction operation that could be one of #ReduceTypes -@param ddepth when it is CV_TYPE_AUTO, the output vector will have the same type as the input matrix, +@param ddepth when it is CV_DEPTH_AUTO, the output vector will have the same type as the input matrix, otherwise, its type will be CV_MAKE_TYPE(ddepth, src.channels()). @sa repeat */ -CV_EXPORTS_W void reduce(InputArray src, OutputArray dst, int dim, int rtype, ElemType ddepth = CV_TYPE_AUTO); +CV_EXPORTS_W void reduce(InputArray src, OutputArray dst, int dim, int rtype, ElemDepth ddepth = CV_DEPTH_AUTO); #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) static inline void reduce(InputArray src, OutputArray dst, int dim, int rtype, int ddepth) { - reduce(src, dst, dim, rtype, static_cast(ddepth)); + reduce(src, dst, dim, rtype, static_cast(ddepth)); } #endif // CV_TYPE_COMPATIBLE_API @@ -1726,21 +1726,21 @@ repeat ) to cover the full src and then subtracted. Type of the delta matrix, when it is not empty, must be the same as the type of created output matrix. See the ddepth parameter description below. @param scale Optional scale factor for the matrix product. -@param ddepth Optional depth of the output matrix. When it is CV_TYPE_AUTO, +@param ddepth Optional depth of the output matrix. When it is CV_DEPTH_AUTO, the output matrix will have the same type as src . Otherwise, it should be either CV_32F or CV_64F, and the output type will be CV_MAKE_TYPE(ddepth, src.channels()). @sa calcCovarMatrix, gemm, repeat, reduce */ CV_EXPORTS_W void mulTransposed( InputArray src, OutputArray dst, bool aTa, InputArray delta = noArray(), - double scale = 1, ElemType ddepth = CV_TYPE_AUTO); + double scale = 1, ElemDepth ddepth = CV_DEPTH_AUTO); #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) static inline void mulTransposed(InputArray src, OutputArray dst, bool aTa, InputArray delta, double scale, int ddepth) { - mulTransposed(src, dst, aTa, delta, scale, static_cast(ddepth)); + mulTransposed(src, dst, aTa, delta, scale, static_cast(ddepth)); } #endif // CV_TYPE_COMPATIBLE_API @@ -2030,13 +2030,13 @@ the set of input vectors. @todo InputArrayOfArrays */ CV_EXPORTS void calcCovarMatrix( const Mat* samples, int nsamples, Mat& covar, Mat& mean, - int flags, ElemType cdepth = CV_64F); + int flags, ElemDepth cdepth = CV_64F); #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(ctype, ctype) static inline void calcCovarMatrix(const Mat* samples, int nsamples, Mat& covar, Mat& mean, int flags, int ctype) { - calcCovarMatrix(samples, nsamples, covar, mean, flags, static_cast(ctype)); + calcCovarMatrix(samples, nsamples, covar, mean, flags, static_cast(ctype)); } #endif // CV_TYPE_COMPATIBLE_API @@ -2049,13 +2049,13 @@ static inline void calcCovarMatrix(const Mat* samples, int nsamples, Mat& covar, @param cdepth depth of the matrixl; it equals 'CV_64F' by default. */ CV_EXPORTS_W void calcCovarMatrix( InputArray samples, OutputArray covar, - InputOutputArray mean, int flags, ElemType cdepth = CV_64F); + InputOutputArray mean, int flags, ElemDepth cdepth = CV_64F); #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(ctype, ctype) static inline void calcCovarMatrix(InputArray samples, OutputArray covar, InputOutputArray mean, int flags, int ctype) { - calcCovarMatrix(samples, covar, mean, flags, static_cast(ctype)); + calcCovarMatrix(samples, covar, mean, flags, static_cast(ctype)); } #endif // CV_TYPE_COMPATIBLE_API diff --git a/modules/core/include/opencv2/core/affine.hpp b/modules/core/include/opencv2/core/affine.hpp index 203e191aaf2e..b2fbdc9b4b88 100644 --- a/modules/core/include/opencv2/core/affine.hpp +++ b/modules/core/include/opencv2/core/affine.hpp @@ -304,7 +304,7 @@ namespace cv static const int channels = 16; static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - static const ElemType depth = DataType::depth; + static const ElemDepth depth = DataType::depth; static const ElemType type = CV_MAKETYPE(depth, channels); #endif @@ -313,7 +313,7 @@ namespace cv namespace traits { template - struct Depth< Affine3<_Tp> > { static const ElemType value = Depth<_Tp>::value; }; + struct Depth< Affine3<_Tp> > { static const ElemDepth value = Depth<_Tp>::value; }; template struct Type< Affine3<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 16); }; } // namespace diff --git a/modules/core/include/opencv2/core/base.hpp b/modules/core/include/opencv2/core/base.hpp index 42d08b03d423..4eeee67ee35e 100644 --- a/modules/core/include/opencv2/core/base.hpp +++ b/modules/core/include/opencv2/core/base.hpp @@ -60,9 +60,9 @@ #ifdef CV_TYPE_COMPATIBLE_API #define CV_DEPRECATED_MAX_DEPTH_DEPTH "use `CV_MAX_DEPTH(...)` instead" -#define CV_DEPRECATED_MAX_DEPTH_INT "max() between `ElemType` and `int` is deprecated" +#define CV_DEPRECATED_MAX_DEPTH_INT "max() between `ElemDepth` and `int` is deprecated" #define CV_DEPRECATED_MIN_DEPTH_DEPTH "use `CV_MIN_DEPTH(...)` instead" -#define CV_DEPRECATED_MIN_DEPTH_INT "min() between `ElemType` and `int` is deprecated" +#define CV_DEPRECATED_MIN_DEPTH_INT "min() between `ElemDepth` and `int` is deprecated" #define CV_DEPRECATED_ELEMTYPE_CMP_INT "comparing `ElemType` directly with `int` is deprecated. " #define CV_DEPRECATED_PARAM(depr_type, depr_var, new_type, new_var) \ "parameter `" CV_STR(depr_type) " " CV_STR(depr_var) "` is deprecated. " \ @@ -91,32 +91,32 @@ namespace std { - CV_DEPRECATED_MAX_DEPTH_INT_ATTR static inline int max(const ElemType left, const int right) + CV_DEPRECATED_MAX_DEPTH_INT_ATTR static inline int max(const ElemDepth left, const int right) { return static_cast(CV_MAX_DEPTH(left, right)); } - CV_DEPRECATED_MAX_DEPTH_INT_ATTR static inline int max(const int left, const ElemType right) + CV_DEPRECATED_MAX_DEPTH_INT_ATTR static inline int max(const int left, const ElemDepth right) { return static_cast(CV_MAX_DEPTH(left, right)); } - CV_DEPRECATED_MAX_DEPTH_DEPTH_ATTR static inline int max(const ElemType left, const ElemType right) + CV_DEPRECATED_MAX_DEPTH_DEPTH_ATTR static inline int max(const ElemDepth left, const ElemDepth right) { return static_cast(CV_MAX_DEPTH(left, right)); } - CV_DEPRECATED_MIN_DEPTH_INT_ATTR static inline int min(const ElemType left, const int right) + CV_DEPRECATED_MIN_DEPTH_INT_ATTR static inline int min(const ElemDepth left, const int right) { return static_cast(CV_MIN_DEPTH(left, right)); } - CV_DEPRECATED_MIN_DEPTH_INT_ATTR static inline int min(const int left, const ElemType right) + CV_DEPRECATED_MIN_DEPTH_INT_ATTR static inline int min(const int left, const ElemDepth right) { return static_cast(CV_MIN_DEPTH(left, right)); } - CV_DEPRECATED_MIN_DEPTH_DEPTH_ATTR static inline int min(const ElemType left, const ElemType right) + CV_DEPRECATED_MIN_DEPTH_DEPTH_ATTR static inline int min(const ElemDepth left, const ElemDepth right) { return static_cast(CV_MIN_DEPTH(left, right)); } diff --git a/modules/core/include/opencv2/core/check.hpp b/modules/core/include/opencv2/core/check.hpp index 9a8d495db201..451ca21e4051 100644 --- a/modules/core/include/opencv2/core/check.hpp +++ b/modules/core/include/opencv2/core/check.hpp @@ -10,11 +10,11 @@ namespace cv { /** Returns string of cv::Mat depth value: CV_8U -> "CV_8U" or "" */ -CV_EXPORTS const char* depthToString(ElemType depth); +CV_EXPORTS const char* depthToString(ElemDepth depth); #ifdef CV_TRANSNATIONAL_API static inline const char* depthToString(int depth) { - return depthToString(static_cast(depth)); + return depthToString(static_cast(depth)); } #endif // CV_TRANSNATIONAL_API @@ -32,11 +32,11 @@ static inline const String typeToString(int type) namespace detail { /** Returns string of cv::Mat depth value: CV_8U -> "CV_8U" or NULL */ -CV_EXPORTS const char* depthToString_(ElemType depth); +CV_EXPORTS const char* depthToString_(ElemDepth depth); #ifdef CV_TRANSNATIONAL_API static inline const char* depthToString_(int depth) { - return depthToString_(static_cast(depth)); + return depthToString_(static_cast(depth)); } #endif // CV_TRANSNATIONAL_API @@ -93,11 +93,11 @@ CV_EXPORTS void CV_NORETURN check_failed_auto(const int v1, const int v2, const CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v1, const size_t v2, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const float v1, const float v2, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const double v1, const double v2, const CheckContext& ctx); -CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const ElemType v1, const ElemType v2, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const ElemDepth v1, const ElemDepth v2, const CheckContext& ctx); #ifdef CV_TRANSNATIONAL_API static inline void CV_NORETURN check_failed_MatDepth(const int v1, const int v2, const CheckContext& ctx) { - check_failed_MatDepth(static_cast(v1), static_cast(v2), ctx); + check_failed_MatDepth(static_cast(v1), static_cast(v2), ctx); } #endif // CV_TRANSNATIONAL_API CV_EXPORTS void CV_NORETURN check_failed_MatType(const ElemType v1, const ElemType v2, const CheckContext& ctx); @@ -113,11 +113,11 @@ CV_EXPORTS void CV_NORETURN check_failed_auto(const int v, const CheckContext& c CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const float v, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const double v, const CheckContext& ctx); -CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const ElemType v, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const ElemDepth v, const CheckContext& ctx); #ifdef CV_TRANSNATIONAL_API static inline void CV_NORETURN check_failed_MatDepth(const int v, const CheckContext& ctx) { - check_failed_MatDepth(static_cast(v), ctx); + check_failed_MatDepth(static_cast(v), ctx); } #endif // CV_TRANSNATIONAL_API CV_EXPORTS void CV_NORETURN check_failed_MatType(const ElemType v, const CheckContext& ctx); diff --git a/modules/core/include/opencv2/core/cuda.hpp b/modules/core/include/opencv2/core/cuda.hpp index 34e8a8438f9b..326171dce5ef 100644 --- a/modules/core/include/opencv2/core/cuda.hpp +++ b/modules/core/include/opencv2/core/cuda.hpp @@ -278,62 +278,62 @@ class CV_EXPORTS_W GpuMat CV_WRAP GpuMat& setTo(Scalar s, InputArray mask, Stream& stream); //! converts GpuMat to another datatype (Blocking call) - CV_WRAP void convertTo(OutputArray dst, ElemType ddepth) const; + CV_WRAP void convertTo(OutputArray dst, ElemDepth ddepth) const; #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) inline void convertTo(OutputArray dst, int ddepth) const { - convertTo(dst, static_cast(ddepth)); + convertTo(dst, static_cast(ddepth)); } #endif // CV_TYPE_COMPATIBLE_API //! converts GpuMat to another datatype (Non-Blocking call) - CV_WRAP void convertTo(OutputArray dst, ElemType ddepth, Stream& stream) const; + CV_WRAP void convertTo(OutputArray dst, ElemDepth ddepth, Stream& stream) const; #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) inline void convertTo(OutputArray dst, int ddepth, Stream& stream) const { - convertTo(dst, static_cast(ddepth), stream); + convertTo(dst, static_cast(ddepth), stream); } #endif // CV_TYPE_COMPATIBLE_API //! converts GpuMat to another datatype with scaling (Blocking call) - CV_WRAP void convertTo(OutputArray dst, ElemType ddepth, double alpha, double beta = 0.0) const; + CV_WRAP void convertTo(OutputArray dst, ElemDepth ddepth, double alpha, double beta = 0.0) const; #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) inline void convertTo(OutputArray dst, int ddepth, double alpha, double beta = 0.0) const { - convertTo(dst, static_cast(ddepth), alpha, beta ); + convertTo(dst, static_cast(ddepth), alpha, beta ); } #endif // CV_TYPE_COMPATIBLE_API //! converts GpuMat to another datatype with scaling (Non-Blocking call) - CV_WRAP void convertTo(OutputArray dst, ElemType ddepth, double alpha, Stream& stream) const; + CV_WRAP void convertTo(OutputArray dst, ElemDepth ddepth, double alpha, Stream& stream) const; #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) inline void convertTo(OutputArray dst, int ddepth, double alpha, Stream& stream) const { - convertTo(dst, static_cast(ddepth), alpha, stream); + convertTo(dst, static_cast(ddepth), alpha, stream); } #endif // CV_TYPE_COMPATIBLE_API //! converts GpuMat to another datatype with scaling (Non-Blocking call) - CV_WRAP void convertTo(OutputArray dst, ElemType ddepth, double alpha, double beta, Stream& stream) const; + CV_WRAP void convertTo(OutputArray dst, ElemDepth ddepth, double alpha, double beta, Stream& stream) const; #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) inline void convertTo(OutputArray dst, int ddepth, double alpha, double beta, Stream& stream) const { - convertTo(dst, static_cast(ddepth), alpha, beta, stream); + convertTo(dst, static_cast(ddepth), alpha, beta, stream); } #endif // CV_TYPE_COMPATIBLE_API - CV_WRAP void assignTo(GpuMat& m, ElemType depth = CV_TYPE_AUTO) const; + CV_WRAP void assignTo(GpuMat& m, ElemDepth depth = CV_DEPTH_AUTO) const; #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) inline void assignTo(GpuMat& m, int _depth) const { - assignTo(m, static_cast(_depth) ); + assignTo(m, static_cast(_depth) ); } #endif // CV_TYPE_COMPATIBLE_API @@ -390,7 +390,7 @@ class CV_EXPORTS_W GpuMat CV_WRAP ElemType type() const; //! returns element type - CV_WRAP ElemType depth() const; + CV_WRAP ElemDepth depth() const; //! returns number of channels CV_WRAP int channels() const; @@ -731,7 +731,7 @@ class CV_EXPORTS_W HostMem CV_WRAP size_t elemSize() const; CV_WRAP size_t elemSize1() const; CV_WRAP ElemType type() const; - CV_WRAP ElemType depth() const; + CV_WRAP ElemDepth depth() const; CV_WRAP int channels() const; CV_WRAP size_t step1() const; CV_WRAP Size size() const; diff --git a/modules/core/include/opencv2/core/cuda.inl.hpp b/modules/core/include/opencv2/core/cuda.inl.hpp index 263db8b88682..04a219300cc2 100644 --- a/modules/core/include/opencv2/core/cuda.inl.hpp +++ b/modules/core/include/opencv2/core/cuda.inl.hpp @@ -177,27 +177,27 @@ GpuMat& GpuMat::setTo(Scalar s, InputArray mask) } inline -void GpuMat::convertTo(OutputArray dst, ElemType ddepth) const +void GpuMat::convertTo(OutputArray dst, ElemDepth ddepth) const { convertTo(dst, ddepth, Stream::Null()); } inline -void GpuMat::convertTo(OutputArray dst, ElemType ddepth, double alpha, double beta) const +void GpuMat::convertTo(OutputArray dst, ElemDepth ddepth, double alpha, double beta) const { convertTo(dst, ddepth, alpha, beta, Stream::Null()); } inline -void GpuMat::convertTo(OutputArray dst, ElemType ddepth, double alpha, Stream& stream) const +void GpuMat::convertTo(OutputArray dst, ElemDepth ddepth, double alpha, Stream& stream) const { convertTo(dst, ddepth, alpha, 0.0, stream); } inline -void GpuMat::assignTo(GpuMat& m, ElemType _depth) const +void GpuMat::assignTo(GpuMat& m, ElemDepth _depth) const { - if (_depth == CV_TYPE_AUTO) + if (_depth == CV_DEPTH_AUTO) m = *this; else convertTo(m, _depth); @@ -314,7 +314,7 @@ ElemType GpuMat::type() const } inline -ElemType GpuMat::depth() const +ElemDepth GpuMat::depth() const { return CV_MAT_DEPTH(flags); } @@ -527,7 +527,7 @@ ElemType HostMem::type() const } inline -ElemType HostMem::depth() const +ElemDepth HostMem::depth() const { return CV_MAT_DEPTH(flags); } diff --git a/modules/core/include/opencv2/core/cvstd.inl.hpp b/modules/core/include/opencv2/core/cvstd.inl.hpp index f293ce2772d6..8b3c3ddac5fa 100644 --- a/modules/core/include/opencv2/core/cvstd.inl.hpp +++ b/modules/core/include/opencv2/core/cvstd.inl.hpp @@ -65,7 +65,7 @@ template class DataType< std::complex<_Tp> > typedef _Tp channel_type; static const bool generic_type = false; - static const ElemType depth = DataType::depth; + static const ElemDepth depth = DataType::depth; static const int channels = 2; static const int fmt = DataType::fmt + ((channels - 1) << 8); static const ElemType type = CV_MAKETYPE(depth, channels); diff --git a/modules/core/include/opencv2/core/eigen.hpp b/modules/core/include/opencv2/core/eigen.hpp index c8603aca9731..8be03c60dc5b 100644 --- a/modules/core/include/opencv2/core/eigen.hpp +++ b/modules/core/include/opencv2/core/eigen.hpp @@ -104,17 +104,17 @@ void cv2eigen( const Mat& src, transpose(src, _dst); else if( src.cols == src.rows ) { - src.convertTo(_dst, _dst.type()); + src.convertTo(_dst, _dst.depth()); transpose(_dst, _dst); } else - Mat(src.t()).convertTo(_dst, _dst.type()); + Mat(src.t()).convertTo(_dst, _dst.depth()); } else { const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value, dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); - src.convertTo(_dst, _dst.type()); + src.convertTo(_dst, _dst.depth()); } } @@ -150,17 +150,17 @@ void cv2eigen( const Mat& src, transpose(src, _dst); else if( src.cols == src.rows ) { - src.convertTo(_dst, _dst.type()); + src.convertTo(_dst, _dst.depth()); transpose(_dst, _dst); } else - Mat(src.t()).convertTo(_dst, _dst.type()); + Mat(src.t()).convertTo(_dst, _dst.depth()); } else { const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value, dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); - src.convertTo(_dst, _dst.type()); + src.convertTo(_dst, _dst.depth()); } } @@ -198,13 +198,13 @@ void cv2eigen( const Mat& src, if( src.type() == _dst.type() ) transpose(src, _dst); else - Mat(src.t()).convertTo(_dst, _dst.type()); + Mat(src.t()).convertTo(_dst, _dst.depth()); } else { const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value, dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); - src.convertTo(_dst, _dst.type()); + src.convertTo(_dst, _dst.depth()); } } @@ -243,13 +243,13 @@ void cv2eigen( const Mat& src, if( src.type() == _dst.type() ) transpose(src, _dst); else - Mat(src.t()).convertTo(_dst, _dst.type()); + Mat(src.t()).convertTo(_dst, _dst.depth()); } else { const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value, dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); - src.convertTo(_dst, _dst.type()); + src.convertTo(_dst, _dst.depth()); } } diff --git a/modules/core/include/opencv2/core/hal/hal.hpp b/modules/core/include/opencv2/core/hal/hal.hpp index 6abc7307332b..eb175fb601bb 100644 --- a/modules/core/include/opencv2/core/hal/hal.hpp +++ b/modules/core/include/opencv2/core/hal/hal.hpp @@ -203,11 +203,11 @@ CV_EXPORTS void addRNGBias64f( double* arr, const double* scaleBiasPairs, int le struct CV_EXPORTS DFT1D { - static Ptr create(int len, int count, ElemType depth, int flags, bool * useBuffer = 0); + static Ptr create(int len, int count, ElemDepth depth, int flags, bool * useBuffer = 0); #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) static inline Ptr create(int len, int count, int depth, int flags, bool * useBuffer = 0) - { return create(len, count, static_cast(depth), flags, useBuffer); + { return create(len, count, static_cast(depth), flags, useBuffer); } #endif // CV_TYPE_COMPATIBLE_API virtual void apply(const uchar *src, uchar *dst) = 0; @@ -216,7 +216,7 @@ struct CV_EXPORTS DFT1D struct CV_EXPORTS DFT2D { - static Ptr create(int width, int height, ElemType depth, + static Ptr create(int width, int height, ElemDepth depth, int src_channels, int dst_channels, int flags, int nonzero_rows = 0); #ifdef CV_TYPE_COMPATIBLE_API @@ -224,7 +224,7 @@ struct CV_EXPORTS DFT2D static inline Ptr create(int width, int height, int depth, int src_channels, int dst_channels, int flags, int nonzero_rows = 0) - { return create(width, height, static_cast(depth), src_channels, dst_channels, flags, nonzero_rows); + { return create(width, height, static_cast(depth), src_channels, dst_channels, flags, nonzero_rows); } #endif // CV_TYPE_COMPATIBLE_API virtual void apply(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step) = 0; @@ -233,11 +233,11 @@ struct CV_EXPORTS DFT2D struct CV_EXPORTS DCT2D { - static Ptr create(int width, int height, ElemType depth, int flags); + static Ptr create(int width, int height, ElemDepth depth, int flags); #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) static inline Ptr create(int width, int height, int depth, int flags) - { return create(width, height, static_cast(depth), flags); + { return create(width, height, static_cast(depth), flags); } #endif // CV_TYPE_COMPATIBLE_API virtual void apply(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step) = 0; diff --git a/modules/core/include/opencv2/core/hal/interface.h b/modules/core/include/opencv2/core/hal/interface.h index 3c6a9d8fd030..07ffa227c038 100644 --- a/modules/core/include/opencv2/core/hal/interface.h +++ b/modules/core/include/opencv2/core/hal/interface.h @@ -69,14 +69,14 @@ typedef signed char schar; #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_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__))) +#define CV_MIN_DEPTH(...) __CV_EXPAND(static_cast(__CV_CAT(__CV_MIN_DEPTH_, __CV_VA_NUM_ARGS(__VA_ARGS__)) (__VA_ARGS__))) #define CV_CN_MAX 512 #define CV_CN_SHIFT 3 @@ -84,7 +84,7 @@ typedef signed char schar; #define CV_MAT_DEPTH_MASK (CV_DEPTH_MAX - 1) #define __CV_MAT_DEPTH(flags) (static_cast(flags) & CV_MAT_DEPTH_MASK) -#define CV_MAT_DEPTH(flags) static_cast(__CV_MAT_DEPTH(flags)) +#define CV_MAT_DEPTH(flags) static_cast(__CV_MAT_DEPTH(flags)) #define __CV_MAKETYPE(depth,cn) (__CV_MAT_DEPTH(depth) | (((cn)-1) << CV_CN_SHIFT)) #define CV_MAKETYPE(depth,cn) static_cast(__CV_MAKETYPE(depth,cn)) #define CV_MAKE_TYPE CV_MAKETYPE @@ -114,7 +114,7 @@ enum MagicFlag { CV_MAGIC_FLAG_NONE = 0 }; -enum ElemType { +enum ElemDepth { CV_8U = 0, CV_8S = 1, CV_16U = 2, @@ -123,6 +123,11 @@ enum ElemType { CV_32S = 4, CV_32F = 5, CV_64F = 6, +}; +#define CV_DEPTH_AUTO static_cast(-1) + +enum ElemType { + CV_SEQ_ELTYPE_PTR = __CV_MAKETYPE(CV_8U, 8 /*sizeof(void*)*/), CV_8UC1 = __CV_MAKETYPE(CV_8U, 1), CV_8UC2 = __CV_MAKETYPE(CV_8U, 2), @@ -163,8 +168,6 @@ enum ElemType { CV_64FC2 = __CV_MAKETYPE(CV_64F, 2), CV_64FC3 = __CV_MAKETYPE(CV_64F, 3), CV_64FC4 = __CV_MAKETYPE(CV_64F, 4), - - CV_SEQ_ELTYPE_PTR = __CV_MAKETYPE(CV_8U, 8 /*sizeof(void*)*/), }; #define CV_TYPE_AUTO static_cast(-1) #define CV_TYPE_UNDEFINED static_cast(-2) @@ -175,8 +178,8 @@ enum ElemType { typedef int MagicFlag; #define CV_MAGIC_FLAG_NONE 0 -typedef int ElemType; -#define CV_TYPE_AUTO -1 +typedef int ElemDepth; +#define CV_DEPTH_AUTO -1 #define CV_8U 0 #define CV_8S 1 #define CV_16U 2 diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index ef19db46c413..25908b1355c1 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -251,7 +251,7 @@ class CV_EXPORTS _InputArray bool sameSize(const _InputArray& arr) const; size_t total(int i=-1) const; ElemType type(int i = -1) const; - ElemType depth(int i = -1) const; + ElemDepth depth(int i = -1) const; int channels(int i=-1) const; bool isContinuous(int i=-1) const; bool isSubmatrix(int i=-1) const; @@ -1372,12 +1372,12 @@ class CV_EXPORTS Mat @param alpha optional scale factor. @param beta optional delta added to the scaled values. */ - void convertTo(OutputArray m, ElemType ddepth, double alpha = 1, double beta = 0) const; + void convertTo(OutputArray m, ElemDepth ddepth, double alpha = 1, double beta = 0) const; #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) inline void convertTo(OutputArray m, int ddepth, double alpha = 1, double beta = 0) const { - convertTo(m, static_cast(ddepth), alpha, beta); + convertTo(m, static_cast(ddepth), alpha, beta); } #endif // CV_TYPE_COMPATIBLE_API @@ -1385,15 +1385,15 @@ class CV_EXPORTS Mat This is an internally used method called by the @ref MatrixExpressions engine. @param m Destination array. - @param depth Desired destination array depth (or CV_TYPE_AUTO if it should be the same as the source type). + @param depth Desired destination array depth (or CV_DEPTH_AUTO if it should be the same as the source type). */ - void assignTo(Mat& m, ElemType depth = CV_TYPE_AUTO) const; + void assignTo(Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const; #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) inline void assignTo(Mat& m, int _depth) const { - assignTo(m, static_cast(_depth)); + assignTo(m, static_cast(_depth)); } #endif // CV_TYPE_COMPATIBLE_API @@ -1987,7 +1987,7 @@ class CV_EXPORTS Mat - CV_32F - 32-bit floating-point numbers ( -FLT_MAX..FLT_MAX, INF, NAN ) - CV_64F - 64-bit floating-point numbers ( -DBL_MAX..DBL_MAX, INF, NAN ) */ - ElemType depth() const; + ElemDepth depth() const; /** @brief Returns the number of matrix channels. @@ -2031,7 +2031,7 @@ class CV_EXPORTS Mat * if the number of planes is not one, then the number of rows * within every plane has to be 1; if the number of rows within * every plane is not 1, then the number of planes has to be 1. - * @param depth The depth the matrix should have. Set it to CV_TYPE_AUTO when any depth is fine. + * @param depth The depth the matrix should have. Set it to CV_DEPTH_AUTO when any depth is fine. * @param requireContinuous Set it to true to require the matrix to be continuous * @return -1 if the requirement is not satisfied. * Otherwise, it returns the number of elements in the matrix. Note @@ -2044,12 +2044,12 @@ class CV_EXPORTS Mat * @snippet snippets/core_mat_checkVector.cpp example-3d */ - int checkVector(int elemChannels, ElemType depth = CV_TYPE_AUTO, bool requireContinuous = true) const; + int checkVector(int elemChannels, ElemDepth depth = CV_DEPTH_AUTO, bool requireContinuous = true) const; #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) inline int checkVector(int elemChannels, int _depth, bool requireContinuous = true) const { - return checkVector(elemChannels, static_cast(_depth), requireContinuous); + return checkVector(elemChannels, static_cast(_depth), requireContinuous); } #endif // CV_TYPE_COMPATIBLE_API @@ -2512,7 +2512,7 @@ template class Mat_ : public Mat size_t elemSize() const; size_t elemSize1() const; ElemType type() const; - ElemType depth() const; + ElemDepth depth() const; int channels() const; size_t step1(int i=0) const; //! returns step()/sizeof(_Tp) @@ -2730,22 +2730,22 @@ class CV_EXPORTS UMat //! copies those matrix elements to "m" that are marked with non-zero mask elements. void copyTo( OutputArray m, InputArray mask ) const; //! converts matrix to another datatype with optional scaling. See cvConvertScale. - void convertTo(OutputArray m, ElemType ddepth, double alpha = 1, double beta = 0) const; + void convertTo(OutputArray m, ElemDepth ddepth, double alpha = 1, double beta = 0) const; #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) inline void convertTo(OutputArray m, int ddepth, double alpha = 1, double beta = 0) const { - convertTo(m, static_cast(ddepth), alpha, beta); + convertTo(m, static_cast(ddepth), alpha, beta); } #endif // CV_TYPE_COMPATIBLE_API - void assignTo(UMat& m, ElemType depth = CV_TYPE_AUTO) const; + void assignTo(UMat& m, ElemDepth depth = CV_DEPTH_AUTO) const; #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) inline void assignTo(UMat& m, int _depth) const { - assignTo(m, static_cast(_depth)); + assignTo(m, static_cast(_depth)); } #endif // CV_TYPE_COMPATIBLE_API @@ -2907,7 +2907,7 @@ class CV_EXPORTS UMat //! returns element type, similar to CV_MAT_TYPE(cvmat->type) ElemType type() const; //! returns element type, similar to CV_MAT_DEPTH(cvmat->type) - ElemType depth() const; + ElemDepth depth() const; //! returns element type, similar to CV_MAT_CN(cvmat->type) int channels() const; //! returns step/elemSize1() @@ -2919,12 +2919,12 @@ class CV_EXPORTS UMat //! returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel (1 x N) or (N x 1); negative number otherwise - int checkVector(int elemChannels, ElemType depth = CV_TYPE_AUTO, bool requireContinuous = true) const; + int checkVector(int elemChannels, ElemDepth depth = CV_DEPTH_AUTO, bool requireContinuous = true) const; #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) inline int checkVector(int elemChannels, int _depth, bool requireContinuous = true) const { - return checkVector(elemChannels, static_cast(_depth), requireContinuous ); + return checkVector(elemChannels, static_cast(_depth), requireContinuous ); } #endif // CV_TYPE_COMPATIBLE_API @@ -3159,12 +3159,12 @@ class CV_EXPORTS SparseMat //! converts sparse matrix to dense matrix. void copyTo( Mat& m ) const; //! multiplies all the matrix elements by the specified scale factor alpha and converts the results to the specified data type - void convertTo(SparseMat& m, ElemType ddepth, double alpha = 1) const; + void convertTo(SparseMat& m, ElemDepth ddepth, double alpha = 1) const; #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) inline void convertTo(SparseMat& m, int ddepth, double alpha = 1) const { - convertTo(m, static_cast(ddepth), alpha ); + convertTo(m, static_cast(ddepth), alpha ); } #endif // CV_TYPE_COMPATIBLE_API //! converts sparse matrix to dense n-dim matrix with optional type conversion and scaling. @@ -3175,23 +3175,23 @@ class CV_EXPORTS SparseMat @param [in] alpha - optional scale factor @param [in] beta - optional delta added to the scaled values */ - void convertTo(Mat& m, ElemType ddepth, double alpha = 1, double beta = 0) const; + void convertTo(Mat& m, ElemDepth ddepth, double alpha = 1, double beta = 0) const; #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) inline void convertTo(Mat& m, int ddepth, double alpha = 1, double beta = 0) const { - convertTo(m, static_cast(ddepth), alpha, beta ); + convertTo(m, static_cast(ddepth), alpha, beta ); } #endif // CV_TYPE_COMPATIBLE_API // not used now - void assignTo(SparseMat& m, ElemType depth = CV_TYPE_AUTO) const; + void assignTo(SparseMat& m, ElemDepth depth = CV_DEPTH_AUTO) const; #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) inline void assignTo(SparseMat& m, int _depth) const { - assignTo(m, static_cast(_depth) ); + assignTo(m, static_cast(_depth) ); } #endif // CV_TYPE_COMPATIBLE_API @@ -3226,7 +3226,7 @@ class CV_EXPORTS SparseMat //! returns type of sparse matrix elements ElemType type() const; //! returns the depth of sparse matrix elements - ElemType depth() const; + ElemDepth depth() const; //! returns the number of channels int channels() const; @@ -3426,7 +3426,7 @@ template class SparseMat_ : public SparseMat //! returns type of the matrix elements ElemType type() const; //! returns depth of the matrix elements - ElemType depth() const; + ElemDepth depth() const; //! returns the number of channels in each matrix element int channels() const; @@ -3885,12 +3885,12 @@ class CV_EXPORTS MatOp virtual bool elementWise(const MatExpr& expr) const; - virtual void assign(const MatExpr& expr, Mat& m, ElemType depth = CV_TYPE_AUTO) const = 0; + virtual void assign(const MatExpr& expr, Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const = 0; #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) inline virtual void assign(const MatExpr& expr, Mat& m, int _depth) const { - assign(expr, m, static_cast(_depth)); + assign(expr, m, static_cast(_depth)); } #endif // CV_TYPE_COMPATIBLE_API virtual void roi(const MatExpr& expr, const Range& rowRange, diff --git a/modules/core/include/opencv2/core/mat.inl.hpp b/modules/core/include/opencv2/core/mat.inl.hpp index bb800ddce4b5..5ece6f5ffef2 100644 --- a/modules/core/include/opencv2/core/mat.inl.hpp +++ b/modules/core/include/opencv2/core/mat.inl.hpp @@ -813,9 +813,9 @@ Mat Mat::clone() const } inline -void Mat::assignTo(Mat& m, ElemType _depth) const +void Mat::assignTo(Mat& m, ElemDepth _depth) const { - if (_depth == CV_TYPE_AUTO) + if (_depth == CV_DEPTH_AUTO) m = *this; else convertTo(m, _depth); @@ -922,7 +922,7 @@ ElemType Mat::type() const } inline -ElemType Mat::depth() const +ElemDepth Mat::depth() const { return CV_MAT_DEPTH(flags); } @@ -1320,7 +1320,7 @@ Mat::operator Vec<_Tp, n>() const return Vec<_Tp, n>((_Tp*)data); Vec<_Tp, n> v; Mat tmp(rows, cols, traits::Type<_Tp>::value, v.val); - convertTo(tmp, tmp.type()); + convertTo(tmp, tmp.depth()); return v; } @@ -1333,7 +1333,7 @@ Mat::operator Matx<_Tp, m, n>() const return Matx<_Tp, m, n>((_Tp*)data); Matx<_Tp, m, n> mtx; Mat tmp(rows, cols, traits::Type<_Tp>::value, mtx.val); - convertTo(tmp, tmp.type()); + convertTo(tmp, tmp.depth()); return mtx; } @@ -1709,7 +1709,7 @@ Mat_<_Tp>& Mat_<_Tp>::operator = (const Mat& m) return (*this = m.reshape(DataType<_Tp>::channels, m.dims, 0)); } CV_Assert(DataType<_Tp>::channels == m.channels() || m.empty()); - m.convertTo(*this, type()); + m.convertTo(*this, depth()); return *this; } @@ -1813,7 +1813,7 @@ ElemType Mat_<_Tp>::type() const } template inline -ElemType Mat_<_Tp>::depth() const +ElemDepth Mat_<_Tp>::depth() const { CV_DbgAssert( Mat::depth() == traits::Depth<_Tp>::value ); return traits::Depth<_Tp>::value; @@ -2087,7 +2087,7 @@ Mat_<_Tp>& Mat_<_Tp>::operator = (Mat&& m) return *this; } CV_DbgAssert(DataType<_Tp>::channels == m.channels()); - m.convertTo(*this, type()); + m.convertTo(*this, depth()); return *this; } @@ -2156,9 +2156,9 @@ SparseMat SparseMat::clone() const } inline -void SparseMat::assignTo(SparseMat& m, ElemType _depth) const +void SparseMat::assignTo(SparseMat& m, ElemDepth _depth) const { - if (_depth == CV_TYPE_AUTO) + if (_depth == CV_DEPTH_AUTO) m = *this; else convertTo(m, _depth); @@ -2198,7 +2198,7 @@ ElemType SparseMat::type() const } inline -ElemType SparseMat::depth() const +ElemDepth SparseMat::depth() const { return CV_MAT_DEPTH(flags); } @@ -2513,7 +2513,7 @@ ElemType SparseMat_<_Tp>::type() const } template inline -ElemType SparseMat_<_Tp>::depth() const +ElemDepth SparseMat_<_Tp>::depth() const { return traits::Depth<_Tp>::value; } @@ -3740,9 +3740,9 @@ UMat UMat::clone() const } inline -void UMat::assignTo(UMat& m, ElemType _depth) const +void UMat::assignTo(UMat& m, ElemDepth _depth) const { - if (_depth == CV_TYPE_AUTO) + if (_depth == CV_DEPTH_AUTO) m = *this; else convertTo(m, _depth); @@ -3837,7 +3837,7 @@ ElemType UMat::type() const } inline -ElemType UMat::depth() const +ElemDepth UMat::depth() const { return CV_MAT_DEPTH(flags); } diff --git a/modules/core/include/opencv2/core/matx.hpp b/modules/core/include/opencv2/core/matx.hpp index 3fcd73b17436..863a798c2c45 100644 --- a/modules/core/include/opencv2/core/matx.hpp +++ b/modules/core/include/opencv2/core/matx.hpp @@ -104,7 +104,7 @@ template class Matx static const int channels = rows*cols; static const int shortdim = (m < n ? m : n); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - static const ElemType depth = traits::Depth<_Tp>::value; + static const ElemDepth depth = traits::Depth<_Tp>::value; static const ElemType type = CV_MAKETYPE(depth, channels); #endif @@ -260,14 +260,14 @@ template class DataType< Matx<_Tp, m, n> > static const int channels = m * n; static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - static const ElemType depth = DataType::depth; + static const ElemDepth depth = DataType::depth; static const ElemType type = CV_MAKETYPE(depth, channels); #endif }; namespace traits { template -struct Depth< Matx<_Tp, m, n> > { static const ElemType value = Depth<_Tp>::value; }; +struct Depth< Matx<_Tp, m, n> > { static const ElemDepth value = Depth<_Tp>::value; }; template struct Type< Matx<_Tp, m, n> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, n*m); }; } // namespace @@ -332,7 +332,7 @@ template class Vec : public Matx<_Tp, cn, 1> typedef _Tp value_type; static const int channels = cn; #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - static const ElemType depth = Matx<_Tp, cn, 1>::depth; + static const ElemDepth depth = Matx<_Tp, cn, 1>::depth; static const ElemType type = CV_MAKETYPE(depth, channels); #endif @@ -431,14 +431,14 @@ template class DataType< Vec<_Tp, cn> > static const int channels = cn; static const int fmt = DataType::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - static const ElemType depth = DataType::depth; + static const ElemDepth depth = DataType::depth; static const ElemType type = CV_MAKETYPE(depth, channels); #endif }; namespace traits { template -struct Depth< Vec<_Tp, cn> > { static const ElemType value = Depth<_Tp>::value; }; +struct Depth< Vec<_Tp, cn> > { static const ElemDepth value = Depth<_Tp>::value; }; template struct Type< Vec<_Tp, cn> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, cn); }; } // namespace diff --git a/modules/core/include/opencv2/core/ocl.hpp b/modules/core/include/opencv2/core/ocl.hpp index f970ebe8ca7b..60d3e52cc3d0 100644 --- a/modules/core/include/opencv2/core/ocl.hpp +++ b/modules/core/include/opencv2/core/ocl.hpp @@ -735,14 +735,14 @@ class CV_EXPORTS PlatformInfo Impl* p; }; -CV_EXPORTS const char* convertTypeStr(ElemType sdepth, ElemType ddepth, int cn, char* buf); +CV_EXPORTS const char* convertTypeStr(ElemDepth sdepth, ElemDepth ddepth, int cn, char* buf); #ifdef CV_TYPE_COMPATIBLE_API # ifndef OPENCV_DISABLE_DEPRECATED_WARNING_INT_ELEMTYPE_OVERLOAD -CV_DEPRECATED_MSG(CV_DEPRECATED_PARAM(int, stype, ElemType, sdepth) ". Similarly, " CV_DEPRECATED_PARAM(int, dtype, ElemType, ddepth)) +CV_DEPRECATED_MSG(CV_DEPRECATED_PARAM(int, stype, ElemDepth, sdepth) ". Similarly, " CV_DEPRECATED_PARAM(int, dtype, ElemDepth, ddepth)) # endif static inline const char* convertTypeStr(int sdepth, int ddepth, int cn, char* buf) { - return convertTypeStr(static_cast(sdepth), static_cast(ddepth), cn, buf); + return convertTypeStr(static_cast(sdepth), static_cast(ddepth), cn, buf); } #endif // CV_TYPE_COMPATIBLE_API CV_EXPORTS const char* typeToStr(int t); @@ -750,12 +750,12 @@ CV_EXPORTS const char* memopTypeToStr(int t); CV_EXPORTS const char* vecopTypeToStr(int t); CV_EXPORTS const char* getOpenCLErrorString(int errorCode); -CV_EXPORTS String kernelToStr(InputArray _kernel, ElemType ddepth = CV_TYPE_AUTO, const char * name = NULL); +CV_EXPORTS String kernelToStr(InputArray _kernel, ElemDepth ddepth = CV_DEPTH_AUTO, const char * name = NULL); #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) static inline String kernelToStr(InputArray _kernel, int ddepth, const char * name = NULL) { - return kernelToStr(_kernel, static_cast(ddepth), name); + return kernelToStr(_kernel, static_cast(ddepth), name); } #endif // CV_TYPE_COMPATIBLE_API CV_EXPORTS void getPlatfomsInfo(std::vector& platform_info); @@ -815,12 +815,12 @@ class CV_EXPORTS Image2D /** Indicates if the image format is supported. */ - static bool isFormatSupported(ElemType depth, int cn, bool norm); + static bool isFormatSupported(ElemDepth depth, int cn, bool norm); #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) static inline bool isFormatSupported(int depth, int cn, bool norm) { - return isFormatSupported(static_cast(depth), cn, norm); + return isFormatSupported(static_cast(depth), cn, norm); } #endif // CV_TYPE_COMPATIBLE_API diff --git a/modules/core/include/opencv2/core/opengl.hpp b/modules/core/include/opencv2/core/opengl.hpp index 65a503615ebb..d404fb9946cc 100644 --- a/modules/core/include/opencv2/core/opengl.hpp +++ b/modules/core/include/opencv2/core/opengl.hpp @@ -303,7 +303,7 @@ class CV_EXPORTS Buffer bool empty() const; ElemType type() const; - ElemType depth() const; + ElemDepth depth() const; int channels() const; int elemSize() const; int elemSize1() const; @@ -416,12 +416,12 @@ class CV_EXPORTS Texture2D @param ddepth Destination depth. @param autoRelease Auto release mode for destination buffer (if arr is OpenGL buffer or texture). */ - void copyTo(OutputArray arr, ElemType ddepth = CV_32F, bool autoRelease = false) const; + void copyTo(OutputArray arr, ElemDepth ddepth = CV_32F, bool autoRelease = false) const; #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) inline void copyTo(OutputArray arr, int ddepth, bool autoRelease = false) const { - copyTo(arr, static_cast(ddepth), autoRelease ); + copyTo(arr, static_cast(ddepth), autoRelease ); } #endif // CV_TYPE_COMPATIBLE_API @@ -681,7 +681,7 @@ ElemType cv::ogl::Buffer::type() const } inline -ElemType cv::ogl::Buffer::depth() const +ElemDepth cv::ogl::Buffer::depth() const { return CV_MAT_DEPTH(type_); } diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index 6481fb953445..6754165d9c37 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -267,14 +267,14 @@ CV_MAT_AUG_OPERATOR_T(-=, cv::subtract(a,b,a), Mat_<_Tp>, Mat_<_Tp>) CV_MAT_AUG_OPERATOR (*=, cv::gemm(a, b, 1, Mat(), 0, a, 0), Mat, Mat) CV_MAT_AUG_OPERATOR_T(*=, cv::gemm(a, b, 1, Mat(), 0, a, 0), Mat_<_Tp>, Mat) CV_MAT_AUG_OPERATOR_T(*=, cv::gemm(a, b, 1, Mat(), 0, a, 0), Mat_<_Tp>, Mat_<_Tp>) -CV_MAT_AUG_OPERATOR (*=, a.convertTo(a, CV_TYPE_AUTO, b), Mat, double) -CV_MAT_AUG_OPERATOR_T(*= , a.convertTo(a, CV_TYPE_AUTO, b), Mat_<_Tp>, double) +CV_MAT_AUG_OPERATOR (*=, a.convertTo(a, CV_DEPTH_AUTO, b), Mat, double) +CV_MAT_AUG_OPERATOR_T(*= , a.convertTo(a, CV_DEPTH_AUTO, b), Mat_<_Tp>, double) CV_MAT_AUG_OPERATOR (/=, cv::divide(a,b,a), Mat, Mat) CV_MAT_AUG_OPERATOR_T(/=, cv::divide(a,b,a), Mat_<_Tp>, Mat) CV_MAT_AUG_OPERATOR_T(/=, cv::divide(a,b,a), Mat_<_Tp>, Mat_<_Tp>) -CV_MAT_AUG_OPERATOR(/= , a.convertTo((Mat&)a, CV_TYPE_AUTO, 1. / b), Mat, double) -CV_MAT_AUG_OPERATOR_T(/= , a.convertTo((Mat&)a, CV_TYPE_AUTO, 1. / b), Mat_<_Tp>, double) +CV_MAT_AUG_OPERATOR(/= , a.convertTo((Mat&)a, CV_DEPTH_AUTO, 1. / b), Mat, double) +CV_MAT_AUG_OPERATOR_T(/= , a.convertTo((Mat&)a, CV_DEPTH_AUTO, 1. / b), Mat_<_Tp>, double) CV_MAT_AUG_OPERATOR (&=, cv::bitwise_and(a,b,a), Mat, Mat) CV_MAT_AUG_OPERATOR (&=, cv::bitwise_and(a,b,a), Mat, Scalar) diff --git a/modules/core/include/opencv2/core/private.hpp b/modules/core/include/opencv2/core/private.hpp index f6fe2741674d..f7cdddccc998 100644 --- a/modules/core/include/opencv2/core/private.hpp +++ b/modules/core/include/opencv2/core/private.hpp @@ -313,7 +313,7 @@ static inline IppiMaskSize ippiGetMaskSize(int kx, int ky) (IppiMaskSize)-1; } -static inline IppDataType ippiGetDataType(ElemType depth) +static inline IppDataType ippiGetDataType(ElemDepth depth) { depth = CV_MAT_DEPTH(depth); return depth == CV_8U ? ipp8u : @@ -329,7 +329,7 @@ static inline IppDataType ippiGetDataType(ElemType depth) #ifdef CV_TRANSNATIONAL_API static inline IppDataType ippiGetDataType(int depth) { - return ippiGetDataType(static_cast(depth)); + return ippiGetDataType(static_cast(depth)); } #endif // CV_TRANSNATIONAL_API diff --git a/modules/core/include/opencv2/core/traits.hpp b/modules/core/include/opencv2/core/traits.hpp index 73c0ad33cae7..c3f2f2c6c2e1 100644 --- a/modules/core/include/opencv2/core/traits.hpp +++ b/modules/core/include/opencv2/core/traits.hpp @@ -91,7 +91,7 @@ DataType itself that is used but its specialized versions, such as: typedef _Tp channel_type; // DataDepth is another helper trait class - static const ElemType depth = DataDepth<_Tp>::value; + static const ElemDepth depth = DataDepth<_Tp>::value; static const int channels = 2; static const int fmt = (channels-1)*256 + DataDepth<_Tp>::fmt; static const ElemType type = CV_MAKETYPE(depth, channels); @@ -125,7 +125,7 @@ template class DataType typedef value_type vec_type; static const bool generic_type = true; - static const ElemType depth = CV_TYPE_AUTO; + static const ElemDepth depth = CV_DEPTH_AUTO; static const int channels = 1; static const int fmt = 0; static const ElemType type = CV_MAKETYPE(depth, channels); @@ -141,7 +141,7 @@ template<> class DataType typedef value_type vec_type; static const bool generic_type = false; - static const ElemType depth = CV_8U; + static const ElemDepth depth = CV_8U; static const int channels = 1; static const int fmt = (int)'u'; static const ElemType type = CV_MAKETYPE(depth, channels); @@ -156,7 +156,7 @@ template<> class DataType typedef value_type vec_type; static const bool generic_type = false; - static const ElemType depth = CV_8U; + static const ElemDepth depth = CV_8U; static const int channels = 1; static const int fmt = (int)'u'; static const ElemType type = CV_MAKETYPE(depth, channels); @@ -171,7 +171,7 @@ template<> class DataType typedef value_type vec_type; static const bool generic_type = false; - static const ElemType depth = CV_8S; + static const ElemDepth depth = CV_8S; static const int channels = 1; static const int fmt = (int)'c'; static const ElemType type = CV_MAKETYPE(depth, channels); @@ -186,7 +186,7 @@ template<> class DataType typedef value_type vec_type; static const bool generic_type = false; - static const ElemType depth = CV_8S; + static const ElemDepth depth = CV_8S; static const int channels = 1; static const int fmt = (int)'c'; static const ElemType type = CV_MAKETYPE(depth, channels); @@ -201,7 +201,7 @@ template<> class DataType typedef value_type vec_type; static const bool generic_type = false; - static const ElemType depth = CV_16U; + static const ElemDepth depth = CV_16U; static const int channels = 1; static const int fmt = (int)'w'; static const ElemType type = CV_MAKETYPE(depth, channels); @@ -216,7 +216,7 @@ template<> class DataType typedef value_type vec_type; static const bool generic_type = false; - static const ElemType depth = CV_16S; + static const ElemDepth depth = CV_16S; static const int channels = 1; static const int fmt = (int)'s'; static const ElemType type = CV_MAKETYPE(depth, channels); @@ -231,7 +231,7 @@ template<> class DataType typedef value_type vec_type; static const bool generic_type = false; - static const ElemType depth = CV_32S; + static const ElemDepth depth = CV_32S; static const int channels = 1; static const int fmt = (int)'i'; static const ElemType type = CV_MAKETYPE(depth, channels); @@ -246,7 +246,7 @@ template<> class DataType typedef value_type vec_type; static const bool generic_type = false; - static const ElemType depth = CV_32F; + static const ElemDepth depth = CV_32F; static const int channels = 1; static const int fmt = (int)'f'; static const ElemType type = CV_MAKETYPE(depth, channels); @@ -261,7 +261,7 @@ template<> class DataType typedef value_type vec_type; static const bool generic_type = false; - static const ElemType depth = CV_64F; + static const ElemDepth depth = CV_64F; static const int channels = 1; static const int fmt = (int)'d'; static const ElemType type = CV_MAKETYPE(depth, channels); @@ -290,7 +290,7 @@ DataDepth::value constant. template class DataDepth { public: - static const ElemType value = DataType<_Tp>::depth; + static const ElemDepth value = DataType<_Tp>::depth; static const int fmt = DataType<_Tp>::fmt; }; @@ -382,7 +382,7 @@ CV_CREATE_MEMBER_CHECK(type) template struct Depth -{ static const ElemType value = DataType::depth; }; +{ static const ElemDepth value = DataType::depth; }; template struct Type diff --git a/modules/core/include/opencv2/core/types.hpp b/modules/core/include/opencv2/core/types.hpp index 048100bdedda..61ccd42aaef3 100644 --- a/modules/core/include/opencv2/core/types.hpp +++ b/modules/core/include/opencv2/core/types.hpp @@ -101,7 +101,7 @@ template class DataType< Complex<_Tp> > static const int channels = 2; static const int fmt = DataType::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - static const ElemType depth = DataType::depth; + static const ElemDepth depth = DataType::depth; static const ElemType type = CV_MAKETYPE(depth, channels); #endif @@ -110,7 +110,7 @@ template class DataType< Complex<_Tp> > namespace traits { template -struct Depth< Complex<_Tp> > { static const ElemType value = Depth<_Tp>::value; }; +struct Depth< Complex<_Tp> > { static const ElemDepth value = Depth<_Tp>::value; }; template struct Type< Complex<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 2); }; } // namespace @@ -203,7 +203,7 @@ template class DataType< Point_<_Tp> > static const int channels = 2; static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - static const ElemType depth = DataType::depth; + static const ElemDepth depth = DataType::depth; static const ElemType type = CV_MAKETYPE(depth, channels); #endif @@ -212,7 +212,7 @@ template class DataType< Point_<_Tp> > namespace traits { template -struct Depth< Point_<_Tp> > { static const ElemType value = Depth<_Tp>::value; }; +struct Depth< Point_<_Tp> > { static const ElemDepth value = Depth<_Tp>::value; }; template struct Type< Point_<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 2); }; } // namespace @@ -280,7 +280,7 @@ template class DataType< Point3_<_Tp> > static const int channels = 3; static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - static const ElemType depth = DataType::depth; + static const ElemDepth depth = DataType::depth; static const ElemType type = CV_MAKETYPE(depth, channels); #endif @@ -289,7 +289,7 @@ template class DataType< Point3_<_Tp> > namespace traits { template -struct Depth< Point3_<_Tp> > { static const ElemType value = Depth<_Tp>::value; }; +struct Depth< Point3_<_Tp> > { static const ElemDepth value = Depth<_Tp>::value; }; template struct Type< Point3_<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 3); }; } // namespace @@ -354,7 +354,7 @@ template class DataType< Size_<_Tp> > static const int channels = 2; static const int fmt = DataType::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - static const ElemType depth = DataType::depth; + static const ElemDepth depth = DataType::depth; static const ElemType type = CV_MAKETYPE(depth, channels); #endif @@ -363,7 +363,7 @@ template class DataType< Size_<_Tp> > namespace traits { template -struct Depth< Size_<_Tp> > { static const ElemType value = Depth<_Tp>::value; }; +struct Depth< Size_<_Tp> > { static const ElemDepth value = Depth<_Tp>::value; }; template struct Type< Size_<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 2); }; } // namespace @@ -468,7 +468,7 @@ template class DataType< Rect_<_Tp> > static const int channels = 4; static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - static const ElemType depth = DataType::depth; + static const ElemDepth depth = DataType::depth; static const ElemType type = CV_MAKETYPE(depth, channels); #endif @@ -477,7 +477,7 @@ template class DataType< Rect_<_Tp> > namespace traits { template -struct Depth< Rect_<_Tp> > { static const ElemType value = Depth<_Tp>::value; }; +struct Depth< Rect_<_Tp> > { static const ElemDepth value = Depth<_Tp>::value; }; template struct Type< Rect_<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 4); }; } // namespace @@ -540,7 +540,7 @@ template<> class DataType< RotatedRect > static const int channels = (int)sizeof(value_type) / sizeof(channel_type); // 5 static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - static const ElemType depth = DataType::depth; + static const ElemDepth depth = DataType::depth; static const ElemType type = CV_MAKETYPE(depth, channels); #endif @@ -549,7 +549,7 @@ template<> class DataType< RotatedRect > namespace traits { template<> -struct Depth< RotatedRect > { static const ElemType value = Depth::value; }; +struct Depth< RotatedRect > { static const ElemDepth value = Depth::value; }; template<> struct Type< RotatedRect > { static const ElemType value = CV_MAKETYPE(Depth::value, (int)sizeof(RotatedRect)/sizeof(float)); }; } // namespace @@ -603,7 +603,7 @@ template<> class DataType static const int channels = 2; static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - static const ElemType depth = DataType::depth; + static const ElemDepth depth = DataType::depth; static const ElemType type = CV_MAKETYPE(depth, channels); #endif @@ -612,7 +612,7 @@ template<> class DataType namespace traits { template<> -struct Depth< Range > { static const ElemType value = Depth::value; }; +struct Depth< Range > { static const ElemDepth value = Depth::value; }; template<> struct Type< Range > { static const ElemType value = CV_MAKETYPE(Depth::value, 2); }; } // namespace @@ -672,7 +672,7 @@ template class DataType< Scalar_<_Tp> > static const int channels = 4; static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - static const ElemType depth = DataType::depth; + static const ElemDepth depth = DataType::depth; static const ElemType type = CV_MAKETYPE(depth, channels); #endif @@ -681,7 +681,7 @@ template class DataType< Scalar_<_Tp> > namespace traits { template -struct Depth< Scalar_<_Tp> > { static const ElemType value = Depth<_Tp>::value; }; +struct Depth< Scalar_<_Tp> > { static const ElemDepth value = Depth<_Tp>::value; }; template struct Type< Scalar_<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 4); }; } // namespace @@ -779,7 +779,7 @@ template<> class DataType typedef float channel_type; static const bool generic_type = false; - static const ElemType depth = DataType::depth; + static const ElemDepth depth = DataType::depth; static const int channels = (int)(sizeof(value_type)/sizeof(channel_type)); // 7 static const int fmt = DataType::fmt + ((channels - 1) << 8); static const ElemType type = CV_MAKETYPE(depth, channels); @@ -822,7 +822,7 @@ template<> class DataType typedef int channel_type; static const bool generic_type = false; - static const ElemType depth = DataType::depth; + static const ElemDepth depth = DataType::depth; static const int channels = (int)(sizeof(value_type)/sizeof(channel_type)); // 4 static const int fmt = DataType::fmt + ((channels - 1) << 8); static const ElemType type = CV_MAKETYPE(depth, channels); @@ -953,7 +953,7 @@ template<> class DataType static const int channels = (int)(sizeof(value_type) / sizeof(channel_type)); // 24 static const int fmt = DataType::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - static const ElemType depth = DataType::depth; + static const ElemDepth depth = DataType::depth; static const ElemType type = CV_MAKETYPE(depth, channels); #endif @@ -962,7 +962,7 @@ template<> class DataType namespace traits { template<> -struct Depth< Moments > { static const ElemType value = Depth::value; }; +struct Depth< Moments > { static const ElemDepth value = Depth::value; }; template<> struct Type< Moments > { static const ElemType value = CV_MAKETYPE(Depth::value, (int)(sizeof(Moments)/sizeof(double))); }; } // namespace diff --git a/modules/core/include/opencv2/core/types_c.h b/modules/core/include/opencv2/core/types_c.h index f2e2a70f2de5..c9bde01cdcf4 100644 --- a/modules/core/include/opencv2/core/types_c.h +++ b/modules/core/include/opencv2/core/types_c.h @@ -656,7 +656,7 @@ CV_INLINE void cvmSet( CvMat* mat, int row, int col, double value ) CV_INLINE int cvIplDepth( int type ) { - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); return CV_ELEM_SIZE1(depth)*8 | (depth == CV_8S || depth == CV_16S || depth == CV_32S ? IPL_DEPTH_SIGN : 0); } diff --git a/modules/core/misc/java/src/cpp/core_manual.hpp b/modules/core/misc/java/src/cpp/core_manual.hpp index 2329bd1cbf11..d09d96d206a3 100644 --- a/modules/core/misc/java/src/cpp/core_manual.hpp +++ b/modules/core/misc/java/src/cpp/core_manual.hpp @@ -13,13 +13,13 @@ CV_EXPORTS_W void setErrorVerbosity(bool verbose); namespace cv { -CV_EXPORTS_W void add(InputArray src1, Scalar src2, OutputArray dst, InputArray mask=noArray(), ElemType ddepth = CV_TYPE_AUTO); +CV_EXPORTS_W void add(InputArray src1, Scalar src2, OutputArray dst, InputArray mask=noArray(), ElemDepth ddepth = CV_DEPTH_AUTO); -CV_EXPORTS_W void subtract(InputArray src1, Scalar src2, OutputArray dst, InputArray mask=noArray(), ElemType ddepth = CV_TYPE_AUTO); +CV_EXPORTS_W void subtract(InputArray src1, Scalar src2, OutputArray dst, InputArray mask=noArray(), ElemDepth ddepth = CV_DEPTH_AUTO); -CV_EXPORTS_W void multiply(InputArray src1, Scalar src2, OutputArray dst, double scale=1, ElemType ddepth = CV_TYPE_AUTO); +CV_EXPORTS_W void multiply(InputArray src1, Scalar src2, OutputArray dst, double scale=1, ElemDepth ddepth = CV_DEPTH_AUTO); -CV_EXPORTS_W void divide(InputArray src1, Scalar src2, OutputArray dst, double scale=1, ElemType ddepth = CV_TYPE_AUTO); +CV_EXPORTS_W void divide(InputArray src1, Scalar src2, OutputArray dst, double scale=1, ElemDepth ddepth = CV_DEPTH_AUTO); CV_EXPORTS_W void absdiff(InputArray src1, Scalar src2, OutputArray dst); diff --git a/modules/core/misc/python/pyopencv_core.hpp b/modules/core/misc/python/pyopencv_core.hpp index 28c11ced08b4..60deeffc069b 100644 --- a/modules/core/misc/python/pyopencv_core.hpp +++ b/modules/core/misc/python/pyopencv_core.hpp @@ -5,6 +5,9 @@ #ifdef CV_TYPE_SAFE_API CV_PY_FROM_ENUM(ElemType); CV_PY_TO_ENUM(ElemType); + +CV_PY_FROM_ENUM(ElemDepth); +CV_PY_TO_ENUM(ElemDepth); #endif #endif diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp index db00ca789674..1673371fd14f 100644 --- a/modules/core/src/arithm.cpp +++ b/modules/core/src/arithm.cpp @@ -91,7 +91,7 @@ static bool ocl_binary_op(InputArray _src1, InputArray _src2, OutputArray _dst, { bool haveMask = !_mask.empty(); int srctype = _src1.type(); - ElemType srcdepth = CV_MAT_DEPTH(srctype); + ElemDepth srcdepth = CV_MAT_DEPTH(srctype); int cn = CV_MAT_CN(srctype); const ocl::Device d = ocl::Device::getDefault(); @@ -169,10 +169,10 @@ static void binary_op( InputArray _src1, InputArray _src2, OutputArray _dst, const _InputArray *psrc1 = &_src1, *psrc2 = &_src2; _InputArray::KindFlag kind1 = psrc1->kind(), kind2 = psrc2->kind(); ElemType type1 = psrc1->type(); - ElemType depth1 = CV_MAT_DEPTH(type1); + ElemDepth depth1 = CV_MAT_DEPTH(type1); int cn = CV_MAT_CN(type1); ElemType type2 = psrc2->type(); - ElemType depth2 = CV_MAT_DEPTH(type2); + ElemDepth depth2 = CV_MAT_DEPTH(type2); int cn2 = CV_MAT_CN(type2); int dims1 = psrc1->dims(), dims2 = psrc2->dims(); Size sz1 = dims1 <= 2 ? psrc1->size() : Size(); @@ -457,7 +457,7 @@ void cv::min(const UMat& src1, const UMat& src2, UMat& dst) namespace cv { -static ElemType actualScalarDepth(const double* data, int len) +static ElemDepth actualScalarDepth(const double* data, int len) { int i = 0, minval = INT_MAX, maxval = INT_MIN; for(; i < len; ++i) @@ -486,7 +486,7 @@ static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, const ocl::Device d = ocl::Device::getDefault(); bool doubleSupport = d.doubleFPConfig() > 0; ElemType type1 = _src1.type(); - ElemType depth1 = CV_MAT_DEPTH(type1); + ElemDepth depth1 = CV_MAT_DEPTH(type1); int cn = CV_MAT_CN(type1); bool haveMask = !_mask.empty(); @@ -494,14 +494,14 @@ static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, return false; ElemType dtype = _dst.type(); - ElemType ddepth = CV_MAT_DEPTH(dtype); - ElemType wdepth = CV_MAX_DEPTH(CV_32S, CV_MAT_DEPTH(wtype)); + ElemDepth ddepth = CV_MAT_DEPTH(dtype); + ElemDepth wdepth = CV_MAX_DEPTH(CV_32S, CV_MAT_DEPTH(wtype)); if (!doubleSupport) wdepth = CV_MIN_DEPTH(wdepth, CV_32F); wtype = CV_MAKETYPE(wdepth, cn); ElemType type2 = haveScalar ? wtype : _src2.type(); - ElemType depth2 = CV_MAT_DEPTH(type2); + ElemDepth depth2 = CV_MAT_DEPTH(type2); if (!doubleSupport && (depth2 == CV_64F || depth1 == CV_64F)) return false; @@ -605,7 +605,7 @@ static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, #endif static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, - InputArray _mask, ElemType ddepth, BinaryFuncC* tab, bool muldiv=false, + InputArray _mask, ElemDepth ddepth, BinaryFuncC* tab, bool muldiv=false, void* usrdata=0, int oclop=-1 ) { const _InputArray *psrc1 = &_src1, *psrc2 = &_src2; @@ -613,10 +613,10 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, bool haveMask = !_mask.empty(); bool reallocate = false; ElemType type1 = psrc1->type(); - ElemType depth1 = CV_MAT_DEPTH(type1); + ElemDepth depth1 = CV_MAT_DEPTH(type1); int cn = CV_MAT_CN(type1); ElemType type2 = psrc2->type(); - ElemType depth2 = CV_MAT_DEPTH(type2); + ElemDepth depth2 = CV_MAT_DEPTH(type2); int cn2 = CV_MAT_CN(type2); ElemType wtype; int dims1 = psrc1->dims(), dims2 = psrc2->dims(); @@ -629,7 +629,7 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, bool src2Scalar = checkScalar(*psrc2, type1, kind2, kind1); if( (kind1 == kind2 || cn == 1) && sz1 == sz2 && dims1 <= 2 && dims2 <= 2 && type1 == type2 && - !haveMask && ((!_dst.fixedType() && (ddepth == CV_TYPE_AUTO || ddepth == depth1)) || + !haveMask && ((!_dst.fixedType() && (ddepth == CV_DEPTH_AUTO || ddepth == depth1)) || (_dst.fixedType() && _dst.type() == type1)) && (src1Scalar == src2Scalar) ) { @@ -685,13 +685,13 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, depth2 = CV_64F; } - if (ddepth == CV_TYPE_AUTO && !_dst.fixedType() && !haveScalar && type1 != type2) + if (ddepth == CV_DEPTH_AUTO && !_dst.fixedType() && !haveScalar && type1 != type2) { CV_Error(CV_StsBadArg, "When the input arrays in add/subtract/multiply/divide functions have different types, " "the output array type must be explicitly specified"); } - if (ddepth == CV_TYPE_AUTO) + if (ddepth == CV_DEPTH_AUTO) ddepth = _dst.fixedType() ? _dst.depth() : CV_MAT_DEPTH(type1); ElemType dtype = CV_MAKETYPE(ddepth, 1); @@ -699,15 +699,15 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, wtype = dtype; else if( !muldiv ) { - wtype = depth1 <= CV_8S && depth2 <= CV_8S ? CV_16S : - depth1 <= CV_32S && depth2 <= CV_32S ? CV_32S : CV_MAX_DEPTH(depth1, depth2); - wtype = CV_MAX_DEPTH(wtype, dtype); + wtype = CV_MAKETYPE(depth1 <= CV_8S && depth2 <= CV_8S ? CV_16S : + depth1 <= CV_32S && depth2 <= CV_32S ? CV_32S : CV_MAX_DEPTH(depth1, depth2), 1); + wtype = CV_MAKETYPE(CV_MAX_DEPTH(wtype, dtype), 1); // when the result of addition should be converted to an integer type, // and just one of the input arrays is floating-point, it makes sense to convert that input to integer type before the operation, // instead of converting the other input to floating-point and then converting the operation result back to integers. if( dtype < CV_32F && (depth1 < CV_32F || depth2 < CV_32F) ) - wtype = CV_32S; + wtype = CV_32SC1; } else { @@ -928,7 +928,7 @@ static BinaryFuncC* getAbsDiffTab() } void cv::add( InputArray src1, InputArray src2, OutputArray dst, - InputArray mask, ElemType ddepth ) + InputArray mask, ElemDepth ddepth ) { CV_INSTRUMENT_REGION(); @@ -936,7 +936,7 @@ void cv::add( InputArray src1, InputArray src2, OutputArray dst, } void cv::subtract( InputArray _src1, InputArray _src2, OutputArray _dst, - InputArray mask, ElemType ddepth ) + InputArray mask, ElemDepth ddepth ) { CV_INSTRUMENT_REGION(); @@ -947,7 +947,7 @@ void cv::absdiff( InputArray src1, InputArray src2, OutputArray dst ) { CV_INSTRUMENT_REGION(); - arithm_op(src1, src2, dst, noArray(), CV_TYPE_AUTO, getAbsDiffTab(), false, 0, OCL_OP_ABSDIFF); + arithm_op(src1, src2, dst, noArray(), CV_DEPTH_AUTO, getAbsDiffTab(), false, 0, OCL_OP_ABSDIFF); } /****************************************************************************************\ @@ -996,7 +996,7 @@ static BinaryFuncC* getRecipTab() } void cv::multiply(InputArray src1, InputArray src2, - OutputArray dst, double scale, ElemType ddepth) + OutputArray dst, double scale, ElemDepth ddepth) { CV_INSTRUMENT_REGION(); @@ -1005,7 +1005,7 @@ void cv::multiply(InputArray src1, InputArray src2, } void cv::divide(InputArray src1, InputArray src2, - OutputArray dst, double scale, ElemType ddepth) + OutputArray dst, double scale, ElemDepth ddepth) { CV_INSTRUMENT_REGION(); @@ -1013,7 +1013,7 @@ void cv::divide(InputArray src1, InputArray src2, } void cv::divide(double scale, InputArray src2, - OutputArray dst, ElemType ddepth) + OutputArray dst, ElemDepth ddepth) { CV_INSTRUMENT_REGION(); @@ -1042,7 +1042,7 @@ static BinaryFuncC* getAddWeightedTab() } void cv::addWeighted( InputArray src1, double alpha, InputArray src2, - double beta, double gamma, OutputArray dst, ElemType ddepth ) + double beta, double gamma, OutputArray dst, ElemDepth ddepth ) { CV_INSTRUMENT_REGION(); @@ -1058,7 +1058,7 @@ void cv::addWeighted( InputArray src1, double alpha, InputArray src2, namespace cv { -static BinaryFuncC getCmpFunc(ElemType depth) +static BinaryFuncC getCmpFunc(ElemDepth depth) { static BinaryFuncC cmpTab[] = { @@ -1072,13 +1072,13 @@ static BinaryFuncC getCmpFunc(ElemType depth) return cmpTab[depth]; } -static double getMinVal(ElemType depth) +static double getMinVal(ElemDepth depth) { static const double tab[] = {0, -128, 0, -32768, INT_MIN, -FLT_MAX, -DBL_MAX, 0}; return tab[depth]; } -static double getMaxVal(ElemType depth) +static double getMaxVal(ElemDepth depth) { static const double tab[] = {255, 127, 65535, 32767, INT_MAX, FLT_MAX, DBL_MAX, 0}; return tab[depth]; @@ -1091,10 +1091,10 @@ static bool ocl_compare(InputArray _src1, InputArray _src2, OutputArray _dst, in const ocl::Device& dev = ocl::Device::getDefault(); bool doubleSupport = dev.doubleFPConfig() > 0; int type1 = _src1.type(); - ElemType depth1 = CV_MAT_DEPTH(type1); + ElemDepth depth1 = CV_MAT_DEPTH(type1); int cn = CV_MAT_CN(type1); ElemType type2 = _src2.type(); - ElemType depth2 = CV_MAT_DEPTH(type2); + ElemDepth depth2 = CV_MAT_DEPTH(type2); if (!doubleSupport && depth1 == CV_64F) return false; @@ -1240,7 +1240,7 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op) } int cn = src1.channels(); - ElemType depth1 = src1.depth(), depth2 = src2.depth(); + ElemDepth depth1 = src1.depth(), depth2 = src2.depth(); _dst.create(src1.dims, src1.size, CV_8UC(cn)); src1 = src1.reshape(1); src2 = src2.reshape(1); @@ -1582,7 +1582,7 @@ static void inRangeReduce(const uchar* src, uchar* dst, size_t len, int cn) typedef void (*InRangeFunc)( const uchar* src1, size_t step1, const uchar* src2, size_t step2, const uchar* src3, size_t step3, uchar* dst, size_t step, Size sz ); -static InRangeFunc getInRangeFunc(ElemType depth) +static InRangeFunc getInRangeFunc(ElemDepth depth) { static InRangeFunc inRangeTab[] = { @@ -1603,7 +1603,7 @@ static bool ocl_inRange( InputArray _src, InputArray _lowerb, _InputArray::KindFlag skind = _src.kind(), lkind = _lowerb.kind(), ukind = _upperb.kind(); Size ssize = _src.size(), lsize = _lowerb.size(), usize = _upperb.size(); ElemType stype = _src.type(), ltype = _lowerb.type(), utype = _upperb.type(); - ElemType sdepth = CV_MAT_DEPTH(stype), ldepth = CV_MAT_DEPTH(ltype), udepth = CV_MAT_DEPTH(utype); + ElemDepth sdepth = CV_MAT_DEPTH(stype), ldepth = CV_MAT_DEPTH(ltype), udepth = CV_MAT_DEPTH(utype); int cn = CV_MAT_CN(stype), rowsPerWI = d.isIntel() ? 4 : 1; bool lbScalar = false, ubScalar = false; @@ -1682,8 +1682,8 @@ static bool ocl_inRange( InputArray _src, InputArray _lowerb, uscalar = Mat(cn, 1, CV_32S, iubuf); } - lscalar.convertTo(lscalar, stype); - uscalar.convertTo(uscalar, stype); + lscalar.convertTo(lscalar, sdepth); + uscalar.convertTo(uscalar, sdepth); } else { @@ -1751,7 +1751,7 @@ void cv::inRange(InputArray _src, InputArray _lowerb, CV_Assert(lbScalar == ubScalar); int cn = src.channels(); - ElemType depth = src.depth(); + ElemDepth depth = src.depth(); size_t esz = src.elemSize(); size_t blocksize0 = (size_t)(BLOCK_SIZE + esz-1)/esz; @@ -1777,7 +1777,7 @@ void cv::inRange(InputArray _src, InputArray _lowerb, ubuf = buf = alignPtr(buf + blocksize*esz, 16); CV_Assert( lb.type() == ub.type() ); - ElemType scdepth = lb.depth(); + ElemDepth scdepth = lb.depth(); if( scdepth != depth && depth < CV_32S ) { diff --git a/modules/core/src/array.cpp b/modules/core/src/array.cpp index 70424d8a78af..66c35e3db3fb 100644 --- a/modules/core/src/array.cpp +++ b/modules/core/src/array.cpp @@ -1457,7 +1457,7 @@ cvScalarToRawData(const CvScalar* scalar, void* data, int type, int extend_to_12 { type = CV_MAT_TYPE(type); int cn = CV_MAT_CN( type ); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); assert( scalar && data ); if( (unsigned)(cn - 1) >= 4 ) @@ -1601,7 +1601,7 @@ static double icvGetReal( const void* data, int type ) static void icvSetReal(double value, const void* data, int _depth) { - ElemType depth = static_cast(_depth); + ElemDepth depth = static_cast(_depth); switch (depth) { case CV_8U: @@ -2797,7 +2797,7 @@ cvGetImage( const CvArr* array, IplImage* img ) if( mat->data.ptr == 0 ) CV_Error( CV_StsNullPtr, "" ); - ElemType depth = static_cast(cvIplDepth(mat->type)); + ElemDepth depth = static_cast(cvIplDepth(mat->type)); cvInitImageHeader( img, cvSize(mat->cols, mat->rows), depth, CV_MAT_CN(mat->type) ); @@ -3221,7 +3221,7 @@ void scalarToRawData(const Scalar& s, void* _buf, int type, int unroll_to) { CV_INSTRUMENT_REGION(); - const ElemType depth = CV_MAT_DEPTH(type); + const ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type); CV_Assert(cn <= 4); switch(depth) diff --git a/modules/core/src/batch_distance.cpp b/modules/core/src/batch_distance.cpp index 02ac0c0ce923..209807a5dcaa 100644 --- a/modules/core/src/batch_distance.cpp +++ b/modules/core/src/batch_distance.cpp @@ -263,7 +263,7 @@ struct BatchDistInvoker : public ParallelLoopBody } void cv::batchDistance( InputArray _src1, InputArray _src2, - OutputArray _dist, ElemType dtype, OutputArray _nidx, + OutputArray _dist, ElemDepth ddepth, OutputArray _nidx, int normType, int K, InputArray _mask, int update, bool crosscheck ) { @@ -275,15 +275,15 @@ void cv::batchDistance( InputArray _src1, InputArray _src2, (type == CV_32F || type == CV_8U)); CV_Assert( _nidx.needed() == (K > 0) ); - if( dtype == -1 ) + if( ddepth == CV_DEPTH_AUTO ) { - dtype = normType == NORM_HAMMING || normType == NORM_HAMMING2 ? CV_32S : CV_32F; + ddepth = normType == NORM_HAMMING || normType == NORM_HAMMING2 ? CV_32S : CV_32F; } - CV_Assert( (type == CV_8U && dtype == CV_32S) || dtype == CV_32F); + CV_Assert((type == CV_8U && ddepth == CV_32S) || ddepth == CV_32F); K = std::min(K, src2.rows); - _dist.create(src1.rows, (K > 0 ? K : src2.rows), dtype); + _dist.create(src1.rows, (K > 0 ? K : src2.rows), ddepth); Mat dist = _dist.getMat(), nidx; if( _nidx.needed() ) { @@ -293,7 +293,7 @@ void cv::batchDistance( InputArray _src1, InputArray _src2, if( update == 0 && K > 0 ) { - dist = Scalar::all(dtype == CV_32S ? (double)INT_MAX : (double)FLT_MAX); + dist = Scalar::all(ddepth == CV_32S ? (double)INT_MAX : (double)FLT_MAX); nidx = Scalar::all(-1); } @@ -302,7 +302,7 @@ void cv::batchDistance( InputArray _src1, InputArray _src2, CV_Assert( K == 1 && update == 0 && mask.empty() ); CV_Assert(!nidx.empty()); Mat tdist, tidx; - batchDistance(src2, src1, tdist, dtype, tidx, normType, K, mask, 0, false); + batchDistance(src2, src1, tdist, ddepth, tidx, normType, K, mask, 0, false); // if an idx-th element from src1 appeared to be the nearest to i-th element of src2, // we update the minimum mutual distance between idx-th element of src1 and the whole src2 set. @@ -310,7 +310,7 @@ void cv::batchDistance( InputArray _src1, InputArray _src2, // to i*-th element of src2 and i*-th element of src2 is the closest to idx-th element of src1. // If nidx[idx] = -1, it means that there is no such ideal couple for it in src2. // This O(N) procedure is called cross-check and it helps to eliminate some false matches. - if( dtype == CV_32S ) + if (ddepth == CV_32S) { for( int i = 0; i < tdist.rows; i++ ) { @@ -342,22 +342,22 @@ void cv::batchDistance( InputArray _src1, InputArray _src2, BatchDistFunc func = 0; if( type == CV_8U ) { - if( normType == NORM_L1 && dtype == CV_32S ) + if (normType == NORM_L1 && ddepth == CV_32S) func = (BatchDistFunc)batchDistL1_8u32s; - else if( normType == NORM_L1 && dtype == CV_32F ) + else if (normType == NORM_L1 && ddepth == CV_32F) func = (BatchDistFunc)batchDistL1_8u32f; - else if( normType == NORM_L2SQR && dtype == CV_32S ) + else if (normType == NORM_L2SQR && ddepth == CV_32S) func = (BatchDistFunc)batchDistL2Sqr_8u32s; - else if( normType == NORM_L2SQR && dtype == CV_32F ) + else if (normType == NORM_L2SQR && ddepth == CV_32F) func = (BatchDistFunc)batchDistL2Sqr_8u32f; - else if( normType == NORM_L2 && dtype == CV_32F ) + else if (normType == NORM_L2 && ddepth == CV_32F) func = (BatchDistFunc)batchDistL2_8u32f; - else if( normType == NORM_HAMMING && dtype == CV_32S ) + else if (normType == NORM_HAMMING && ddepth == CV_32S) func = (BatchDistFunc)batchDistHamming; - else if( normType == NORM_HAMMING2 && dtype == CV_32S ) + else if (normType == NORM_HAMMING2 && ddepth == CV_32S) func = (BatchDistFunc)batchDistHamming2; } - else if( type == CV_32F && dtype == CV_32F ) + else if (type == CV_32F && ddepth == CV_32F) { if( normType == NORM_L1 ) func = (BatchDistFunc)batchDistL1_32f; @@ -369,8 +369,8 @@ void cv::batchDistance( InputArray _src1, InputArray _src2, if( func == 0 ) CV_Error_(CV_StsUnsupportedFormat, - ("The combination of type=%d, dtype=%d and normType=%d is not supported", - type, dtype, normType)); + ("The combination of type=%d, ddepth=%d and normType=%d is not supported", + type, ddepth, normType)); parallel_for_(Range(0, src1.rows), BatchDistInvoker(src1, src2, dist, nidx, K, mask, update, func)); diff --git a/modules/core/src/channels.cpp b/modules/core/src/channels.cpp index 4afad2ecc87b..afc7384349cb 100644 --- a/modules/core/src/channels.cpp +++ b/modules/core/src/channels.cpp @@ -77,7 +77,7 @@ static void mixChannels64s( const int64** src, const int* sdelta, typedef void (*MixChannelsFunc)( const uchar** src, const int* sdelta, uchar** dst, const int* ddelta, int len, int npairs ); -static MixChannelsFunc getMixchFunc(ElemType depth) +static MixChannelsFunc getMixchFunc(ElemDepth depth) { static MixChannelsFunc mixchTab[] = { @@ -101,7 +101,7 @@ void cv::mixChannels( const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts, cons CV_Assert( src && nsrcs > 0 && dst && ndsts > 0 && fromTo && npairs > 0 ); size_t i, j, k, esz1 = dst[0].elemSize1(); - ElemType depth = dst[0].depth(); + ElemDepth depth = dst[0].depth(); AutoBuffer buf((nsrcs + ndsts + 1)*(sizeof(Mat*) + sizeof(uchar*)) + npairs*(sizeof(uchar*)*2 + sizeof(int)*6)); const Mat** arrays = (const Mat**)(uchar*)buf.data(); @@ -210,7 +210,7 @@ static bool ocl_mixChannels(InputArrayOfArrays _src, InputOutputArrayOfArrays _d CV_Assert(nsrc > 0 && ndst > 0); Size size = src[0].size(); - ElemType depth = src[0].depth(); + ElemDepth depth = src[0].depth(); int esz = CV_ELEM_SIZE(depth), rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1; @@ -423,7 +423,7 @@ void cv::extractChannel(InputArray _src, OutputArray _dst, int coi) CV_INSTRUMENT_REGION(); ElemType type = _src.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type); CV_Assert( 0 <= coi && coi < cn ); int ch[] = { coi, 0 }; @@ -453,10 +453,10 @@ void cv::insertChannel(InputArray _src, InputOutputArray _dst, int coi) CV_INSTRUMENT_REGION(); ElemType stype = _src.type(); - ElemType sdepth = CV_MAT_DEPTH(stype); + ElemDepth sdepth = CV_MAT_DEPTH(stype); int scn = CV_MAT_CN(stype); ElemType dtype = _dst.type(); - ElemType ddepth = CV_MAT_DEPTH(dtype); + ElemDepth ddepth = CV_MAT_DEPTH(dtype); int dcn = CV_MAT_CN(dtype); CV_Assert( _src.sameSize(_dst) && sdepth == ddepth ); CV_Assert( 0 <= coi && coi < dcn && scn == 1 ); diff --git a/modules/core/src/check.cpp b/modules/core/src/check.cpp index 11779899a6fc..0c09018a0b2b 100644 --- a/modules/core/src/check.cpp +++ b/modules/core/src/check.cpp @@ -8,7 +8,7 @@ namespace cv { -const char* depthToString(ElemType depth) +const char* depthToString(ElemDepth depth) { const char* s = detail::depthToString_(depth); return s ? s : ""; @@ -41,7 +41,7 @@ static const char* getTestOpMath(unsigned testOp) return testOp < CV__LAST_TEST_OP ? _names[testOp] : "???"; } -const char* depthToString_(ElemType depth) +const char* depthToString_(ElemDepth depth) { static const char* depthNames[] = { "CV_8U", "CV_8S", "CV_16U", "CV_16S", "CV_32S", "CV_32F", "CV_64F", "CV_16F" }; return (depth <= CV_16F && depth >= CV_8U) ? depthNames[depth] : NULL; @@ -49,7 +49,7 @@ const char* depthToString_(ElemType depth) const cv::String typeToString_(ElemType type) { - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type); if (depth >= CV_8U && depth <= CV_16F) return cv::format("%sC%d", depthToString_(depth), cn); @@ -69,7 +69,7 @@ void check_failed_auto_(const T& v1, const T& v2, const CheckContext& ctx) ss << " '" << ctx.p2_str << "' is " << v2; cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line); } -void check_failed_MatDepth(const ElemType v1, const ElemType v2, const CheckContext& ctx) +void check_failed_MatDepth(const ElemDepth v1, const ElemDepth v2, const CheckContext& ctx) { std::stringstream ss; ss << ctx.message << " (expected: '" << ctx.p1_str << " " << getTestOpMath(ctx.testOp) << " " << ctx.p2_str << "'), where" << std::endl @@ -125,7 +125,7 @@ void check_failed_auto_(const T& v, const CheckContext& ctx) << " '" << ctx.p1_str << "' is " << v; cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line); } -void check_failed_MatDepth(const ElemType v, const CheckContext& ctx) +void check_failed_MatDepth(const ElemDepth v, const CheckContext& ctx) { std::stringstream ss; ss << ctx.message << ":" << std::endl diff --git a/modules/core/src/convert.cpp b/modules/core/src/convert.cpp index 593ee92ffaf1..010d9aa0fe57 100644 --- a/modules/core/src/convert.cpp +++ b/modules/core/src/convert.cpp @@ -332,7 +332,7 @@ DEF_CVT_FUNC(32f64f, float, double) DEF_CPY_FUNC(64s, int64) */ -BinaryFunc getConvertFunc(ElemType sdepth, ElemType ddepth) +BinaryFunc getConvertFunc(ElemDepth sdepth, ElemDepth ddepth) { static BinaryFunc cvtTab[][8] = { @@ -380,7 +380,7 @@ BinaryFunc getConvertFunc(ElemType sdepth, ElemType ddepth) } #ifdef HAVE_OPENCL -static bool ocl_convertFp16(InputArray _src, OutputArray _dst, ElemType sdepth, ElemType ddepth) +static bool ocl_convertFp16(InputArray _src, OutputArray _dst, ElemDepth sdepth, ElemDepth ddepth) { int type = _src.type(), cn = CV_MAT_CN(type); @@ -411,7 +411,7 @@ static bool ocl_convertFp16(InputArray _src, OutputArray _dst, ElemType sdepth, } // cv:: -void cv::Mat::convertTo(OutputArray _dst, ElemType ddepth, double alpha, double beta) const +void cv::Mat::convertTo(OutputArray _dst, ElemDepth ddepth, double alpha, double beta) const { CV_INSTRUMENT_REGION(); @@ -424,12 +424,12 @@ void cv::Mat::convertTo(OutputArray _dst, ElemType ddepth, double alpha, double bool noScale = fabs(alpha-1) < DBL_EPSILON && fabs(beta) < DBL_EPSILON; int cn = channels(); - if (ddepth == CV_TYPE_AUTO) + if (ddepth == CV_DEPTH_AUTO) ddepth = _dst.fixedType() ? _dst.depth() : depth(); ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ ElemType dtype = CV_MAKETYPE(ddepth, cn); - ElemType sdepth = depth(); + ElemDepth sdepth = depth(); if( sdepth == ddepth && noScale ) { copyTo(_dst); @@ -471,7 +471,7 @@ void cv::convertFp16( InputArray _src, OutputArray _dst ) { CV_INSTRUMENT_REGION(); - ElemType sdepth = _src.depth(), ddepth = CV_8U; + ElemDepth sdepth = _src.depth(), ddepth = CV_8U; BinaryFunc func = 0; switch( sdepth ) diff --git a/modules/core/src/convert_c.cpp b/modules/core/src/convert_c.cpp index 5d0770a0c702..656e55912ff1 100644 --- a/modules/core/src/convert_c.cpp +++ b/modules/core/src/convert_c.cpp @@ -110,7 +110,7 @@ cvConvertScale( const void* srcarr, void* dstarr, cv::Mat src = cv::cvarrToMat(srcarr), dst = cv::cvarrToMat(dstarr); CV_Assert( src.size == dst.size && src.channels() == dst.channels() ); - src.convertTo(dst, dst.type(), scale, shift); + src.convertTo(dst, dst.depth(), scale, shift); } diff --git a/modules/core/src/convert_scale.cpp b/modules/core/src/convert_scale.cpp index 485e7e2e9ad7..7fcc5ceb1b8b 100644 --- a/modules/core/src/convert_scale.cpp +++ b/modules/core/src/convert_scale.cpp @@ -287,7 +287,7 @@ DEF_CVT_SCALE_FUNC(32f16f, cvt1_32f, float, float16_t, float) DEF_CVT_SCALE_FUNC(64f16f, cvt_64f, double, float16_t, double) DEF_CVT_SCALE_FUNC(16f, cvt1_32f, float16_t, float16_t, float) -static BinaryFunc getCvtScaleAbsFunc(ElemType depth) +static BinaryFunc getCvtScaleAbsFunc(ElemDepth depth) { static BinaryFunc cvtScaleAbsTab[] = { @@ -299,7 +299,7 @@ static BinaryFunc getCvtScaleAbsFunc(ElemType depth) return cvtScaleAbsTab[depth]; } -BinaryFunc getConvertScaleFunc(ElemType sdepth, ElemType ddepth) +BinaryFunc getConvertScaleFunc(ElemDepth sdepth, ElemDepth ddepth) { static BinaryFunc cvtScaleTab[][8] = { @@ -355,7 +355,7 @@ static bool ocl_convertScaleAbs( InputArray _src, OutputArray _dst, double alpha const ocl::Device & d = ocl::Device::getDefault(); ElemType type = _src.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type); bool doubleSupport = d.doubleFPConfig() > 0; if (!doubleSupport && depth == CV_64F) @@ -376,7 +376,7 @@ static bool ocl_convertScaleAbs( InputArray _src, OutputArray _dst, double alpha int rowsPerWI = d.isIntel() ? 4 : 1; char cvt[2][50]; - ElemType wdepth = CV_MAX_DEPTH(depth, CV_32F); + ElemDepth wdepth = CV_MAX_DEPTH(depth, CV_32F); String build_opt = format("-D OP_CONVERT_SCALE_ABS -D UNARY_OP -D dstT=%s -D srcT1=%s" " -D workT=%s -D wdepth=%d -D convertToWT1=%s -D convertToDT=%s" " -D workT1=%s -D rowsPerWI=%d%s", @@ -449,7 +449,7 @@ namespace cv { #ifdef HAVE_OPENCL -static bool ocl_normalize( InputArray _src, InputOutputArray _dst, InputArray _mask, ElemType ddepth, +static bool ocl_normalize( InputArray _src, InputOutputArray _dst, InputArray _mask, ElemDepth ddepth, double scale, double delta ) { UMat src = _src.getUMat(); @@ -461,9 +461,9 @@ static bool ocl_normalize( InputArray _src, InputOutputArray _dst, InputArray _m const ocl::Device & dev = ocl::Device::getDefault(); ElemType stype = _src.type(); - ElemType sdepth = CV_MAT_DEPTH(stype); + ElemDepth sdepth = CV_MAT_DEPTH(stype); int cn = CV_MAT_CN(stype); - ElemType wdepth = CV_MAX_DEPTH(CV_32F, sdepth, ddepth); + ElemDepth wdepth = CV_MAX_DEPTH(CV_32F, sdepth, ddepth); int rowsPerWI = dev.isIntel() ? 4 : 1; float fscale = static_cast(scale), fdelta = static_cast(delta); @@ -541,15 +541,15 @@ static bool ocl_normalize( InputArray _src, InputOutputArray _dst, InputArray _m } // cv:: void cv::normalize( InputArray _src, InputOutputArray _dst, double a, double b, - int norm_type, ElemType ddepth, InputArray _mask ) + int norm_type, ElemDepth ddepth, InputArray _mask ) { CV_INSTRUMENT_REGION(); double scale = 1, shift = 0; ElemType type = _src.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); - if (ddepth == CV_TYPE_AUTO) + if (ddepth == CV_DEPTH_AUTO) ddepth = _dst.fixedType() ? _dst.depth() : depth; if( norm_type == CV_MINMAX ) diff --git a/modules/core/src/copy.cpp b/modules/core/src/copy.cpp index 8ca8c1dfb53e..4bf062251676 100644 --- a/modules/core/src/copy.cpp +++ b/modules/core/src/copy.cpp @@ -657,7 +657,7 @@ static bool ocl_flip(InputArray _src, OutputArray _dst, int flipCode ) const ocl::Device & dev = ocl::Device::getDefault(); ElemType type = _src.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type), flipType, kercn = std::min(ocl::predictOptimalVectorWidth(_src, _dst), 4); @@ -843,7 +843,7 @@ static bool ocl_repeat(InputArray _src, int ny, int nx, OutputArray _dst) } ElemType type = _src.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type), rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1, kercn = ocl::predictOptimalVectorWidth(_src, _dst); @@ -1090,7 +1090,7 @@ static bool ocl_copyMakeBorder( InputArray _src, OutputArray _dst, int top, int { ElemType type = _src.type(); int cn = CV_MAT_CN(type); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1; bool isolated = (borderType & BORDER_ISOLATED) != 0; borderType &= ~cv::BORDER_ISOLATED; diff --git a/modules/core/src/count_non_zero.cpp b/modules/core/src/count_non_zero.cpp index 68a5e5abf17f..6191d3693fbb 100644 --- a/modules/core/src/count_non_zero.cpp +++ b/modules/core/src/count_non_zero.cpp @@ -177,7 +177,7 @@ static int countNonZero64f( const double* src, int len ) typedef int (*CountNonZeroFunc)(const uchar*, int); -static CountNonZeroFunc getCountNonZeroTab(ElemType depth) +static CountNonZeroFunc getCountNonZeroTab(ElemDepth depth) { static CountNonZeroFunc countNonZeroTab[] = { @@ -195,7 +195,7 @@ static CountNonZeroFunc getCountNonZeroTab(ElemType depth) static bool ocl_countNonZero( InputArray _src, int & res ) { ElemType type = _src.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int kercn = ocl::predictOptimalVectorWidth(_src); bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; @@ -243,7 +243,7 @@ static bool ipp_countNonZero( Mat &src, int &res ) #endif Ipp32s count = 0; - ElemType depth = src.depth(); + ElemDepth depth = src.depth(); if(src.dims <= 2) { @@ -334,7 +334,7 @@ void cv::findNonZero( InputArray _src, OutputArray _idx ) Mat src = _src.getMat(); CV_Assert( src.channels() == 1 && src.dims == 2 ); - ElemType depth = src.depth(); + ElemDepth depth = src.depth(); std::vector idxvec; int rows = src.rows, cols = src.cols; AutoBuffer buf_(cols + 1); diff --git a/modules/core/src/cuda/gpu_mat.cu b/modules/core/src/cuda/gpu_mat.cu index a1f87744ad3d..a64b13e78e74 100644 --- a/modules/core/src/cuda/gpu_mat.cu +++ b/modules/core/src/cuda/gpu_mat.cu @@ -523,14 +523,14 @@ namespace } } -void cv::cuda::GpuMat::convertTo(OutputArray _dst, ElemType ddepth, Stream& stream) const +void cv::cuda::GpuMat::convertTo(OutputArray _dst, ElemDepth ddepth, Stream& stream) const { - if (ddepth == CV_TYPE_AUTO) + if (ddepth == CV_DEPTH_AUTO) ddepth = _dst.fixedType() ? _dst.depth() : depth(); ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ ElemType dtype = CV_MAKETYPE(ddepth, channels()); - const ElemType sdepth = depth(); + const ElemDepth sdepth = depth(); if (sdepth == ddepth) { if (stream) @@ -563,14 +563,14 @@ void cv::cuda::GpuMat::convertTo(OutputArray _dst, ElemType ddepth, Stream& stre funcs[sdepth][ddepth](reshape(1), dst.reshape(1), stream); } -void cv::cuda::GpuMat::convertTo(OutputArray _dst, ElemType ddepth, double alpha, double beta, Stream& stream) const +void cv::cuda::GpuMat::convertTo(OutputArray _dst, ElemDepth ddepth, double alpha, double beta, Stream& stream) const { - if (ddepth == CV_TYPE_AUTO) + if (ddepth == CV_DEPTH_AUTO) ddepth = _dst.fixedType() ? _dst.depth() : depth(); ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ ElemType dtype = CV_MAKETYPE(ddepth, channels()); - const ElemType sdepth = depth(); + const ElemDepth sdepth = depth(); GpuMat src = *this; @@ -595,7 +595,7 @@ void cv::cuda::GpuMat::convertTo(OutputArray _dst, ElemType ddepth, double alpha void cv::cuda::convertFp16(InputArray _src, OutputArray _dst, Stream& stream) { GpuMat src = _src.getGpuMat(); - ElemType ddepth = CV_TYPE_AUTO; + ElemDepth ddepth = CV_DEPTH_AUTO; switch(src.depth()) { diff --git a/modules/core/src/cuda_gpu_mat.cpp b/modules/core/src/cuda_gpu_mat.cpp index 93047ccc13f6..b004b43005a7 100644 --- a/modules/core/src/cuda_gpu_mat.cpp +++ b/modules/core/src/cuda_gpu_mat.cpp @@ -494,7 +494,7 @@ GpuMat& cv::cuda::GpuMat::setTo(Scalar s, InputArray _mask, Stream& _stream) throw_no_cuda(); } -void cv::cuda::GpuMat::convertTo(OutputArray _dst, ElemType ddepth, Stream& _stream) const +void cv::cuda::GpuMat::convertTo(OutputArray _dst, ElemDepth ddepth, Stream& _stream) const { CV_UNUSED(_dst); CV_UNUSED(ddepth); @@ -502,7 +502,7 @@ void cv::cuda::GpuMat::convertTo(OutputArray _dst, ElemType ddepth, Stream& _str throw_no_cuda(); } -void cv::cuda::GpuMat::convertTo(OutputArray _dst, ElemType ddepth, double alpha, double beta, Stream& _stream) const +void cv::cuda::GpuMat::convertTo(OutputArray _dst, ElemDepth ddepth, double alpha, double beta, Stream& _stream) const { CV_UNUSED(_dst); CV_UNUSED(ddepth); diff --git a/modules/core/src/downhill_simplex.cpp b/modules/core/src/downhill_simplex.cpp index 425a63a8a777..b86d6a6526f9 100644 --- a/modules/core/src/downhill_simplex.cpp +++ b/modules/core/src/downhill_simplex.cpp @@ -201,7 +201,7 @@ class DownhillSolverImpl CV_FINAL : public DownhillSolver } else { - ElemType x_depth = x_.fixedType() ? x_.depth() : CV_64F; + ElemDepth x_depth = x_.fixedType() ? x_.depth() : CV_64F; simplex.row(0).convertTo(x_, x_depth); } return res; diff --git a/modules/core/src/dxt.cpp b/modules/core/src/dxt.cpp index 7e18d7cdcad6..0b381e604210 100644 --- a/modules/core/src/dxt.cpp +++ b/modules/core/src/dxt.cpp @@ -1885,11 +1885,11 @@ struct OCL_FftPlan String buildOptions; int thread_count; int dft_size; - ElemType dft_depth; + ElemDepth dft_depth; bool status; public: - OCL_FftPlan(int _size, ElemType _depth) : dft_size(_size), dft_depth(_depth), status(true) + OCL_FftPlan(int _size, ElemDepth _depth) : dft_size(_size), dft_depth(_depth), status(true) { CV_Assert( dft_depth == CV_32F || dft_depth == CV_64F ); @@ -2092,7 +2092,7 @@ class OCL_FftPlanCache CV_SINGLETON_LAZY_INIT_REF(OCL_FftPlanCache, new OCL_FftPlanCache()) } - Ptr getFftPlan(int dft_size, ElemType depth) + Ptr getFftPlan(int dft_size, ElemDepth depth) { int key = (dft_size << 16) | (depth & 0xFFFF); std::map >::iterator f = planStorage.find(key); @@ -2124,7 +2124,7 @@ class OCL_FftPlanCache static bool ocl_dft_rows(InputArray _src, OutputArray _dst, int nonzero_rows, int flags, int fftType) { ElemType type = _src.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); Ptr plan = OCL_FftPlanCache::getInstance().getFftPlan(_src.cols(), depth); return plan->enqueueTransform(_src, _dst, nonzero_rows, flags, fftType, true); } @@ -2132,7 +2132,7 @@ static bool ocl_dft_rows(InputArray _src, OutputArray _dst, int nonzero_rows, in static bool ocl_dft_cols(InputArray _src, OutputArray _dst, int nonzero_cols, int flags, int fftType) { ElemType type = _src.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); Ptr plan = OCL_FftPlanCache::getInstance().getFftPlan(_src.rows(), depth); return plan->enqueueTransform(_src, _dst, nonzero_cols, flags, fftType, false); } @@ -2164,7 +2164,7 @@ static bool ocl_dft(InputArray _src, OutputArray _dst, int flags, int nonzero_ro { ElemType type = _src.type(); int cn = CV_MAT_CN(type); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); Size ssize = _src.size(); bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; @@ -2418,7 +2418,7 @@ static void CL_CALLBACK oclCleanupCallback(cl_event e, cl_int, void *p) static bool ocl_dft_amdfft(InputArray _src, OutputArray _dst, int flags) { ElemType type = _src.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type); Size ssize = _src.size(); @@ -2506,7 +2506,7 @@ static void complementComplex(T * ptr, size_t step, int n, int len, int dft_dims } } -static void complementComplexOutput(ElemType depth, uchar * ptr, size_t step, int count, int len, int dft_dims) +static void complementComplexOutput(ElemDepth depth, uchar * ptr, size_t step, int count, int len, int dft_dims) { if( depth == CV_32F ) complementComplex((float*)ptr, step, count, len, dft_dims); @@ -2626,7 +2626,7 @@ class OcvDftImpl CV_FINAL : public hal::DFT2D DftMode mode; int elem_size; int complex_elem_size; - ElemType depth; + ElemDepth depth; bool real_transform; int nonzero_rows; bool isRowTransform; @@ -2662,7 +2662,7 @@ class OcvDftImpl CV_FINAL : public hal::DFT2D dst_channels = 0; } - void init(int _width, int _height, ElemType _depth, int _src_channels, int _dst_channels, int flags, int _nonzero_rows) + void init(int _width, int _height, ElemDepth _depth, int _src_channels, int _dst_channels, int flags, int _nonzero_rows) { bool isComplex = _src_channels != _dst_channels; nonzero_rows = _nonzero_rows; @@ -3062,7 +3062,7 @@ class OcvDftBasicImpl CV_FINAL : public hal::DFT1D { opt.factors = _factors; } - void init(int len, int count, ElemType depth, int flags, bool *needBuffer) + void init(int len, int count, ElemDepth depth, int flags, bool *needBuffer) { int prev_len = opt.n; @@ -3214,7 +3214,7 @@ struct ReplacementDFT1D : public hal::DFT1D bool isInitialized; ReplacementDFT1D() : context(0), isInitialized(false) {} - bool init(int len, int count, ElemType depth, int flags, bool *needBuffer) + bool init(int len, int count, ElemDepth depth, int flags, bool *needBuffer) { int res = cv_hal_dftInit1D(&context, len, count, depth, flags, needBuffer); isInitialized = (res == CV_HAL_ERROR_OK); @@ -3242,7 +3242,7 @@ struct ReplacementDFT2D : public hal::DFT2D bool isInitialized; ReplacementDFT2D() : context(0), isInitialized(false) {} - bool init(int width, int height, ElemType depth, + bool init(int width, int height, ElemDepth depth, int src_channels, int dst_channels, int flags, int nonzero_rows) { @@ -3270,7 +3270,7 @@ namespace hal { //================== 1D ====================== -Ptr DFT1D::create(int len, int count, ElemType depth, int flags, bool *needBuffer) +Ptr DFT1D::create(int len, int count, ElemDepth depth, int flags, bool *needBuffer) { { ReplacementDFT1D *impl = new ReplacementDFT1D(); @@ -3289,7 +3289,7 @@ Ptr DFT1D::create(int len, int count, ElemType depth, int flags, bool *ne //================== 2D ====================== -Ptr DFT2D::create(int width, int height, ElemType depth, +Ptr DFT2D::create(int width, int height, ElemDepth depth, int src_channels, int dst_channels, int flags, int nonzero_rows) { @@ -3336,7 +3336,7 @@ void cv::dft( InputArray _src0, OutputArray _dst, int flags, int nonzero_rows ) Mat src0 = _src0.getMat(), src = src0; bool inv = (flags & DFT_INVERSE) != 0; ElemType type = src.type(); - ElemType depth = src.depth(); + ElemDepth depth = src.depth(); CV_Assert( type == CV_32FC1 || type == CV_32FC2 || type == CV_64FC1 || type == CV_64FC2 ); @@ -3541,7 +3541,7 @@ void cv::mulSpectrums( InputArray _srcA, InputArray _srcB, ocl_mulSpectrums(_srcA, _srcB, _dst, flags, conjB)) Mat srcA = _srcA.getMat(), srcB = _srcB.getMat(); - ElemType depth = srcA.depth(); + ElemDepth depth = srcA.depth(); int cn = srcA.channels(); ElemType type = srcA.type(); size_t rows = srcA.rows, cols = srcA.cols; @@ -4073,9 +4073,9 @@ class OcvDctImpl CV_FINAL : public hal::DCT2D int end_stage; int width; int height; - ElemType depth; + ElemDepth depth; - void init(int _width, int _height, ElemType _depth, int flags) + void init(int _width, int _height, ElemDepth _depth, int flags) { width = _width; height = _height; @@ -4198,7 +4198,7 @@ struct ReplacementDCT2D : public hal::DCT2D bool isInitialized; ReplacementDCT2D() : context(0), isInitialized(false) {} - bool init(int width, int height, ElemType depth, int flags) + bool init(int width, int height, ElemDepth depth, int flags) { int res = hal_ni_dctInit2D(&context, width, height, depth, flags); isInitialized = (res == CV_HAL_ERROR_OK); @@ -4222,7 +4222,7 @@ struct ReplacementDCT2D : public hal::DCT2D namespace hal { -Ptr DCT2D::create(int width, int height, ElemType depth, int flags) +Ptr DCT2D::create(int width, int height, ElemDepth depth, int flags) { { ReplacementDCT2D *impl = new ReplacementDCT2D(); @@ -4248,7 +4248,7 @@ void cv::dct( InputArray _src0, OutputArray _dst, int flags ) Mat src0 = _src0.getMat(), src = src0; ElemType type = src.type(); - ElemType depth = src.depth(); + ElemDepth depth = src.depth(); CV_Assert( type == CV_32FC1 || type == CV_64FC1 ); _dst.create( src.rows, src.cols, type ); diff --git a/modules/core/src/hal_replacement.hpp b/modules/core/src/hal_replacement.hpp index e837ae850aa2..24361fe61087 100644 --- a/modules/core/src/hal_replacement.hpp +++ b/modules/core/src/hal_replacement.hpp @@ -507,7 +507,7 @@ struct cvhalDFT {}; @param flags algorithm options (combination of CV_HAL_DFT_INVERSE, CV_HAL_DFT_SCALE, ...) @param needBuffer pointer to boolean variable, if valid pointer provided, then variable value should be set to true to signal that additional memory buffer is needed for operations */ -inline int hal_ni_dftInit1D(cvhalDFT **context, int len, int count, ElemType depth, int flags, bool *needBuffer) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_dftInit1D(cvhalDFT **context, int len, int count, ElemDepth depth, int flags, bool *needBuffer) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @param context pointer to context storing all necessary data @param src source data @@ -534,7 +534,7 @@ inline int hal_ni_dftFree1D(cvhalDFT *context) { return CV_HAL_ERROR_NOT_IMPLEME @param flags algorithm options (combination of CV_HAL_DFT_INVERSE, ...) @param nonzero_rows number of nonzero rows in image, can be used for optimization */ -inline int hal_ni_dftInit2D(cvhalDFT **context, int width, int height, ElemType depth, int src_channels, int dst_channels, int flags, int nonzero_rows) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_dftInit2D(cvhalDFT **context, int width, int height, ElemDepth depth, int src_channels, int dst_channels, int flags, int nonzero_rows) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @param context pointer to context storing all necessary data @param src_data,src_step source image data and step @@ -558,7 +558,7 @@ inline int hal_ni_dftFree2D(cvhalDFT *context) { return CV_HAL_ERROR_NOT_IMPLEME @param depth image type (CV_32F or CV64F) @param flags algorithm options (combination of CV_HAL_DFT_INVERSE, ...) */ -inline int hal_ni_dctInit2D(cvhalDFT **context, int width, int height, ElemType depth, int flags) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_dctInit2D(cvhalDFT **context, int width, int height, ElemDepth depth, int flags) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @param context pointer to context storing all necessary data @param src_data,src_step source image data and step @@ -721,7 +721,7 @@ inline int hal_ni_gemm64fc(const double* src1, size_t src1_step, const double* s @param minIdx,maxIdx Pointer to the returned minimum and maximum location. @param mask Specified array region. */ -inline int hal_ni_minMaxIdx(const uchar* src_data, size_t src_step, int width, int height, ElemType depth, double* minVal, double* maxVal, +inline int hal_ni_minMaxIdx(const uchar* src_data, size_t src_step, int width, int height, ElemDepth depth, double* minVal, double* maxVal, int* minIdx, int* maxIdx, uchar* mask) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } //! @cond IGNORED diff --git a/modules/core/src/lapack.cpp b/modules/core/src/lapack.cpp index 666f27e2d9cf..e352038409cf 100644 --- a/modules/core/src/lapack.cpp +++ b/modules/core/src/lapack.cpp @@ -1695,7 +1695,7 @@ cvEigenVV( CvArr* srcarr, CvArr* evectsarr, CvArr* evalsarr, double, if( evects0.data != evects.data ) { const uchar* p = evects0.ptr(); - evects.convertTo(evects0, evects0.type()); + evects.convertTo(evects0, evects0.depth()); CV_Assert( p == evects0.ptr() ); } } @@ -1705,11 +1705,11 @@ cvEigenVV( CvArr* srcarr, CvArr* evectsarr, CvArr* evalsarr, double, { const uchar* p = evals0.ptr(); if( evals0.size() == evals.size() ) - evals.convertTo(evals0, evals0.type()); + evals.convertTo(evals0, evals0.depth()); else if( evals0.type() == evals.type() ) cv::transpose(evals, evals0); else - cv::Mat(evals.t()).convertTo(evals0, evals0.type()); + cv::Mat(evals.t()).convertTo(evals0, evals0.depth()); CV_Assert( p == evals0.ptr() ); } } diff --git a/modules/core/src/lda.cpp b/modules/core/src/lda.cpp index 053dffedb51f..ae36e37c005b 100644 --- a/modules/core/src/lda.cpp +++ b/modules/core/src/lda.cpp @@ -78,9 +78,9 @@ static Mat asRowMatrix(InputArrayOfArrays src, ElemType rtype, double alpha = 1, Mat xi = data.row(i); // make reshape happy by cloning for non-continuous matrices if(src.getMat(i).isContinuous()) { - src.getMat(i).reshape(1, 1).convertTo(xi, rtype, alpha, beta); + src.getMat(i).reshape(1, 1).convertTo(xi, CV_MAT_DEPTH(rtype), alpha, beta); } else { - src.getMat(i).clone().reshape(1, 1).convertTo(xi, rtype, alpha, beta); + src.getMat(i).clone().reshape(1, 1).convertTo(xi, CV_MAT_DEPTH(rtype), alpha, beta); } } return data; @@ -190,7 +190,7 @@ Mat LDA::subspaceProject(InputArray _W, InputArray _mean, InputArray _src) { // create temporary matrices Mat X, Y; // make sure you operate on correct type - src.convertTo(X, W.type()); + src.convertTo(X, W.depth()); // safe to do, because of above assertion if(!mean.empty()) { for(int i=0; i sorted_eigenvalues64f(n); for (size_t i = 0; i < n; i++) sorted_eigenvalues64f[i] = eigenvalues64f[sort_indexes[i]]; - Mat(sorted_eigenvalues64f).convertTo(_evals, type); + Mat(sorted_eigenvalues64f).convertTo(_evals, depth); if( _evects.needed() ) { @@ -988,7 +988,7 @@ void eigenNonSymmetric(InputArray _src, OutputArray _evals, OutputArray _evects) CV_Assert(pSrc != NULL); memcpy(pDst, pSrc, n * sizeof(double)); } - sorted_eigenvectors64f.convertTo(_evects, type); + sorted_eigenvectors64f.convertTo(_evects, depth); } } @@ -1109,10 +1109,10 @@ void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) { numClass[classIdx]++; } // calculate total mean - meanTotal.convertTo(meanTotal, meanTotal.type(), 1.0 / static_cast (N)); + meanTotal.convertTo(meanTotal, meanTotal.depth(), 1.0 / static_cast (N)); // calculate class means for (int i = 0; i < C; i++) { - meanClass[i].convertTo(meanClass[i], meanClass[i].type(), 1.0 / static_cast (numClass[i])); + meanClass[i].convertTo(meanClass[i], meanClass[i].depth(), 1.0 / static_cast (numClass[i])); } // subtract class means for (int i = 0; i < N; i++) { diff --git a/modules/core/src/lut.cpp b/modules/core/src/lut.cpp index 309812544b0e..c03b4b940fc1 100644 --- a/modules/core/src/lut.cpp +++ b/modules/core/src/lut.cpp @@ -79,7 +79,7 @@ static LUTFunc lutTab[] = static bool ocl_LUT(InputArray _src, InputArray _lut, OutputArray _dst) { int lcn = _lut.channels(), dcn = _src.channels(); - ElemType ddepth = _lut.depth(); + ElemDepth ddepth = _lut.depth(); UMat src = _src.getUMat(), lut = _lut.getUMat(); _dst.create(src.size(), CV_MAKETYPE(ddepth, dcn)); @@ -362,7 +362,7 @@ void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst ) CV_INSTRUMENT_REGION(); int cn = _src.channels(); - ElemType depth = _src.depth(); + ElemDepth depth = _src.depth(); int lutcn = _lut.channels(); CV_Assert( (lutcn == cn || lutcn == 1) && diff --git a/modules/core/src/mathfuncs.cpp b/modules/core/src/mathfuncs.cpp index c16b8523ad4e..67e114110c0a 100644 --- a/modules/core/src/mathfuncs.cpp +++ b/modules/core/src/mathfuncs.cpp @@ -61,7 +61,7 @@ static const char* oclop2str[] = { "OP_LOG", "OP_EXP", "OP_MAG", "OP_PHASE_DEGRE static bool ocl_math_op(InputArray _src1, InputArray _src2, OutputArray _dst, int oclop) { ElemType type = _src1.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type); int kercn = oclop == OCL_OP_PHASE_DEGREES || oclop == OCL_OP_PHASE_RADIANS ? 1 : ocl::predictOptimalVectorWidth(_src1, _src2, _dst); @@ -150,7 +150,7 @@ void magnitude( InputArray src1, InputArray src2, OutputArray dst ) CV_INSTRUMENT_REGION(); int type = src1.type(); - ElemType depth = src1.depth(); + ElemDepth depth = src1.depth(); int cn = src1.channels(); CV_Assert( src1.size() == src2.size() && type == src2.type() && (depth == CV_32F || depth == CV_64F)); @@ -188,7 +188,7 @@ void phase( InputArray src1, InputArray src2, OutputArray dst, bool angleInDegre CV_INSTRUMENT_REGION(); ElemType type = src1.type(); - ElemType depth = src1.depth(); + ElemDepth depth = src1.depth(); int cn = src1.channels(); CV_Assert( src1.size() == src2.size() && type == src2.type() && (depth == CV_32F || depth == CV_64F)); @@ -235,7 +235,7 @@ static bool ocl_cartToPolar( InputArray _src1, InputArray _src2, { const ocl::Device & d = ocl::Device::getDefault(); ElemType type = _src1.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type), rowsPerWI = d.isIntel() ? 4 : 1; bool doubleSupport = d.doubleFPConfig() > 0; @@ -282,7 +282,7 @@ void cartToPolar( InputArray src1, InputArray src2, Mat X = src1.getMat(), Y = src2.getMat(); ElemType type = X.type(); - ElemType depth = X.depth(); + ElemDepth depth = X.depth(); int cn = X.channels(); CV_Assert( X.size == Y.size && type == Y.type() && (depth == CV_32F || depth == CV_64F)); dst1.create( X.dims, X.size, type ); @@ -477,7 +477,7 @@ static bool ocl_polarToCart( InputArray _mag, InputArray _angle, { const ocl::Device & d = ocl::Device::getDefault(); ElemType type = _angle.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type), rowsPerWI = d.isIntel() ? 4 : 1; bool doubleSupport = d.doubleFPConfig() > 0; @@ -515,7 +515,7 @@ static bool ipp_polarToCart(Mat &mag, Mat &angle, Mat &x, Mat &y) { CV_INSTRUMENT_REGION_IPP(); - ElemType depth = angle.depth(); + ElemDepth depth = angle.depth(); if(depth != CV_32F && depth != CV_64F) return false; @@ -575,7 +575,7 @@ void polarToCart( InputArray src1, InputArray src2, CV_INSTRUMENT_REGION(); ElemType type = src2.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type); CV_Assert((depth == CV_32F || depth == CV_64F) && (src1.empty() || src1.type() == type)); @@ -680,7 +680,7 @@ void exp( InputArray _src, OutputArray _dst ) CV_INSTRUMENT_REGION(); ElemType type = _src.type(); - ElemType depth = _src.depth(); + ElemDepth depth = _src.depth(); int cn = _src.channels(); CV_Assert( depth == CV_32F || depth == CV_64F ); @@ -715,7 +715,7 @@ void log( InputArray _src, OutputArray _dst ) CV_INSTRUMENT_REGION(); ElemType type = _src.type(); - ElemType depth = _src.depth(); + ElemDepth depth = _src.depth(); int cn = _src.channels(); CV_Assert( depth == CV_32F || depth == CV_64F ); @@ -1155,7 +1155,7 @@ static bool ocl_pow(InputArray _src, double power, OutputArray _dst, { const ocl::Device & d = ocl::Device::getDefault(); ElemType type = _src.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type), rowsPerWI = d.isIntel() ? 4 : 1; bool doubleSupport = d.doubleFPConfig() > 0; @@ -1225,7 +1225,7 @@ void pow( InputArray _src, double power, OutputArray _dst ) CV_INSTRUMENT_REGION(); ElemType type = _src.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type), ipower = cvRound(power); bool is_ipower = fabs(ipower - power) < DBL_EPSILON; #ifdef HAVE_OPENCL @@ -1417,7 +1417,7 @@ template<> struct mat_type_assotiations static const type max_allowable = INT_MAX; }; -template +template static bool checkIntegerRange(cv::Mat src, Point& bad_pt, int minVal, int maxVal) { typedef mat_type_assotiations type_ass; @@ -1483,7 +1483,7 @@ bool checkRange(InputArray _src, bool quiet, Point* pt, double minVal, double ma return true; } - ElemType depth = src.depth(); + ElemDepth depth = src.depth(); Point badPt(-1, -1); if (depth < CV_32F) @@ -1912,7 +1912,7 @@ double cv::solvePoly( InputArray _coeffs0, OutputArray _roots0, int maxIters ) int iter, i, j; Mat coeffs0 = _coeffs0.getMat(); ElemType ctype = _coeffs0.type(); - ElemType cdepth = CV_MAT_DEPTH(ctype); + ElemDepth cdepth = CV_MAT_DEPTH(ctype); CV_Assert( CV_MAT_DEPTH(ctype) >= CV_32F && CV_MAT_CN(ctype) <= 2 ); CV_Assert( coeffs0.rows == 1 || coeffs0.cols == 1 ); @@ -1925,7 +1925,7 @@ double cv::solvePoly( InputArray _coeffs0, OutputArray _roots0, int maxIters ) AutoBuffer buf(n*2+2); C *coeffs = buf.data(), *roots = coeffs + n + 1; Mat coeffs1(coeffs0.size(), CV_MAKETYPE(CV_64F, coeffs0.channels()), coeffs0.channels() == 2 ? coeffs : roots); - coeffs0.convertTo(coeffs1, coeffs1.type()); + coeffs0.convertTo(coeffs1, coeffs1.depth()); if( coeffs0.channels() == 1 ) { const double* rcoeffs = (const double*)roots; @@ -2020,7 +2020,7 @@ double cv::solvePoly( InputArray _coeffs0, OutputArray _roots0, int maxIters ) for( ; n < n0; n++ ) roots[n+1] = roots[n]; - Mat(roots0.size(), CV_64FC2, roots).convertTo(roots0, roots0.type()); + Mat(roots0.size(), CV_64FC2, roots).convertTo(roots0, roots0.depth()); return maxDiff; } diff --git a/modules/core/src/matmul.cpp b/modules/core/src/matmul.cpp index 003ff157f082..f945fcc843c3 100644 --- a/modules/core/src/matmul.cpp +++ b/modules/core/src/matmul.cpp @@ -794,7 +794,7 @@ static bool ocl_gemm_amdblas( InputArray matA, InputArray matB, double alpha, static bool ocl_gemm( InputArray matA, InputArray matB, double alpha, InputArray matC, double beta, OutputArray matD, int flags ) { - ElemType depth = matA.depth(); + ElemDepth depth = matA.depth(); int cn = matA.channels(); ElemType type = CV_MAKETYPE(depth, cn); @@ -1513,7 +1513,7 @@ void cv::hal::gemm32f(const float* src1, size_t src1_step, const float* src2, si { CALL_HAL(gemm32f, cv_hal_gemm32f, src1, src1_step, src2, src2_step, alpha, src3, src3_step, beta, dst, dst_step, m_a, n_a, n_d, flags) - callGemmImpl(src1, src1_step, src2, src2_step, alpha, src3, src3_step, beta, dst, dst_step, m_a, n_a, n_d, flags, CV_32F); + callGemmImpl(src1, src1_step, src2, src2_step, alpha, src3, src3_step, beta, dst, dst_step, m_a, n_a, n_d, flags, CV_32FC1); } void cv::hal::gemm64f(const double* src1, size_t src1_step, const double* src2, size_t src2_step, @@ -1521,7 +1521,7 @@ void cv::hal::gemm64f(const double* src1, size_t src1_step, const double* src2, int m_a, int n_a, int n_d, int flags) { CALL_HAL(gemm64f, cv_hal_gemm64f, src1, src1_step, src2, src2_step, alpha, src3, src3_step, beta, dst, dst_step, m_a, n_a, n_d, flags) - callGemmImpl(src1, src1_step, src2, src2_step, alpha, src3, src3_step, beta, dst, dst_step, m_a, n_a, n_d, flags, CV_64F); + callGemmImpl(src1, src1_step, src2, src2_step, alpha, src3, src3_step, beta, dst, dst_step, m_a, n_a, n_d, flags, CV_64FC1); } CV_EXPORTS void cv::hal::gemm32fc(const float* src1, size_t src1_step, const float* src2, size_t src2_step, @@ -2057,7 +2057,7 @@ diagtransform_64f(const double* src, double* dst, const double* m, int len, int typedef void (*TransformFunc)( const uchar* src, uchar* dst, const uchar* m, int, int, int ); -static TransformFunc getTransformFunc(ElemType depth) +static TransformFunc getTransformFunc(ElemDepth depth) { static TransformFunc transformTab[] = { @@ -2069,7 +2069,7 @@ static TransformFunc getTransformFunc(ElemType depth) return transformTab[depth]; } -static TransformFunc getDiagTransformFunc(ElemType depth) +static TransformFunc getDiagTransformFunc(ElemDepth depth) { static TransformFunc diagTransformTab[] = { @@ -2088,7 +2088,7 @@ void cv::transform( InputArray _src, OutputArray _dst, InputArray _mtx ) CV_INSTRUMENT_REGION(); Mat src = _src.getMat(), m = _mtx.getMat(); - ElemType depth = src.depth(); + ElemDepth depth = src.depth(); int scn = src.channels(), dcn = m.rows; CV_Assert( scn == m.cols || scn + 1 == m.cols ); bool isDiag = false; @@ -2107,11 +2107,11 @@ void cv::transform( InputArray _src, OutputArray _dst, InputArray _mtx ) Mat tmp(dcn, scn+1, mtype, mbuf); memset(tmp.ptr(), 0, tmp.total()*tmp.elemSize()); if( m.cols == scn+1 ) - m.convertTo(tmp, mtype); + m.convertTo(tmp, CV_MAT_DEPTH(mtype)); else { Mat tmppart = tmp.colRange(0, m.cols); - m.convertTo(tmppart, mtype); + m.convertTo(tmppart, CV_MAT_DEPTH(mtype)); } m = tmp; } @@ -2130,7 +2130,7 @@ void cv::transform( InputArray _src, OutputArray _dst, InputArray _mtx ) alpha = m.at(0), beta = m.at(1); else alpha = m.at(0), beta = m.at(1); - src.convertTo(dst, dst.type(), alpha, beta); + src.convertTo(dst, dst.depth(), alpha, beta); return; } @@ -2269,7 +2269,7 @@ void cv::perspectiveTransform( InputArray _src, OutputArray _dst, InputArray _mt CV_INSTRUMENT_REGION(); Mat src = _src.getMat(), m = _mtx.getMat(); - ElemType depth = src.depth(); + ElemDepth depth = src.depth(); int scn = src.channels(), dcn = m.rows - 1; CV_Assert( scn + 1 == m.cols ); CV_Assert( depth == CV_32F || depth == CV_64F ); @@ -2286,7 +2286,7 @@ void cv::perspectiveTransform( InputArray _src, OutputArray _dst, InputArray _mt _mbuf.allocate((dcn+1)*(scn+1)); mbuf = _mbuf.data(); Mat tmp(dcn+1, scn+1, mtype, mbuf); - m.convertTo(tmp, mtype); + m.convertTo(tmp, CV_MAT_DEPTH(mtype)); m = tmp; } @@ -2370,13 +2370,13 @@ static bool ocl_scaleAdd(InputArray _src1, double alpha, InputArray _src2, Outpu bool doubleSupport = d.doubleFPConfig() > 0; Size size = _src1.size(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); if ( (!doubleSupport && depth == CV_64F) || size != _src2.size() ) return false; _dst.create(size, type); int cn = CV_MAT_CN(type); - ElemType wdepth = CV_MAX_DEPTH(depth, CV_32F); + ElemDepth wdepth = CV_MAX_DEPTH(depth, CV_32F); int kercn = ocl::predictOptimalVectorWidthMax(_src1, _src2, _dst), rowsPerWI = d.isIntel() ? 4 : 1; @@ -2418,7 +2418,7 @@ void cv::scaleAdd( InputArray _src1, double alpha, InputArray _src2, OutputArray CV_INSTRUMENT_REGION(); ElemType type = _src1.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type); CV_Assert( type == _src2.type() ); @@ -2462,7 +2462,7 @@ void cv::scaleAdd( InputArray _src1, double alpha, InputArray _src2, OutputArray * Covariation Matrix * \****************************************************************************************/ -void cv::calcCovarMatrix( const Mat* data, int nsamples, Mat& covar, Mat& _mean, int flags, ElemType cdepth ) +void cv::calcCovarMatrix( const Mat* data, int nsamples, Mat& covar, Mat& _mean, int flags, ElemDepth cdepth ) { CV_INSTRUMENT_REGION(); @@ -2505,7 +2505,7 @@ void cv::calcCovarMatrix( const Mat* data, int nsamples, Mat& covar, Mat& _mean, _mean = mean.reshape(1, size.height); } -void cv::calcCovarMatrix(InputArray _src, OutputArray _covar, InputOutputArray _mean, int flags, ElemType cdepth) +void cv::calcCovarMatrix(InputArray _src, OutputArray _covar, InputOutputArray _mean, int flags, ElemDepth cdepth) { CV_INSTRUMENT_REGION(); @@ -2601,7 +2601,7 @@ double cv::Mahalanobis( InputArray _v1, InputArray _v2, InputArray _icovar ) Mat v1 = _v1.getMat(), v2 = _v2.getMat(), icovar = _icovar.getMat(); ElemType type = v1.type(); - ElemType depth = v1.depth(); + ElemDepth depth = v1.depth(); Size sz = v1.size(); int i, j, len = sz.width*sz.height*v1.channels(); AutoBuffer buf(len); @@ -2888,13 +2888,13 @@ typedef void (*MulTransposedFunc)(const Mat& src, Mat& dst, const Mat& delta, do } void cv::mulTransposed( InputArray _src, OutputArray _dst, bool ata, - InputArray _delta, double scale, ElemType ddepth ) + InputArray _delta, double scale, ElemDepth ddepth ) { CV_INSTRUMENT_REGION(); Mat src = _src.getMat(), delta = _delta.getMat(); const int gemm_level = 100; // boundary above which GEMM is faster. - ElemType sdepth = src.depth(); + ElemDepth sdepth = src.depth(); ddepth = CV_MAX_DEPTH(ddepth >= CV_8U ? ddepth : sdepth, delta.depth(), CV_32F); CV_Assert( src.channels() == 1 ); @@ -3283,7 +3283,7 @@ static double dotProd_64f(const double* src1, const double* src2, int len) typedef double (*DotProdFunc)(const uchar* src1, const uchar* src2, int len); -static DotProdFunc getDotProdFunc(ElemType depth) +static DotProdFunc getDotProdFunc(ElemDepth depth) { static DotProdFunc dotProdTab[] = { @@ -3357,8 +3357,8 @@ cvTransform( const CvArr* srcarr, CvArr* dstarr, { cv::Mat v = cv::cvarrToMat(shiftvec).reshape(1,m.rows), _m(m.rows, m.cols + 1, m.type()), m1 = _m.colRange(0,m.cols), v1 = _m.col(m.cols); - m.convertTo(m1, m1.type()); - v.convertTo(v1, v1.type()); + m.convertTo(m1, m1.depth()); + v.convertTo(v1, v1.depth()); m = _m; } @@ -3412,10 +3412,10 @@ cvCalcCovarMatrix( const CvArr** vecarr, int count, } if( mean.data != mean0.data && mean0.data ) - mean.convertTo(mean0, mean0.type()); + mean.convertTo(mean0, mean0.depth()); if( cov.data != cov0.data ) - cov.convertTo(cov0, cov0.type()); + cov.convertTo(cov0, cov0.depth()); } @@ -3435,7 +3435,7 @@ cvMulTransposed( const CvArr* srcarr, CvArr* dstarr, delta = cv::cvarrToMat(deltaarr); cv::mulTransposed( src, dst, order != 0, delta, scale, dst.depth()); if( dst.data != dst0.data ) - dst.convertTo(dst0, dst0.type()); + dst.convertTo(dst0, dst0.depth()); } CV_IMPL double cvDotProduct( const CvArr* srcAarr, const CvArr* srcBarr ) @@ -3460,10 +3460,10 @@ cvCalcPCA( const CvArr* data_arr, CvArr* avg_arr, CvArr* eigenvals, CvArr* eigen flags, !evals.empty() ? evals.rows + evals.cols - 1 : 0); if( pca.mean.size() == mean.size() ) - pca.mean.convertTo( mean, mean.type() ); + pca.mean.convertTo(mean, mean.depth()); else { - cv::Mat temp; pca.mean.convertTo( temp, mean.type() ); + cv::Mat temp; pca.mean.convertTo(temp, mean.depth()); transpose( temp, mean ); } @@ -3479,12 +3479,12 @@ cvCalcPCA( const CvArr* data_arr, CvArr* avg_arr, CvArr* eigenvals, CvArr* eigen cv::Mat temp = evals0; if( evals.rows == 1 ) - evals.colRange(0, ecount0).convertTo(temp, evals0.type()); + evals.colRange(0, ecount0).convertTo(temp, evals0.depth()); else - evals.rowRange(0, ecount0).convertTo(temp, evals0.type()); + evals.rowRange(0, ecount0).convertTo(temp, evals0.depth()); if( temp.data != evals0.data ) transpose(temp, evals0); - evects.rowRange(0, ecount0).convertTo( evects0, evects0.type() ); + evects.rowRange(0, ecount0).convertTo(evects0, evects0.depth()); // otherwise some datatype's or size's were incorrect, so the output arrays have been reallocated CV_Assert( mean0.data == mean.data ); @@ -3516,7 +3516,7 @@ cvProjectPCA( const CvArr* data_arr, const CvArr* avg_arr, cv::Mat result = pca.project(data); if( result.cols != dst.cols ) result = result.reshape(1, 1); - result.convertTo(dst, dst.type()); + result.convertTo(dst, dst.depth()); CV_Assert(dst0.data == dst.data); } @@ -3545,7 +3545,7 @@ cvBackProjectPCA( const CvArr* proj_arr, const CvArr* avg_arr, pca.eigenvectors = evects.rowRange(0, n); cv::Mat result = pca.backProject(data); - result.convertTo(dst, dst.type()); + result.convertTo(dst, dst.depth()); CV_Assert(dst0.data == dst.data); } diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index 976e47d73bff..11ac1db05f59 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -931,7 +931,7 @@ Mat Mat::diag(const Mat& d) return m; } -int Mat::checkVector(int _elemChannels, ElemType _depth, bool _requireContinuous) const +int Mat::checkVector(int _elemChannels, ElemDepth _depth, bool _requireContinuous) const { return data && (depth() == _depth || _depth <= CV_8U) && (isContinuous() || !_requireContinuous) && diff --git a/modules/core/src/matrix_c.cpp b/modules/core/src/matrix_c.cpp index 7fc00e499ec0..825151d83fc5 100644 --- a/modules/core/src/matrix_c.cpp +++ b/modules/core/src/matrix_c.cpp @@ -97,7 +97,7 @@ static Mat iplImageToMat(const IplImage* img, bool copyData) m.dims = 2; CV_DbgAssert(CV_IS_IMAGE(img) && img->imageData != 0); - ElemType imgdepth = static_cast(IPL2CV_DEPTH(img->depth)); + ElemDepth imgdepth = static_cast(IPL2CV_DEPTH(img->depth)); size_t esz; m.step[0] = img->widthStep; diff --git a/modules/core/src/matrix_expressions.cpp b/modules/core/src/matrix_expressions.cpp index 150293f9a154..c292abe7336e 100644 --- a/modules/core/src/matrix_expressions.cpp +++ b/modules/core/src/matrix_expressions.cpp @@ -21,7 +21,7 @@ class MatOp_Identity CV_FINAL : public MatOp virtual ~MatOp_Identity() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return true; } - void assign(const MatExpr& expr, Mat& m, ElemType depth = CV_TYPE_AUTO) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const CV_OVERRIDE; static void makeExpr(MatExpr& res, const Mat& m); }; @@ -35,7 +35,7 @@ class MatOp_AddEx CV_FINAL : public MatOp virtual ~MatOp_AddEx() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return true; } - void assign(const MatExpr& expr, Mat& m, ElemType depth = CV_TYPE_AUTO) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const CV_OVERRIDE; void add(const MatExpr& e1, const Scalar& s, MatExpr& res) const CV_OVERRIDE; void subtract(const Scalar& s, const MatExpr& expr, MatExpr& res) const CV_OVERRIDE; @@ -57,7 +57,7 @@ class MatOp_Bin CV_FINAL : public MatOp virtual ~MatOp_Bin() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return true; } - void assign(const MatExpr& expr, Mat& m, ElemType depth = CV_TYPE_AUTO) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const CV_OVERRIDE; void multiply(const MatExpr& e1, double s, MatExpr& res) const CV_OVERRIDE; void divide(double s, const MatExpr& e, MatExpr& res) const CV_OVERRIDE; @@ -75,7 +75,7 @@ class MatOp_Cmp CV_FINAL : public MatOp virtual ~MatOp_Cmp() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return true; } - void assign(const MatExpr& expr, Mat& m, ElemType depth = CV_TYPE_AUTO) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const CV_OVERRIDE; static void makeExpr(MatExpr& res, int cmpop, const Mat& a, const Mat& b); static void makeExpr(MatExpr& res, int cmpop, const Mat& a, double alpha); @@ -90,7 +90,7 @@ class MatOp_GEMM CV_FINAL : public MatOp virtual ~MatOp_GEMM() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return false; } - void assign(const MatExpr& expr, Mat& m, ElemType depth = CV_TYPE_AUTO) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const CV_OVERRIDE; void add(const MatExpr& e1, const MatExpr& e2, MatExpr& res) const CV_OVERRIDE; void subtract(const MatExpr& e1, const MatExpr& e2, MatExpr& res) const CV_OVERRIDE; @@ -111,7 +111,7 @@ class MatOp_Invert CV_FINAL : public MatOp virtual ~MatOp_Invert() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return false; } - void assign(const MatExpr& expr, Mat& m, ElemType depth = CV_TYPE_AUTO) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const CV_OVERRIDE; void matmul(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res) const CV_OVERRIDE; @@ -127,7 +127,7 @@ class MatOp_T CV_FINAL : public MatOp virtual ~MatOp_T() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return false; } - void assign(const MatExpr& expr, Mat& m, ElemType depth = CV_TYPE_AUTO) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const CV_OVERRIDE; void multiply(const MatExpr& e1, double s, MatExpr& res) const CV_OVERRIDE; void transpose(const MatExpr& expr, MatExpr& res) const CV_OVERRIDE; @@ -144,7 +144,7 @@ class MatOp_Solve CV_FINAL : public MatOp virtual ~MatOp_Solve() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return false; } - void assign(const MatExpr& expr, Mat& m, ElemType depth = CV_TYPE_AUTO) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const CV_OVERRIDE; static void makeExpr(MatExpr& res, int method, const Mat& a, const Mat& b); }; @@ -158,7 +158,7 @@ class MatOp_Initializer CV_FINAL : public MatOp virtual ~MatOp_Initializer() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return false; } - void assign(const MatExpr& expr, Mat& m, ElemType depth = CV_TYPE_AUTO) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const CV_OVERRIDE; void multiply(const MatExpr& e, double s, MatExpr& res) const CV_OVERRIDE; @@ -1185,23 +1185,22 @@ ElemType MatExpr::type() const if( isInitializer(*this) ) return a.type(); if( isCmp(*this) ) - return CV_8U; + return CV_8UC1; return op ? op->type(*this) : CV_TYPE_AUTO; } ///////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_Identity::assign(const MatExpr& e, Mat& m, ElemType _depth) const +void MatOp_Identity::assign(const MatExpr& e, Mat& m, ElemDepth _depth) const { - if (_depth == CV_TYPE_AUTO) + if (_depth == CV_DEPTH_AUTO) _depth = e.a.depth(); if (_depth == e.a.depth()) m = e.a; else { - CV_Assert( CV_MAT_CN(_depth) == e.a.channels() ); e.a.convertTo(m, _depth); } } @@ -1213,9 +1212,9 @@ inline void MatOp_Identity::makeExpr(MatExpr& res, const Mat& m) ///////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_AddEx::assign(const MatExpr& e, Mat& m, ElemType _depth) const +void MatOp_AddEx::assign(const MatExpr& e, Mat& m, ElemDepth _depth) const { - if (_depth == CV_TYPE_AUTO) + if (_depth == CV_DEPTH_AUTO) _depth = e.a.depth(); Mat temp, &dst = e.a.depth() == _depth ? m : temp; @@ -1259,12 +1258,12 @@ void MatOp_AddEx::assign(const MatExpr& e, Mat& m, ElemType _depth) const cv::subtract(e.s, e.a, dst); else { - e.a.convertTo(dst, e.a.type(), e.alpha); + e.a.convertTo(dst, CV_MAT_DEPTH(e.a.depth()), e.alpha); cv::add(dst, e.s, dst); } if( dst.data != m.data ) - dst.convertTo(m, m.type()); + dst.convertTo(m, CV_MAT_DEPTH(m.depth())); } @@ -1337,9 +1336,9 @@ inline void MatOp_AddEx::makeExpr(MatExpr& res, const Mat& a, const Mat& b, doub ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_Bin::assign(const MatExpr& e, Mat& m, ElemType _depth) const +void MatOp_Bin::assign(const MatExpr& e, Mat& m, ElemDepth _depth) const { - if (_depth == CV_TYPE_AUTO) + if (_depth == CV_DEPTH_AUTO) _depth = e.a.depth(); Mat temp, &dst = e.a.depth() == _depth ? m : temp; @@ -1418,9 +1417,9 @@ inline void MatOp_Bin::makeExpr(MatExpr& res, char op, const Mat& a, const Scala /////////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_Cmp::assign(const MatExpr& e, Mat& m, ElemType _depth) const +void MatOp_Cmp::assign(const MatExpr& e, Mat& m, ElemDepth _depth) const { - if (_depth == CV_TYPE_AUTO) + if (_depth == CV_DEPTH_AUTO) _depth = e.a.depth(); //TODO: Investigate why CV_8U is coded here @@ -1447,9 +1446,9 @@ inline void MatOp_Cmp::makeExpr(MatExpr& res, int cmpop, const Mat& a, double al ///////////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_T::assign(const MatExpr& e, Mat& m, ElemType _depth) const +void MatOp_T::assign(const MatExpr& e, Mat& m, ElemDepth _depth) const { - if (_depth == CV_TYPE_AUTO) + if (_depth == CV_DEPTH_AUTO) _depth = e.a.depth(); Mat temp, &dst = _depth == e.a.depth() ? m : temp; @@ -1485,9 +1484,9 @@ inline void MatOp_T::makeExpr(MatExpr& res, const Mat& a, double alpha) ///////////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_GEMM::assign(const MatExpr& e, Mat& m, ElemType _depth) const +void MatOp_GEMM::assign(const MatExpr& e, Mat& m, ElemDepth _depth) const { - if (_depth == CV_TYPE_AUTO) + if (_depth == CV_DEPTH_AUTO) _depth = e.a.depth(); Mat temp, &dst = _depth == e.a.depth() ? m : temp; @@ -1563,9 +1562,9 @@ inline void MatOp_GEMM::makeExpr(MatExpr& res, int flags, const Mat& a, const Ma /////////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_Invert::assign(const MatExpr& e, Mat& m, ElemType _depth) const +void MatOp_Invert::assign(const MatExpr& e, Mat& m, ElemDepth _depth) const { - if (_depth == CV_TYPE_AUTO) + if (_depth == CV_DEPTH_AUTO) _depth = e.a.depth(); Mat temp, &dst = _depth == e.a.depth() ? m : temp; @@ -1592,9 +1591,9 @@ inline void MatOp_Invert::makeExpr(MatExpr& res, int method, const Mat& m) ///////////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_Solve::assign(const MatExpr& e, Mat& m, ElemType _depth) const +void MatOp_Solve::assign(const MatExpr& e, Mat& m, ElemDepth _depth) const { - if (_depth == CV_TYPE_AUTO) + if (_depth == CV_DEPTH_AUTO) _depth = e.a.depth(); Mat temp, &dst = _depth == e.a.depth() ? m : temp; @@ -1611,9 +1610,9 @@ inline void MatOp_Solve::makeExpr(MatExpr& res, int method, const Mat& a, const ////////////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_Initializer::assign(const MatExpr& e, Mat& m, ElemType _depth) const +void MatOp_Initializer::assign(const MatExpr& e, Mat& m, ElemDepth _depth) const { - if (_depth == CV_TYPE_AUTO) + if (_depth == CV_DEPTH_AUTO) _depth = e.a.depth(); if( e.a.dims <= 2 ) diff --git a/modules/core/src/matrix_operations.cpp b/modules/core/src/matrix_operations.cpp index 977dae731b8f..c5a91264edf9 100644 --- a/modules/core/src/matrix_operations.cpp +++ b/modules/core/src/matrix_operations.cpp @@ -144,7 +144,7 @@ namespace cv { static bool ocl_setIdentity( InputOutputArray _m, const Scalar& s ) { ElemType type = _m.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type), kercn = cn, rowsPerWI = 1; ElemType sctype = CV_MAKE_TYPE(depth, cn == 3 ? 4 : cn); if (ocl::Device::getDefault().isIntel()) @@ -374,7 +374,7 @@ static bool ocl_transpose( InputArray _src, OutputArray _dst ) const int TILE_DIM = 32, BLOCK_ROWS = 8; ElemType type = _src.type(); int cn = CV_MAT_CN(type); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int rowsPerWI = dev.isIntel() ? 4 : 1; UMat src = _src.getUMat(); @@ -568,7 +568,7 @@ cv::Mat cv::Mat::cross(InputArray _m) const { Mat m = _m.getMat(); ElemType tp = type(); - ElemType d = CV_MAT_DEPTH(tp); + ElemDepth d = CV_MAT_DEPTH(tp); CV_Assert( dims <= 2 && m.dims <= 2 && size() == m.size() && tp == m.type() && ((rows == 3 && cols == 1) || (cols*channels() == 3 && rows == 1))); Mat result(rows, cols, tp); @@ -720,7 +720,7 @@ typedef void (*ReduceFunc)( const Mat& src, Mat& dst ); static inline bool ipp_reduceSumC_8u16u16s32f_64f(const cv::Mat& srcmat, cv::Mat& dstmat) { int sstep = (int)srcmat.step, stype = srcmat.type(); - ElemType ddepth = dstmat.depth(); + ElemDepth ddepth = dstmat.depth(); IppiSize roisize = { srcmat.size().width, 1 }; @@ -777,7 +777,7 @@ static inline void reduceSumC_8u16u16s32f_64f(const cv::Mat& srcmat, cv::Mat& ds if(dstmat.depth() == CV_64F) { - ElemType sdepth = CV_MAT_DEPTH(srcmat.type()); + ElemDepth sdepth = CV_MAT_DEPTH(srcmat.type()); func = sdepth == CV_8U ? (cv::ReduceFunc)cv::reduceC_ > : sdepth == CV_16U ? (cv::ReduceFunc)cv::reduceC_ > : @@ -869,9 +869,9 @@ static bool ocl_reduce(InputArray _src, OutputArray _dst, int dim, int op, int op0, ElemType stype, ElemType dtype) { const int min_opt_cols = 128, buf_cols = 32; - ElemType sdepth = CV_MAT_DEPTH(stype); + ElemDepth sdepth = CV_MAT_DEPTH(stype); int cn = CV_MAT_CN(stype); - ElemType ddepth = CV_MAT_DEPTH(dtype), ddepth0 = ddepth; + ElemDepth ddepth = CV_MAT_DEPTH(dtype), ddepth0 = ddepth; const ocl::Device &defDev = ocl::Device::getDefault(); bool doubleSupport = defDev.doubleFPConfig() > 0; @@ -889,7 +889,7 @@ static bool ocl_reduce(InputArray _src, OutputArray _dst, const char * const ops[4] = { "OCL_CV_REDUCE_SUM", "OCL_CV_REDUCE_AVG", "OCL_CV_REDUCE_MAX", "OCL_CV_REDUCE_MIN" }; - ElemType wdepth = CV_MAX_DEPTH(ddepth, CV_32F); + ElemDepth wdepth = CV_MAX_DEPTH(ddepth, CV_32F); if (useOptimized) { size_t tileHeight = (size_t)(wgs / buf_cols); @@ -969,16 +969,16 @@ static bool ocl_reduce(InputArray _src, OutputArray _dst, #endif -void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, ElemType ddepth) +void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, ElemDepth ddepth) { CV_INSTRUMENT_REGION(); CV_Assert( _src.dims() <= 2 ); int op0 = op; ElemType stype = _src.type(); - ElemType sdepth = _src.depth(); + ElemDepth sdepth = _src.depth(); int cn = CV_MAT_CN(stype); - if (ddepth == CV_TYPE_AUTO) + if (ddepth == CV_DEPTH_AUTO) ddepth = _dst.fixedType() ? _dst.depth() : sdepth; ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ ElemType dtype = CV_MAKETYPE(ddepth, cn); @@ -1122,7 +1122,7 @@ void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, ElemType dde func( src, temp ); if( op0 == CV_REDUCE_AVG ) - temp.convertTo(dst, dst.type(), 1./(dim == 0 ? src.rows : src.cols)); + temp.convertTo(dst, dst.depth(), 1. / (dim == 0 ? src.rows : src.cols)); } @@ -1183,7 +1183,7 @@ template static void sort_( const Mat& src, Mat& dst, int flags ) #ifdef HAVE_IPP typedef IppStatus (CV_STDCALL *IppSortFunc)(void *pSrcDst, int len, Ipp8u *pBuffer); -static IppSortFunc getSortFunc(ElemType depth, bool sortDescending) +static IppSortFunc getSortFunc(ElemDepth depth, bool sortDescending) { if (!sortDescending) return depth == CV_8U ? (IppSortFunc)ippsSortRadixAscend_8u_I : @@ -1210,7 +1210,7 @@ static bool ipp_sort(const Mat& src, Mat& dst, int flags) bool sortRows = (flags & 1) == CV_SORT_EVERY_ROW; bool sortDescending = (flags & CV_SORT_DESCENDING) != 0; bool inplace = (src.data == dst.data); - ElemType depth = src.depth(); + ElemDepth depth = src.depth(); IppDataType type = ippiGetDataType(depth); IppSortFunc ippsSortRadix_I = getSortFunc(depth, sortDescending); @@ -1331,7 +1331,7 @@ template static void sortIdx_( const Mat& src, Mat& dst, int flags ) #ifdef HAVE_IPP typedef IppStatus (CV_STDCALL *IppSortIndexFunc)(const void* pSrc, Ipp32s srcStrideBytes, Ipp32s *pDstIndx, int len, Ipp8u *pBuffer); -static IppSortIndexFunc getSortIndexFunc(ElemType depth, bool sortDescending) +static IppSortIndexFunc getSortIndexFunc(ElemDepth depth, bool sortDescending) { if (!sortDescending) return depth == CV_8U ? (IppSortIndexFunc)ippsSortRadixIndexAscend_8u : @@ -1355,7 +1355,7 @@ static bool ipp_sortIdx( const Mat& src, Mat& dst, int flags ) bool sortRows = (flags & 1) == SORT_EVERY_ROW; bool sortDescending = (flags & SORT_DESCENDING) != 0; - ElemType depth = src.depth(); + ElemDepth depth = src.depth(); IppDataType type = ippiGetDataType(depth); IppSortIndexFunc ippsSortRadixIndex = getSortIndexFunc(depth, sortDescending); diff --git a/modules/core/src/matrix_sparse.cpp b/modules/core/src/matrix_sparse.cpp index ab5c7e0bb0d6..c4cb7acd7ab4 100644 --- a/modules/core/src/matrix_sparse.cpp +++ b/modules/core/src/matrix_sparse.cpp @@ -278,10 +278,10 @@ void SparseMat::copyTo( Mat& m ) const } -void SparseMat::convertTo(SparseMat& m, ElemType ddepth, double alpha) const +void SparseMat::convertTo(SparseMat& m, ElemDepth ddepth, double alpha) const { int cn = channels(); - if (ddepth == CV_TYPE_AUTO) + if (ddepth == CV_DEPTH_AUTO) ddepth = depth(); ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ ElemType dtype = CV_MAKETYPE(ddepth, cn); @@ -323,10 +323,10 @@ void SparseMat::convertTo(SparseMat& m, ElemType ddepth, double alpha) const } } -void SparseMat::convertTo(Mat& m, ElemType ddepth, double alpha, double beta) const +void SparseMat::convertTo(Mat& m, ElemDepth ddepth, double alpha, double beta) const { int cn = channels(); - if (ddepth == CV_TYPE_AUTO) + if (ddepth == CV_DEPTH_AUTO) ddepth = depth(); ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ ElemType dtype = CV_MAKETYPE(ddepth, cn); @@ -760,7 +760,7 @@ void normalize( const SparseMat& src, SparseMat& dst, double a, int norm_type ) else CV_Error( CV_StsBadArg, "Unknown/unsupported norm type" ); - src.convertTo(dst, CV_TYPE_AUTO, scale); + src.convertTo(dst, CV_DEPTH_AUTO, scale); } } // cv:: diff --git a/modules/core/src/matrix_wrap.cpp b/modules/core/src/matrix_wrap.cpp index 45990f102ea4..bf0422e28818 100644 --- a/modules/core/src/matrix_wrap.cpp +++ b/modules/core/src/matrix_wrap.cpp @@ -842,7 +842,7 @@ ElemType _InputArray::type(int i) const CV_Error(Error::StsNotImplemented, "Unknown/unsupported array type"); } -ElemType _InputArray::depth(int i) const +ElemDepth _InputArray::depth(int i) const { return CV_MAT_DEPTH(type(i)); } diff --git a/modules/core/src/mean.cpp b/modules/core/src/mean.cpp index a364745a29ab..dd4af74e37b8 100644 --- a/modules/core/src/mean.cpp +++ b/modules/core/src/mean.cpp @@ -112,7 +112,7 @@ cv::Scalar cv::mean( InputArray _src, InputArray _mask ) CV_Assert( mask.empty() || mask.type() == CV_8U ); int k, cn = src.channels(); - ElemType depth = src.depth(); + ElemDepth depth = src.depth(); Scalar s; CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_mean(src, mask, s), s) @@ -467,7 +467,7 @@ static int sqsum64f( const double* src, const uchar* mask, double* sum, double* typedef int (*SumSqrFunc)(const uchar*, const uchar* mask, uchar*, uchar*, int, int); -static SumSqrFunc getSumSqrTab(ElemType depth) +static SumSqrFunc getSumSqrTab(ElemDepth depth) { static SumSqrFunc sumSqrTab[] = { @@ -492,7 +492,7 @@ static bool ocl_meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv { ElemType type = _src.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0, isContinuous = _src.isContinuous(), isMaskContinuous = _mask.isContinuous(); @@ -505,7 +505,7 @@ static bool ocl_meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv } size_t wgs = defDev.maxWorkGroupSize(); - ElemType ddepth = CV_MAX_DEPTH(CV_32S, depth), sqddepth = CV_MAX_DEPTH(CV_32F, depth); + ElemDepth ddepth = CV_MAX_DEPTH(CV_32S, depth), sqddepth = CV_MAX_DEPTH(CV_32F, depth); ElemType sqdtype = CV_MAKETYPE(sqddepth, cn); ElemType dtype = CV_MAKE_TYPE(ddepth, cn); CV_Assert(!haveMask || _mask.type() == CV_8UC1); @@ -802,7 +802,7 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_meanStdDev(src, _mean, _sdv, mask)); int k, cn = src.channels(); - ElemType depth = src.depth(); + ElemDepth depth = src.depth(); SumSqrFunc func = getSumSqrTab(depth); diff --git a/modules/core/src/merge.cpp b/modules/core/src/merge.cpp index a0c710b70d99..2ecb3609a5df 100644 --- a/modules/core/src/merge.cpp +++ b/modules/core/src/merge.cpp @@ -212,7 +212,7 @@ void merge64s(const int64** src, int64* dst, int len, int cn ) typedef void (*MergeFunc)(const uchar** src, uchar* dst, int len, int cn); -static MergeFunc getMergeFunc(ElemType depth) +static MergeFunc getMergeFunc(ElemDepth depth) { static MergeFunc mergeTab[] = { @@ -285,7 +285,7 @@ void cv::merge(const Mat* mv, size_t n, OutputArray _dst) CV_Assert( mv && n > 0 ); - ElemType depth = mv[0].depth(); + ElemDepth depth = mv[0].depth(); bool allch1 = true; int k, cn = 0; size_t i; @@ -372,7 +372,7 @@ static bool ocl_merge( InputArrayOfArrays _mv, OutputArray _dst ) CV_Assert(!src.empty()); ElemType type = src[0].type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1; Size size = src[0].size(); @@ -380,7 +380,7 @@ static bool ocl_merge( InputArrayOfArrays _mv, OutputArray _dst ) { int itype = src[i].type(); int icn = CV_MAT_CN(itype); - ElemType idepth = CV_MAT_DEPTH(itype); + ElemDepth idepth = CV_MAT_DEPTH(itype); int esz1 = CV_ELEM_SIZE1(idepth); if (src[i].dims > 2) return false; diff --git a/modules/core/src/minmax.cpp b/modules/core/src/minmax.cpp index d989923508a6..f778193b942f 100644 --- a/modules/core/src/minmax.cpp +++ b/modules/core/src/minmax.cpp @@ -93,7 +93,7 @@ static void minMaxIdx_64f(const double* src, const uchar* mask, double* minval, typedef void (*MinMaxIdxFunc)(const uchar*, const uchar*, int*, int*, size_t*, size_t*, int, size_t); -static MinMaxIdxFunc getMinmaxTab(ElemType depth) +static MinMaxIdxFunc getMinmaxTab(ElemDepth depth) { static MinMaxIdxFunc minmaxTab[] = { @@ -230,7 +230,7 @@ typedef void (*getMinMaxResFunc)(const Mat & db, double * minVal, double * maxVa int * minLoc, int *maxLoc, int gropunum, int cols, double * maxVal2); bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int* minLoc, int* maxLoc, InputArray _mask, - ElemType ddepth, bool absValues, InputArray _src2, double * maxVal2) + ElemDepth ddepth, bool absValues, InputArray _src2, double * maxVal2) { const ocl::Device & dev = ocl::Device::getDefault(); @@ -242,7 +242,7 @@ bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int* minLoc bool doubleSupport = dev.doubleFPConfig() > 0, haveMask = !_mask.empty(), haveSrc2 = _src2.kind() != _InputArray::NONE; ElemType type = _src.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type), kercn = haveMask ? cn : std::min(4, ocl::predictOptimalVectorWidth(_src, _src2)); @@ -253,7 +253,7 @@ bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int* minLoc CV_Assert( (cn == 1 && (!haveMask || _mask.type() == CV_8U)) || (cn >= 1 && !minLoc && !maxLoc) ); - if (ddepth == CV_TYPE_AUTO) + if (ddepth == CV_DEPTH_AUTO) ddepth = depth; CV_Assert(!haveSrc2 || _src2.type() == type); @@ -751,7 +751,7 @@ void cv::minMaxIdx(InputArray _src, double* minVal, CV_INSTRUMENT_REGION(); ElemType type = _src.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type); CV_Assert( (cn == 1 && (_mask.empty() || _mask.type() == CV_8U)) || (cn > 1 && _mask.empty() && !minIdx && !maxIdx) ); diff --git a/modules/core/src/norm.cpp b/modules/core/src/norm.cpp index 417bee2a2500..6e1745a945f3 100644 --- a/modules/core/src/norm.cpp +++ b/modules/core/src/norm.cpp @@ -395,7 +395,7 @@ CV_DEF_NORM_ALL(64f, double, double, double, double) typedef int (*NormFunc)(const uchar*, const uchar*, uchar*, int, int); typedef int (*NormDiffFunc)(const uchar*, const uchar*, const uchar*, uchar*, int, int); -static NormFunc getNormFunc(int normType, ElemType depth) +static NormFunc getNormFunc(int normType, ElemDepth depth) { static NormFunc normTab[3][8] = { @@ -416,7 +416,7 @@ static NormFunc getNormFunc(int normType, ElemType depth) return normTab[normType][depth]; } -static NormDiffFunc getNormDiffFunc(int normType, ElemType depth) +static NormDiffFunc getNormDiffFunc(int normType, ElemDepth depth) { static NormDiffFunc normDiffTab[3][8] = { @@ -457,7 +457,7 @@ static bool ocl_norm( InputArray _src, int normType, InputArray _mask, double & if (cn > 4) return false; ElemType type = _src.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); bool doubleSupport = d.doubleFPConfig() > 0, haveMask = _mask.kind() != _InputArray::NONE; @@ -574,7 +574,7 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result) else { IppiSize sz = { cols*src.channels(), rows }; - ElemType type = src.depth(); + ElemDepth type = src.depth(); typedef IppStatus (CV_STDCALL* ippiNormFuncHint)(const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint); typedef IppStatus (CV_STDCALL* ippiNormFuncNoHint)(const void *, int, IppiSize, Ipp64f *); @@ -646,7 +646,7 @@ double cv::norm( InputArray _src, int normType, InputArray _mask ) Mat src = _src.getMat(), mask = _mask.getMat(); CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_norm(src, normType, mask, _result), _result); - ElemType depth = src.depth(); + ElemDepth depth = src.depth(); int cn = src.channels(); if( src.isContinuous() && mask.empty() ) { @@ -822,7 +822,7 @@ static bool ocl_norm( InputArray _src1, InputArray _src2, int normType, InputArr if (cn > 4) return false; int type = _src1.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); bool relative = (normType & NORM_RELATIVE) != 0; normType &= ~NORM_RELATIVE; bool normsum = normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR; @@ -925,7 +925,7 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra else { IppiSize sz = { cols*src1.channels(), rows }; - ElemType type = src1.depth(); + ElemDepth type = src1.depth(); typedef IppStatus (CV_STDCALL* ippiNormRelFuncHint)(const void *, int, const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint); typedef IppStatus (CV_STDCALL* ippiNormRelFuncNoHint)(const void *, int, const void *, int, IppiSize, Ipp64f *); @@ -1054,7 +1054,7 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra else { IppiSize sz = { cols*src1.channels(), rows }; - ElemType type = src1.depth(); + ElemDepth type = src1.depth(); typedef IppStatus (CV_STDCALL* ippiNormDiffFuncHint)(const void *, int, const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint); typedef IppStatus (CV_STDCALL* ippiNormDiffFuncNoHint)(const void *, int, const void *, int, IppiSize, Ipp64f *); @@ -1128,7 +1128,7 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m } Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat(); - ElemType depth = src1.depth(); + ElemDepth depth = src1.depth(); int cn = src1.channels(); normType &= 7; diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index 4bdfc031933e..ba353c4f137a 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -5765,7 +5765,7 @@ void convertFromImage(void* cl_mem_image, UMat& dst) cl_image_format fmt = { 0, 0 }; CV_OCL_CHECK(clGetImageInfo(clImage, CL_IMAGE_FORMAT, sizeof(cl_image_format), &fmt, 0)); - ElemType depth = CV_8U; + ElemDepth depth = CV_8U; switch (fmt.image_channel_data_type) { case CL_UNORM_INT8: @@ -5984,7 +5984,7 @@ const char* typeToStr(int type) "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?" }; int cn = CV_MAT_CN(type); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); return cn > 16 ? "?" : tab[depth*16 + cn-1]; } @@ -6002,7 +6002,7 @@ const char* memopTypeToStr(int type) "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?" }; int cn = CV_MAT_CN(type); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); return cn > 16 ? "?" : tab[depth*16 + cn-1]; } @@ -6020,11 +6020,11 @@ const char* vecopTypeToStr(int type) "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?" }; int cn = CV_MAT_CN(type); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); return cn > 16 ? "?" : tab[depth*16 + cn-1]; } -const char* convertTypeStr(ElemType sdepth, ElemType ddepth, int cn, char* buf) +const char* convertTypeStr(ElemDepth sdepth, ElemDepth ddepth, int cn, char* buf) { if( sdepth == ddepth ) return "noconvert"; @@ -6131,7 +6131,7 @@ template static std::string kerToStr(const Mat & k) { int width = k.cols - 1; - ElemType depth = k.depth(); + ElemDepth depth = k.depth(); const T * const data = k.ptr(); std::ostringstream stream; @@ -6160,12 +6160,12 @@ static std::string kerToStr(const Mat & k) return stream.str(); } -String kernelToStr(InputArray _kernel, ElemType ddepth, const char * name) +String kernelToStr(InputArray _kernel, ElemDepth ddepth, const char * name) { Mat kernel = _kernel.getMat().reshape(1, 1); - ElemType depth = kernel.depth(); - if (ddepth == CV_TYPE_AUTO) + ElemDepth depth = kernel.depth(); + if (ddepth == CV_DEPTH_AUTO) ddepth = depth; if (ddepth != depth) @@ -6188,7 +6188,7 @@ String kernelToStr(InputArray _kernel, ElemType ddepth, const char * name) CV_Assert(src.isMat() || src.isUMat()); \ Size csize = src.size(); \ ElemType ctype = src.type(); \ - ElemType cdepth = CV_MAT_DEPTH(ctype); \ + ElemDepth cdepth = CV_MAT_DEPTH(ctype); \ int ccn = CV_MAT_CN(ctype), \ ckercn = vectorWidths[cdepth], cwidth = ccn * csize.width; \ if (cwidth < ckercn || ckercn <= 0) \ @@ -6278,7 +6278,7 @@ void buildOptionsAddMatrixDescription(String& buildOptions, const String& name, if (!buildOptions.empty()) buildOptions += " "; ElemType type = _m.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); buildOptions += format( "-D %s_T=%s -D %s_T1=%s -D %s_CN=%d -D %s_TSIZE=%d -D %s_T1SIZE=%d -D %s_DEPTH=%d", name.c_str(), ocl::typeToStr(type), @@ -6306,7 +6306,7 @@ struct Image2D::Impl clReleaseMemObject(handle); } - static cl_image_format getImageFormat(ElemType depth, int cn, bool norm) + static cl_image_format getImageFormat(ElemDepth depth, int cn, bool norm) { cl_image_format format; static const int channelTypes[] = { CL_UNSIGNED_INT8, CL_SIGNED_INT8, CL_UNSIGNED_INT16, @@ -6358,7 +6358,7 @@ struct Image2D::Impl CV_Assert(ocl::Device::getDefault().imageSupport()); int err; - ElemType depth = src.depth(); + ElemDepth depth = src.depth(); int cn = src.channels(); CV_Assert(cn <= 4); cl_image_format format = getImageFormat(depth, cn, norm); @@ -6472,7 +6472,7 @@ bool Image2D::canCreateAlias(const UMat &m) return ret; } -bool Image2D::isFormatSupported(ElemType depth, int cn, bool norm) +bool Image2D::isFormatSupported(ElemDepth depth, int cn, bool norm) { cl_image_format format = Impl::getImageFormat(depth, cn, norm); diff --git a/modules/core/src/opengl.cpp b/modules/core/src/opengl.cpp index a002a4346d61..ba57f1626837 100644 --- a/modules/core/src/opengl.cpp +++ b/modules/core/src/opengl.cpp @@ -979,7 +979,7 @@ cv::ogl::Texture2D::Texture2D(InputArray arr, bool autoRelease) : rows_(0), cols const Size asize = arr.size(); const ElemType atype = arr.type(); - const ElemType depth = CV_MAT_DEPTH(atype); + const ElemDepth depth = CV_MAT_DEPTH(atype); const int cn = CV_MAT_CN(atype); CV_Assert( depth <= CV_32F ); @@ -1091,7 +1091,7 @@ void cv::ogl::Texture2D::copyFrom(InputArray arr, bool autoRelease) const Size asize = arr.size(); const ElemType atype = arr.type(); - const ElemType depth = CV_MAT_DEPTH(atype); + const ElemDepth depth = CV_MAT_DEPTH(atype); const int cn = CV_MAT_CN(atype); CV_Assert( depth <= CV_32F ); @@ -1146,7 +1146,7 @@ void cv::ogl::Texture2D::copyFrom(InputArray arr, bool autoRelease) #endif } -void cv::ogl::Texture2D::copyTo(OutputArray arr, ElemType ddepth, bool autoRelease) const +void cv::ogl::Texture2D::copyTo(OutputArray arr, ElemDepth ddepth, bool autoRelease) const { #ifndef HAVE_OPENGL CV_UNUSED(arr); @@ -1224,7 +1224,7 @@ unsigned int cv::ogl::Texture2D::texId() const void cv::ogl::Arrays::setVertexArray(InputArray vertex) { const int cn = vertex.channels(); - const ElemType depth = vertex.depth(); + const ElemDepth depth = vertex.depth(); CV_Assert( cn == 2 || cn == 3 || cn == 4 ); CV_Assert( depth == CV_16S || depth == CV_32S || depth == CV_32F || depth == CV_64F ); @@ -1263,7 +1263,7 @@ void cv::ogl::Arrays::resetColorArray() void cv::ogl::Arrays::setNormalArray(InputArray normal) { const int cn = normal.channels(); - const ElemType depth = normal.depth(); + const ElemDepth depth = normal.depth(); CV_Assert( cn == 3 ); CV_Assert( depth == CV_8S || depth == CV_16S || depth == CV_32S || depth == CV_32F || depth == CV_64F ); @@ -1282,7 +1282,7 @@ void cv::ogl::Arrays::resetNormalArray() void cv::ogl::Arrays::setTexCoordArray(InputArray texCoord) { const int cn = texCoord.channels(); - const ElemType depth = texCoord.depth(); + const ElemDepth depth = texCoord.depth(); CV_Assert( cn >= 1 && cn <= 4 ); CV_Assert( depth == CV_16S || depth == CV_32S || depth == CV_32F || depth == CV_64F ); @@ -1515,7 +1515,7 @@ void cv::ogl::render(const ogl::Arrays& arr, InputArray indices, int mode, Scala { ogl::Buffer buf = indices.getOGlBuffer(); - const ElemType depth = buf.depth(); + const ElemDepth depth = buf.depth(); CV_Assert( buf.channels() == 1 ); CV_Assert( depth <= CV_32S ); @@ -1541,7 +1541,7 @@ void cv::ogl::render(const ogl::Arrays& arr, InputArray indices, int mode, Scala { Mat mat = indices.getMat(); - const ElemType depth = mat.depth(); + const ElemDepth depth = mat.depth(); CV_Assert( mat.channels() == 1 ); CV_Assert( depth <= CV_32S ); diff --git a/modules/core/src/pca.cpp b/modules/core/src/pca.cpp index 08adaac7941e..8fd9947d7483 100644 --- a/modules/core/src/pca.cpp +++ b/modules/core/src/pca.cpp @@ -102,7 +102,7 @@ PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, int maxComp if( !_mean.empty() ) { CV_Assert( _mean.size() == mean_sz ); - _mean.convertTo(mean, ctype); + _mean.convertTo(mean, CV_MAT_DEPTH(ctype)); covar_flags |= CV_COVAR_USE_AVG; } @@ -116,7 +116,7 @@ PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, int maxComp Mat tmp_data, tmp_mean = repeat(mean, data.rows/mean.rows, data.cols/mean.cols); if( data.type() != ctype || tmp_mean.data == mean.data ) { - data.convertTo( tmp_data, ctype ); + data.convertTo(tmp_data, CV_MAT_DEPTH(ctype)); subtract( tmp_data, tmp_mean, tmp_data ); } else @@ -238,7 +238,7 @@ PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, double reta if( !_mean.empty() ) { CV_Assert( _mean.size() == mean_sz ); - _mean.convertTo(mean, ctype); + _mean.convertTo(mean, CV_MAT_DEPTH(ctype)); covar_flags |= CV_COVAR_USE_AVG; } @@ -252,7 +252,7 @@ PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, double reta Mat tmp_data, tmp_mean = repeat(mean, data.rows/mean.rows, data.cols/mean.cols); if( data.type() != ctype || tmp_mean.data == mean.data ) { - data.convertTo( tmp_data, ctype ); + data.convertTo(tmp_data, CV_MAT_DEPTH(ctype)); subtract( tmp_data, tmp_mean, tmp_data ); } else @@ -298,7 +298,7 @@ void PCA::project(InputArray _data, OutputArray result) const ElemType ctype = mean.type(); if( data.type() != ctype || tmp_mean.data == mean.data ) { - data.convertTo( tmp_data, ctype ); + data.convertTo(tmp_data, CV_MAT_DEPTH(ctype)); subtract( tmp_data, tmp_mean, tmp_data ); } else @@ -327,7 +327,7 @@ void PCA::backProject(InputArray _data, OutputArray result) const (mean.cols == 1 && eigenvectors.rows == data.rows))); Mat tmp_data, tmp_mean; - data.convertTo(tmp_data, mean.type()); + data.convertTo(tmp_data, mean.depth()); if( mean.rows == 1 ) { tmp_mean = repeat(mean, data.rows, 1); diff --git a/modules/core/src/persistence_base64.cpp b/modules/core/src/persistence_base64.cpp index 3c756b9646bc..e59267137797 100644 --- a/modules/core/src/persistence_base64.cpp +++ b/modules/core/src/persistence_base64.cpp @@ -745,7 +745,7 @@ class BinaryToCvSeqConvertor typedef size_t(*binary_to_t)(uchar const *, uchar *); struct binary_to_filenode_t { - ElemType cv_type; + ElemDepth cv_type; size_t offset; binary_to_t func; }; diff --git a/modules/core/src/persistence_types.cpp b/modules/core/src/persistence_types.cpp index 8a5879e70e96..418402d6feee 100644 --- a/modules/core/src/persistence_types.cpp +++ b/modules/core/src/persistence_types.cpp @@ -385,7 +385,7 @@ static void icvWriteImage( CvFileStorage* fs, const char* name, const void* stru char dt_buf[16], *dt; cv::Size size; int y; - ElemType depth; + ElemDepth depth; assert( CV_IS_IMAGE(image) ); @@ -411,7 +411,7 @@ static void icvWriteImage( CvFileStorage* fs, const char* name, const void* stru cvEndWriteStruct( fs ); } - depth = static_cast(IPL2CV_DEPTH(image->depth)); + depth = static_cast(IPL2CV_DEPTH(image->depth)); dt = icvEncodeFormat(depth, dt_buf); cvWriteString( fs, "dt", dt, 0 ); @@ -441,7 +441,7 @@ static void* icvReadImage( CvFileStorage* fs, CvFileNode* node ) cv::Rect roi; int y, width, height, coi; ElemType elem_type; - ElemType depth; + ElemDepth depth; const char* origin, *data_order; width = cvReadIntByName( fs, node, "width", 0 ); @@ -465,7 +465,7 @@ static void* icvReadImage( CvFileStorage* fs, CvFileNode* node ) CV_Error( CV_StsUnmatchedSizes, "The matrix size does not match to the number of stored elements" ); - depth = static_cast(cvIplDepth(elem_type)); + depth = static_cast(cvIplDepth(elem_type)); image = cvCreateImage( cvSize(width,height), depth, CV_MAT_CN(elem_type) ); roi_node = cvGetFileNodeByName( fs, node, "roi" ); diff --git a/modules/core/src/precomp.hpp b/modules/core/src/precomp.hpp index 9992564825dc..739bdcbe9e7c 100644 --- a/modules/core/src/precomp.hpp +++ b/modules/core/src/precomp.hpp @@ -136,8 +136,8 @@ typedef void (*BinaryFuncC)(const uchar* src1, size_t step1, uchar* dst, size_t step, int width, int height, void*); -BinaryFunc getConvertFunc(ElemType sdepth, ElemType ddepth); -BinaryFunc getConvertScaleFunc(ElemType sdepth, ElemType ddepth); +BinaryFunc getConvertFunc(ElemDepth sdepth, ElemDepth ddepth); +BinaryFunc getConvertScaleFunc(ElemDepth sdepth, ElemDepth ddepth); BinaryFunc getCopyMaskFunc(size_t esz); /* default memory block for sparse array elements */ diff --git a/modules/core/src/rand.cpp b/modules/core/src/rand.cpp index 4e72aa1cf81e..981c18d65961 100644 --- a/modules/core/src/rand.cpp +++ b/modules/core/src/rand.cpp @@ -394,7 +394,7 @@ void RNG::fill( InputOutputArray _mat, int disttype, CV_Assert(!_mat.empty()); Mat mat = _mat.getMat(), _param1 = _param1arg.getMat(), _param2 = _param2arg.getMat(); - ElemType depth = mat.depth(); + ElemDepth depth = mat.depth(); int cn = mat.channels(); AutoBuffer _parambuf; int j, k; @@ -549,7 +549,7 @@ void RNG::fill( InputOutputArray _mat, int disttype, else { Mat tmp(_param1.size(), ptype, parambuf); - _param1.convertTo(tmp, ptype); + _param1.convertTo(tmp, CV_MAT_DEPTH(ptype)); mean = (uchar*)parambuf; } @@ -562,7 +562,7 @@ void RNG::fill( InputOutputArray _mat, int disttype, else { Mat tmp(_param2.size(), ptype, parambuf + MAX(n1, cn)); - _param2.convertTo(tmp, ptype); + _param2.convertTo(tmp, CV_MAT_DEPTH(ptype)); stddev = (uchar*)(parambuf + MAX(n1, cn)); } diff --git a/modules/core/src/split.cpp b/modules/core/src/split.cpp index 100c0824eefa..13e0109aeb8b 100644 --- a/modules/core/src/split.cpp +++ b/modules/core/src/split.cpp @@ -220,7 +220,7 @@ void split64s(const int64* src, int64** dst, int len, int cn ) typedef void (*SplitFunc)(const uchar* src, uchar** dst, int len, int cn); -static SplitFunc getSplitFunc(ElemType depth) +static SplitFunc getSplitFunc(ElemDepth depth) { static SplitFunc splitTab[] = { @@ -292,7 +292,7 @@ void cv::split(const Mat& src, Mat* mv) CV_INSTRUMENT_REGION(); int k, cn = src.channels(); - ElemType depth = src.depth(); + ElemDepth depth = src.depth(); if( cn == 1 ) { src.copyTo(mv[0]); @@ -349,7 +349,7 @@ namespace cv { static bool ocl_split( InputArray _m, OutputArrayOfArrays _mv ) { ElemType type = _m.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type), rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1; @@ -406,7 +406,7 @@ void cv::split(InputArray _m, OutputArrayOfArrays _mv) CV_Assert( !_mv.fixedType() || _mv.empty() || _mv.type() == CV_MAKETYPE(m.depth(), 1) ); - ElemType depth = m.depth(); + ElemDepth depth = m.depth(); int cn = m.channels(); _mv.create(cn, 1, depth); for (int i = 0; i < cn; ++i) diff --git a/modules/core/src/stat.hpp b/modules/core/src/stat.hpp index 868548a9d3a4..d2bf843b5ed1 100644 --- a/modules/core/src/stat.hpp +++ b/modules/core/src/stat.hpp @@ -16,7 +16,7 @@ enum { OCL_OP_SUM = 0, OCL_OP_SUM_ABS = 1, OCL_OP_SUM_SQR = 2 }; bool ocl_sum( InputArray _src, Scalar & res, int sum_op, InputArray _mask = noArray(), InputArray _src2 = noArray(), bool calc2 = false, const Scalar & res2 = Scalar() ); bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int* minLoc, int* maxLoc, InputArray _mask, - ElemType ddepth = CV_TYPE_AUTO, bool absValues = false, InputArray _src2 = noArray(), double * maxVal2 = NULL); + ElemDepth ddepth = CV_DEPTH_AUTO, bool absValues = false, InputArray _src2 = noArray(), double * maxVal2 = NULL); template Scalar ocl_part_sum(Mat m) { @@ -36,7 +36,7 @@ template Scalar ocl_part_sum(Mat m) #endif typedef int (*SumFunc)(const uchar*, const uchar* mask, uchar*, int, int); -SumFunc getSumFunc(ElemType depth); +SumFunc getSumFunc(ElemDepth depth); } diff --git a/modules/core/src/sum.cpp b/modules/core/src/sum.cpp index 39427e0d1ee9..fa3228309665 100644 --- a/modules/core/src/sum.cpp +++ b/modules/core/src/sum.cpp @@ -429,7 +429,7 @@ static int sum32f( const float* src, const uchar* mask, double* dst, int len, in static int sum64f( const double* src, const uchar* mask, double* dst, int len, int cn ) { return sum_(src, mask, dst, len, cn); } -SumFunc getSumFunc(ElemType depth) +SumFunc getSumFunc(ElemDepth depth) { static SumFunc sumTab[] = { @@ -455,7 +455,7 @@ bool ocl_sum( InputArray _src, Scalar & res, int sum_op, InputArray _mask, haveMask = _mask.kind() != _InputArray::NONE, haveSrc2 = _src2.kind() != _InputArray::NONE; ElemType type = _src.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type), kercn = cn == 1 && !haveMask ? ocl::predictOptimalVectorWidth(_src, _src2) : 1, mcn = std::max(cn, kercn); @@ -468,7 +468,7 @@ bool ocl_sum( InputArray _src, Scalar & res, int sum_op, InputArray _mask, int ngroups = dev.maxComputeUnits(), dbsize = ngroups * (calc2 ? 2 : 1); size_t wgs = dev.maxWorkGroupSize(); - ElemType ddepth = CV_MAX_DEPTH(sum_op == OCL_OP_SUM_SQR ? (CV_32F) : (CV_32S), depth); + ElemDepth ddepth = CV_MAX_DEPTH(sum_op == OCL_OP_SUM_SQR ? (CV_32F) : (CV_32S), depth); ElemType dtype = CV_MAKE_TYPE(ddepth, cn); CV_Assert(!haveMask || _mask.type() == CV_8UC1); @@ -615,7 +615,7 @@ cv::Scalar cv::sum( InputArray _src ) CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_sum(src, _res), _res); int k, cn = src.channels(); - ElemType depth = src.depth(); + ElemDepth depth = src.depth(); SumFunc func = getSumFunc(depth); CV_Assert( cn <= 4 && func != 0 ); diff --git a/modules/core/src/umatrix.cpp b/modules/core/src/umatrix.cpp index d86c34550661..d459c5e31c34 100644 --- a/modules/core/src/umatrix.cpp +++ b/modules/core/src/umatrix.cpp @@ -751,7 +751,7 @@ UMat UMat::diag(const UMat& d) return m; } -int UMat::checkVector(int _elemChannels, ElemType _depth, bool _requireContinuous) const +int UMat::checkVector(int _elemChannels, ElemDepth _depth, bool _requireContinuous) const { return (depth() == _depth || _depth <= CV_8U) && (isContinuous() || !_requireContinuous) && @@ -886,7 +886,7 @@ void UMat::copyTo(OutputArray _dst) const if( _dst.fixedType() && dtype != type() ) { CV_Assert( channels() == CV_MAT_CN(dtype) ); - convertTo( _dst, dtype ); + convertTo(_dst, CV_MAT_DEPTH(dtype)); return; } @@ -936,7 +936,7 @@ void UMat::copyTo(OutputArray _dst, InputArray _mask) const #ifdef HAVE_OPENCL int cn = channels(); ElemType mtype = _mask.type(); - ElemType mdepth = CV_MAT_DEPTH(mtype); + ElemDepth mdepth = CV_MAT_DEPTH(mtype); int mcn = CV_MAT_CN(mtype); CV_Assert( mdepth == CV_8U && (mcn == 1 || mcn == cn) ); @@ -976,18 +976,18 @@ void UMat::copyTo(OutputArray _dst, InputArray _mask) const src.copyTo(_dst, _mask); } -void UMat::convertTo(OutputArray _dst, ElemType ddepth, double alpha, double beta) const +void UMat::convertTo(OutputArray _dst, ElemDepth ddepth, double alpha, double beta) const { CV_INSTRUMENT_REGION(); bool noScale = std::fabs(alpha - 1) < DBL_EPSILON && std::fabs(beta) < DBL_EPSILON; ElemType stype = type(); - if (ddepth == CV_TYPE_AUTO) + if (ddepth == CV_DEPTH_AUTO) ddepth = _dst.fixedType() ? _dst.depth() : depth(); ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ - ElemType sdepth = CV_MAT_DEPTH(stype); + ElemDepth sdepth = CV_MAT_DEPTH(stype); if( sdepth == ddepth && noScale ) { copyTo(_dst); @@ -1000,7 +1000,7 @@ void UMat::convertTo(OutputArray _dst, ElemType ddepth, double alpha, double bet if( dims <= 2 && cn && _dst.isUMat() && ocl::useOpenCL() && ((needDouble && doubleSupport) || !needDouble) ) { - ElemType wdepth = CV_MAX_DEPTH(CV_32F, sdepth); + ElemDepth wdepth = CV_MAX_DEPTH(CV_32F, sdepth); int rowsPerWI = 4; char cvt[2][40]; @@ -1050,7 +1050,7 @@ UMat& UMat::setTo(InputArray _value, InputArray _mask) #ifdef HAVE_OPENCL ElemType tp = type(); int cn = CV_MAT_CN(tp); - ElemType d = CV_MAT_DEPTH(tp); + ElemDepth d = CV_MAT_DEPTH(tp); if( dims <= 2 && cn <= 4 && CV_MAT_DEPTH(tp) < CV_64F && ocl::useOpenCL() ) { @@ -1137,7 +1137,7 @@ static bool ocl_dot( InputArray _src1, InputArray _src2, double & res ) UMat src1 = _src1.getUMat().reshape(1), src2 = _src2.getUMat().reshape(1); ElemType type = src1.type(); - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int kercn = ocl::predictOptimalVectorWidth(src1, src2); bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; @@ -1146,7 +1146,7 @@ static bool ocl_dot( InputArray _src1, InputArray _src2, double & res ) int dbsize = ocl::Device::getDefault().maxComputeUnits(); size_t wgs = ocl::Device::getDefault().maxWorkGroupSize(); - ElemType ddepth = CV_MAX_DEPTH(CV_32F, depth); + ElemDepth ddepth = CV_MAX_DEPTH(CV_32F, depth); int wgs2_aligned = 1; while (wgs2_aligned < (int)wgs) diff --git a/modules/java/generator/gen_java.py b/modules/java/generator/gen_java.py index 0dbd4a5c0784..ff1bf85632ea 100755 --- a/modules/java/generator/gen_java.py +++ b/modules/java/generator/gen_java.py @@ -66,6 +66,7 @@ def checkFileRemap(path): "int64" : { "j_type" : "long", "jn_type" : "long", "jni_type" : "jlong", "suffix" : "J" }, "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. @@ -563,7 +564,7 @@ def gen_func(self, ci, fi, prop_name=''): cpp_code = ci.cpp_code # c_decl - # e.g: void add(Mat src1, Mat src2, Mat dst, Mat mask = Mat(), ElemType ddepth = CV_TYPE_AUTO) + # e.g: void add(Mat src1, Mat src2, Mat dst, Mat mask = Mat(), ElemDepth ddepth = CV_DEPTH_AUTO) if prop_name: c_decl = "%s %s::%s" % (fi.ctype, fi.classname, prop_name) else: @@ -721,7 +722,7 @@ def gen_func(self, ci, fi, prop_name=''): # java part: # private java NATIVE method decl # e.g. - # private static native void add_0(long src1, long src2, long dst, long mask, ElemType ddepth); + # private static native void add_0(long src1, long src2, long dst, long mask, ElemDepth ddepth); jn_code.write( Template(\ " private static native $type $name($args);\n").substitute(\ type = type_dict[fi.ctype].get("jn_type", "double[]"), \ @@ -747,7 +748,7 @@ def gen_func(self, ci, fi, prop_name=''): # public java wrapper method impl (calling native one above) # e.g. - # public static void add( Mat src1, Mat src2, Mat dst, Mat mask, ElemType ddepth ) + # public static void add( Mat src1, Mat src2, Mat dst, Mat mask, ElemDepth ddepth ) # { add_0( src1.nativeObj, src2.nativeObj, dst.nativeObj, mask.nativeObj, ddepth ); } ret_type = fi.ctype if fi.ctype.endswith('*'): diff --git a/modules/java/generator/src/cpp/Mat.cpp b/modules/java/generator/src/cpp/Mat.cpp index e8fb351e96b0..0512803ada89 100644 --- a/modules/java/generator/src/cpp/Mat.cpp +++ b/modules/java/generator/src/cpp/Mat.cpp @@ -258,7 +258,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1adjustROI // -// void Mat::assignTo(Mat m, ElemType depth = CV_TYPE_AUTO) +// void Mat::assignTo(Mat m, ElemDepth depth = CV_DEPTH_AUTO) // JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1assignTo__JJI @@ -271,7 +271,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1assignTo__JJI try { LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL - me->assignTo((*(Mat*)m_nativeObj), static_cast(depth)); + me->assignTo((*(Mat*)m_nativeObj), static_cast(depth)); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -327,7 +327,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1channels // -// int Mat::checkVector(int elemChannels, ElemType depth = -1, bool requireContinuous = true) +// int Mat::checkVector(int elemChannels, ElemDepth depth = -1, bool requireContinuous = true) // JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JIIZ @@ -340,7 +340,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JIIZ try { LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL - return me->checkVector(elemChannels, static_cast(depth), requireContinuous); + return me->checkVector(elemChannels, static_cast(depth), requireContinuous); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -362,7 +362,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JII try { LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL - return me->checkVector(elemChannels, static_cast(depth)); + return me->checkVector(elemChannels, static_cast(depth)); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -531,7 +531,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1cols // -// void Mat::convertTo(Mat& m, ElemType ddepth, double alpha = 1, double beta = 0) +// void Mat::convertTo(Mat& m, ElemDepth ddepth, double alpha = 1, double beta = 0) // JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJIDD @@ -545,7 +545,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJIDD LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); - me->convertTo(m, static_cast(depth), alpha, beta); + me->convertTo(m, static_cast(depth), alpha, beta); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -565,7 +565,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJID LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); - me->convertTo(m, static_cast(rdepth), alpha); + me->convertTo(m, static_cast(rdepth), alpha); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -585,7 +585,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJI LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); - me->convertTo( m, static_cast(rtype) ); + me->convertTo( m, static_cast(rtype) ); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { diff --git a/modules/js/src/core_bindings.cpp b/modules/js/src/core_bindings.cpp index 5f8d9aa91f0f..1bbe527cebda 100644 --- a/modules/js/src/core_bindings.cpp +++ b/modules/js/src/core_bindings.cpp @@ -130,17 +130,17 @@ namespace binding_utils return Mat(cv::Mat::eye(size, type)); } - void convertTo(const Mat& obj, Mat& m, ElemType ddepth, double alpha, double beta) + void convertTo(const Mat& obj, Mat& m, ElemDepth ddepth, double alpha, double beta) { obj.convertTo(m, ddepth, alpha, beta); } - void convertTo(const Mat& obj, Mat& m, ElemType ddepth) + void convertTo(const Mat& obj, Mat& m, ElemDepth ddepth) { obj.convertTo(m, ddepth); } - void convertTo(const Mat& obj, Mat& m, ElemType ddepth, double alpha) + void convertTo(const Mat& obj, Mat& m, ElemDepth ddepth, double alpha) { obj.convertTo(m, ddepth, alpha); } @@ -358,9 +358,9 @@ EMSCRIPTEN_BINDINGS(binding_utils) .function("elemSize", select_overload(&cv::Mat::elemSize)) .function("elemSize1", select_overload(&cv::Mat::elemSize1)) .function("channels", select_overload(&cv::Mat::channels)) - .function("convertTo", select_overload(&binding_utils::convertTo)) - .function("convertTo", select_overload(&binding_utils::convertTo)) - .function("convertTo", select_overload(&binding_utils::convertTo)) + .function("convertTo", select_overload(&binding_utils::convertTo)) + .function("convertTo", select_overload(&binding_utils::convertTo)) + .function("convertTo", select_overload(&binding_utils::convertTo)) .function("total", select_overload(&cv::Mat::total)) .function("row", select_overload(&cv::Mat::row)) .function("create", select_overload(&cv::Mat::create)) @@ -375,7 +375,7 @@ EMSCRIPTEN_BINDINGS(binding_utils) .function("colRange", select_overload(&cv::Mat::colRange)) .function("step1", select_overload(&cv::Mat::step1)) .function("clone", select_overload(&cv::Mat::clone)) - .function("depth", select_overload(&cv::Mat::depth)) + .function("depth", select_overload(&cv::Mat::depth)) .function("col", select_overload(&cv::Mat::col)) .function("dot", select_overload(&binding_utils::matDot)) .function("mul", select_overload(&binding_utils::matMul)) diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index 9905c95b744f..1df682ab8b1e 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -262,7 +262,7 @@ class NumpyAllocator : public MatAllocator } PyEnsureGIL gil; - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type); const int f = (int)(sizeof(size_t)/8); int typenum = depth == CV_8U ? NPY_UBYTE : depth == CV_8S ? NPY_BYTE : @@ -363,14 +363,14 @@ static bool pyopencv_to(PyObject* o, Mat& m, const ArgInfo info) bool needcopy = false, needcast = false; int typenum = PyArray_TYPE(oarr), new_typenum = typenum; - ElemType type = typenum == NPY_UBYTE ? CV_8U : - typenum == NPY_BYTE ? CV_8S : - typenum == NPY_USHORT ? CV_16U : - typenum == NPY_SHORT ? CV_16S : - typenum == NPY_INT ? CV_32S : - typenum == NPY_INT32 ? CV_32S : - typenum == NPY_FLOAT ? CV_32F : - typenum == NPY_DOUBLE ? CV_64F : CV_TYPE_AUTO; + ElemType type = typenum == NPY_UBYTE ? CV_8UC1 : + typenum == NPY_BYTE ? CV_8SC1 : + typenum == NPY_USHORT ? CV_16UC1 : + typenum == NPY_SHORT ? CV_16SC1 : + typenum == NPY_INT ? CV_32SC1 : + typenum == NPY_INT32 ? CV_32SC1 : + typenum == NPY_FLOAT ? CV_32FC1 : + typenum == NPY_DOUBLE ? CV_64FC1 : CV_TYPE_AUTO; if( type == CV_TYPE_AUTO ) { @@ -378,7 +378,7 @@ static bool pyopencv_to(PyObject* o, Mat& m, const ArgInfo info) { needcopy = needcast = true; new_typenum = NPY_INT; - type = CV_32S; + type = CV_32SC1; } else { @@ -1149,7 +1149,7 @@ template struct pyopencvVecConverter value.resize(n); ElemType type = traits::Type<_Tp>::value; - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int channels = CV_MAT_CN(type); PyObject** items = PySequence_Fast_ITEMS(seq); @@ -1177,8 +1177,8 @@ template struct pyopencvVecConverter ((src.cols != 1 || src.rows != channels) && (src.cols != channels || src.rows != 1))) break; - Mat dst(src.rows, src.cols, depth, data); - src.convertTo(dst, type); + Mat dst(src.rows, src.cols, CV_MAKETYPE(depth, 1), data); + src.convertTo(dst, depth); if( dst.data != (uchar*)data ) break; continue; @@ -1233,7 +1233,7 @@ template struct pyopencvVecConverter if(value.empty()) return PyTuple_New(0); int type = traits::Type<_Tp>::value; - ElemType depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int channels = CV_MAT_CN(type); Mat src((int)value.size(), channels, CV_MAKETYPE(depth, 1), (uchar*)&value[0]); return pyopencv_from(src); diff --git a/modules/python/src2/gen2.py b/modules/python/src2/gen2.py index c7f5171a32bf..ddc2d4f6b50e 100755 --- a/modules/python/src2/gen2.py +++ b/modules/python/src2/gen2.py @@ -863,7 +863,7 @@ def clear(self): self.classes = {} self.namespaces = {} self.consts = {} - self.enumTypes = ["ElemType", ] + self.enumTypes = ["ElemType", "ElemDepth", ] self.code_include = StringIO() self.code_types = StringIO() self.code_funcs = StringIO() From 4a01dd2d203d486772a91b81a6ffe830ac4e1ecf Mon Sep 17 00:00:00 2001 From: Hamdi Sahloul Date: Sat, 22 Sep 2018 06:00:17 +0900 Subject: [PATCH 10/10] Support ElemDepth compatibility API --- modules/core/include/opencv2/core.hpp | 97 +++++- modules/core/include/opencv2/core/base.hpp | 42 ++- modules/core/include/opencv2/core/check.hpp | 8 + modules/core/include/opencv2/core/cuda.hpp | 122 ++++++- .../core/include/opencv2/core/cuda.inl.hpp | 20 ++ modules/core/include/opencv2/core/hal/hal.hpp | 20 +- modules/core/include/opencv2/core/mat.hpp | 300 +++++++++++++++++- modules/core/include/opencv2/core/ocl.hpp | 26 +- modules/core/include/opencv2/core/opengl.hpp | 37 ++- modules/core/src/matrix_expressions.cpp | 40 +++ 10 files changed, 677 insertions(+), 35 deletions(-) diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index 726b34f65eda..2499ef81e8f7 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -343,12 +343,18 @@ output array to be changed. CV_EXPORTS_W void add(InputArray src1, InputArray src2, OutputArray dst, InputArray mask = noArray(), ElemDepth ddepth = CV_DEPTH_AUTO); #ifdef CV_TYPE_COMPATIBLE_API -CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) +CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(dtype, ddepth) static inline void add(InputArray src1, InputArray src2, OutputArray dst, InputArray mask, int ddepth) { add(src1, src2, dst, mask, static_cast(ddepth)); } +CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(dtype, ddepth) +static inline void add(InputArray src1, InputArray src2, OutputArray dst, + InputArray mask, ElemType ddepth) +{ + add(src1, src2, dst, mask, CV_MAT_DEPTH(ddepth)); +} #endif // CV_TYPE_COMPATIBLE_API /** @brief Calculates the per-element difference between two arrays or array and a scalar. @@ -391,12 +397,18 @@ of the output array to be changed. CV_EXPORTS_W void subtract(InputArray src1, InputArray src2, OutputArray dst, InputArray mask = noArray(), ElemDepth ddepth = CV_DEPTH_AUTO); #ifdef CV_TYPE_COMPATIBLE_API -CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) +CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(dtype, ddepth) static inline void subtract(InputArray src1, InputArray src2, OutputArray dst, InputArray mask, int ddepth) { subtract(src1, src2, dst, mask, static_cast(ddepth)); } +CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(dtype, ddepth) +static inline void subtract(InputArray src1, InputArray src2, OutputArray dst, + InputArray mask, ElemType ddepth) +{ + subtract(src1, src2, dst, mask, CV_MAT_DEPTH(ddepth)); +} #endif // CV_TYPE_COMPATIBLE_API @@ -424,12 +436,18 @@ Mat::convertTo CV_EXPORTS_W void multiply(InputArray src1, InputArray src2, OutputArray dst, double scale = 1, ElemDepth ddepth = CV_DEPTH_AUTO); #ifdef CV_TYPE_COMPATIBLE_API -CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) +CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(dtype, ddepth) static inline void multiply(InputArray src1, InputArray src2, OutputArray dst, double scale, int ddepth) { multiply(src1, src2, dst, scale, static_cast(ddepth)); } +CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(dtype, ddepth) +static inline void multiply(InputArray src1, InputArray src2, + OutputArray dst, double scale, ElemType ddepth) +{ + multiply(src1, src2, dst, scale, CV_MAT_DEPTH(ddepth)); +} #endif // CV_TYPE_COMPATIBLE_API /** @brief Performs per-element division of two arrays or a scalar by an array. @@ -455,24 +473,36 @@ case of an array-by-array division, you can only pass -1 when src1.depth()==src2 CV_EXPORTS_W void divide(InputArray src1, InputArray src2, OutputArray dst, double scale = 1, ElemDepth ddepth = CV_DEPTH_AUTO); #ifdef CV_TYPE_COMPATIBLE_API -CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) +CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(dtype, ddepth) static inline void divide(InputArray src1, InputArray src2, OutputArray dst, double scale, int ddepth) { divide(src1, src2, dst, scale, static_cast(ddepth)); } +CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(dtype, ddepth) +static inline void divide(InputArray src1, InputArray src2, OutputArray dst, + double scale, ElemType ddepth) +{ + divide(src1, src2, dst, scale, CV_MAT_DEPTH(ddepth)); +} #endif // CV_TYPE_COMPATIBLE_API /** @overload */ CV_EXPORTS_W void divide(double scale, InputArray src2, OutputArray dst, ElemDepth ddepth = CV_DEPTH_AUTO); #ifdef CV_TYPE_COMPATIBLE_API -CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) +CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(dtype, ddepth) static inline void divide(double scale, InputArray src2, OutputArray dst, int ddepth) { divide(scale, src2, dst, static_cast(ddepth)); } +CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(dtype, ddepth) +static inline void divide(double scale, InputArray src2, + OutputArray dst, ElemType ddepth) +{ + divide(scale, src2, dst, CV_MAT_DEPTH(ddepth)); +} #endif // CV_TYPE_COMPATIBLE_API /** @brief Calculates the sum of a scaled array and another array. @@ -524,12 +554,18 @@ can be set to CV_DEPTH_AUTO, which will be equivalent to src1.depth(). CV_EXPORTS_W void addWeighted(InputArray src1, double alpha, InputArray src2, double beta, double gamma, OutputArray dst, ElemDepth ddepth = CV_DEPTH_AUTO); #ifdef CV_TYPE_COMPATIBLE_API -CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) +CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(dtype, ddepth) static inline void addWeighted(InputArray src1, double alpha, InputArray src2, double beta, double gamma, OutputArray dst, int ddepth) { addWeighted(src1, alpha, src2, beta, gamma, dst, static_cast(ddepth)); } +CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(dtype, ddepth) +static inline void addWeighted(InputArray src1, double alpha, InputArray src2, + double beta, double gamma, OutputArray dst, ElemType ddepth) +{ + addWeighted(src1, alpha, src2, beta, gamma, dst, CV_MAT_DEPTH(ddepth)); +} #endif // CV_TYPE_COMPATIBLE_API /** @brief Scales, calculates absolute values, and converts the result to 8-bit. @@ -768,6 +804,15 @@ static inline void batchDistance(InputArray src1, InputArray src2, { batchDistance(src1, src2, dist, static_cast(ddepth), nidx, normType, K, mask, update, crosscheck); } +CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(dtype, ddepth) +static inline void batchDistance(InputArray src1, InputArray src2, + OutputArray dist, ElemType ddepth, OutputArray nidx, + int normType = NORM_L2, int K = 0, + InputArray mask = noArray(), int update = 0, + bool crosscheck = false) +{ + batchDistance(src1, src2, dist, CV_MAT_DEPTH(ddepth), nidx, normType, K, mask, update, crosscheck); +} #endif // CV_TYPE_COMPATIBLE_API @@ -831,12 +876,18 @@ normalization. CV_EXPORTS_W void normalize( InputArray src, InputOutputArray dst, double alpha = 1, double beta = 0, int norm_type = NORM_L2, ElemDepth ddepth = CV_DEPTH_AUTO, InputArray mask = noArray()); #ifdef CV_TYPE_COMPATIBLE_API -CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) +CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(dtype, ddepth) static inline void normalize( InputArray src, InputOutputArray dst, double alpha, double beta, int norm_type, int ddepth, InputArray mask = noArray()) { normalize(src, dst, alpha, beta, norm_type, static_cast(ddepth), mask); } +CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(dtype, ddepth) +static inline void normalize( InputArray src, InputOutputArray dst, double alpha, double beta, + int norm_type, ElemType ddepth, InputArray mask = noArray()) +{ + normalize(src, dst, alpha, beta, norm_type, CV_MAT_DEPTH(ddepth), mask); +} #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -936,11 +987,16 @@ otherwise, its type will be CV_MAKE_TYPE(ddepth, src.channels()). CV_EXPORTS_W void reduce(InputArray src, OutputArray dst, int dim, int rtype, ElemDepth ddepth = CV_DEPTH_AUTO); #ifdef CV_TYPE_COMPATIBLE_API -CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) +CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(dtype, ddepth) static inline void reduce(InputArray src, OutputArray dst, int dim, int rtype, int ddepth) { reduce(src, dst, dim, rtype, static_cast(ddepth)); } +CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(dtype, ddepth) +static inline void reduce(InputArray src, OutputArray dst, int dim, int rtype, ElemType ddepth) +{ + reduce(src, dst, dim, rtype, CV_MAT_DEPTH(ddepth)); +} #endif // CV_TYPE_COMPATIBLE_API /** @brief Creates one multi-channel array out of several single-channel ones. @@ -1735,13 +1791,20 @@ CV_EXPORTS_W void mulTransposed( InputArray src, OutputArray dst, bool aTa, InputArray delta = noArray(), double scale = 1, ElemDepth ddepth = CV_DEPTH_AUTO); #ifdef CV_TYPE_COMPATIBLE_API -CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) +CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(dtype, ddepth) static inline void mulTransposed(InputArray src, OutputArray dst, bool aTa, InputArray delta, double scale, int ddepth) { mulTransposed(src, dst, aTa, delta, scale, static_cast(ddepth)); } +CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(dtype, ddepth) +static inline void mulTransposed(InputArray src, OutputArray dst, bool aTa, + InputArray delta, + double scale, ElemType ddepth) +{ + mulTransposed(src, dst, aTa, delta, scale, CV_MAT_DEPTH(ddepth)); +} #endif // CV_TYPE_COMPATIBLE_API /** @brief Transposes a matrix. @@ -2032,12 +2095,18 @@ the set of input vectors. CV_EXPORTS void calcCovarMatrix( const Mat* samples, int nsamples, Mat& covar, Mat& mean, int flags, ElemDepth cdepth = CV_64F); #ifdef CV_TYPE_COMPATIBLE_API -CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(ctype, ctype) +CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(ctype, ctype) static inline void calcCovarMatrix(const Mat* samples, int nsamples, Mat& covar, Mat& mean, int flags, int ctype) { calcCovarMatrix(samples, nsamples, covar, mean, flags, static_cast(ctype)); } +CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(ctype, ctype) +static inline void calcCovarMatrix(const Mat* samples, int nsamples, Mat& covar, Mat& mean, + int flags, ElemType ctype) +{ + calcCovarMatrix(samples, nsamples, covar, mean, flags, CV_MAT_DEPTH(ctype)); +} #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -2051,12 +2120,18 @@ static inline void calcCovarMatrix(const Mat* samples, int nsamples, Mat& covar, CV_EXPORTS_W void calcCovarMatrix( InputArray samples, OutputArray covar, InputOutputArray mean, int flags, ElemDepth cdepth = CV_64F); #ifdef CV_TYPE_COMPATIBLE_API -CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(ctype, ctype) +CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(ctype, ctype) static inline void calcCovarMatrix(InputArray samples, OutputArray covar, InputOutputArray mean, int flags, int ctype) { calcCovarMatrix(samples, covar, mean, flags, static_cast(ctype)); } +CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(ctype, ctype) +static inline void calcCovarMatrix(InputArray samples, OutputArray covar, + InputOutputArray mean, int flags, ElemType ctype) +{ + calcCovarMatrix(samples, covar, mean, flags, CV_MAT_DEPTH(ctype)); +} #endif // CV_TYPE_COMPATIBLE_API diff --git a/modules/core/include/opencv2/core/base.hpp b/modules/core/include/opencv2/core/base.hpp index 4eeee67ee35e..8965ad17f718 100644 --- a/modules/core/include/opencv2/core/base.hpp +++ b/modules/core/include/opencv2/core/base.hpp @@ -63,29 +63,43 @@ #define CV_DEPRECATED_MAX_DEPTH_INT "max() between `ElemDepth` and `int` is deprecated" #define CV_DEPRECATED_MIN_DEPTH_DEPTH "use `CV_MIN_DEPTH(...)` instead" #define CV_DEPRECATED_MIN_DEPTH_INT "min() between `ElemDepth` and `int` is deprecated" -#define CV_DEPRECATED_ELEMTYPE_CMP_INT "comparing `ElemType` directly with `int` is deprecated. " +#define CV_DEPRECATED_ELEMDEPTH_CMP_ELEMTYPE "comparing `ElemType` and `ElemDepth` directly with each other is deprecated. " \ + "Use `mat.depth()` or `CV_MAT_DEPTH(type)` for depth comparsion, or CV_MAKETYPE(depth, cn) for type comparsion instead. " \ + " You can also utilize `mat.channels()` or `CV_MAT_CN(type)` for the number of channels" +#define CV_DEPRECATED_ELEMTYPE_CMP_INT "comparing `ElemDepth` directly with `int` is deprecated. " +#define CV_DEPRECATED_ELEMDEPTH_CMP_INT "comparing `ElemDepth` directly with `int` is deprecated. " #define CV_DEPRECATED_PARAM(depr_type, depr_var, new_type, new_var) \ "parameter `" CV_STR(depr_type) " " CV_STR(depr_var) "` is deprecated. " \ "Use `" CV_STR(new_type) " " CV_STR(new_var) "` instead" -#ifdef OPENCV_ENABLE_DEPRECATED_WARNING_ELEMTYPE_OVERLOAD +#ifdef OPENCV_ENABLE_DEPRECATED_WARNING_ELEMDEPTH_ELEMTYPE_OVERLOAD # define CV_DEPRECATED_MAX_DEPTH_DEPTH_ATTR CV_DEPRECATED_MSG(CV_DEPRECATED_MAX_DEPTH_DEPTH) # define CV_DEPRECATED_MIN_DEPTH_DEPTH_ATTR CV_DEPRECATED_MSG(CV_DEPRECATED_MIN_DEPTH_DEPTH) +# define CV_DEPRECATED_ELEMDEPTH_CMP_ELEMTYPE_ATTR CV_DEPRECATED_MSG(CV_DEPRECATED_ELEMDEPTH_CMP_ELEMTYPE) +# define CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(depr_var, new_var) CV_DEPRECATED_MSG(CV_DEPRECATED_PARAM(ElemDepth, depr_var, ElemType, new_var)) +# define CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(depr_var, new_var) CV_DEPRECATED_MSG(CV_DEPRECATED_PARAM(ElemType, depr_var, ElemDepth, new_var)) #else # define CV_DEPRECATED_MAX_DEPTH_DEPTH_ATTR /* nothing, default */ # define CV_DEPRECATED_MIN_DEPTH_DEPTH_ATTR /* nothing, default */ +# define CV_DEPRECATED_ELEMDEPTH_CMP_ELEMTYPE_ATTR /* nothing, default */ +# define CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(depr_var, new_var) /* nothing, default */ +# define CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(depr_var, new_var) /* nothing, default */ #endif #ifndef OPENCV_DISABLE_DEPRECATED_WARNING_INT_ELEMTYPE_OVERLOAD # define CV_DEPRECATED_MAX_DEPTH_INT_ATTR CV_DEPRECATED_MSG(CV_DEPRECATED_MAX_DEPTH_INT) # define CV_DEPRECATED_MIN_DEPTH_INT_ATTR CV_DEPRECATED_MSG(CV_DEPRECATED_MIN_DEPTH_INT) # define CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR CV_DEPRECATED_MSG(CV_DEPRECATED_ELEMTYPE_CMP_INT) +# define CV_DEPRECATED_ELEMDEPTH_CMP_INT_ATTR CV_DEPRECATED_MSG(CV_DEPRECATED_ELEMDEPTH_CMP_INT) +# define CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(depr_var, new_var) CV_DEPRECATED_MSG(CV_DEPRECATED_PARAM(int, depr_var, ElemDepth, new_var)) # define CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(depr_var, new_var) CV_DEPRECATED_MSG(CV_DEPRECATED_PARAM(int, depr_var, ElemType, new_var)) #else # define CV_DEPRECATED_MAX_DEPTH_INT_ATTR /* nothing */ # define CV_DEPRECATED_MIN_DEPTH_INT_ATTR /* nothing */ # define CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR /* nothing */ +# define CV_DEPRECATED_ELEMDEPTH_CMP_INT_ATTR /* nothing */ +# define CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(depr_var, new_var) /* nothing */ # define CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(depr_var, new_var) /* nothing */ #endif @@ -160,21 +174,45 @@ ATTRIBUTES static inline bool operator>(const LType left, const RType right) //CV_OPERATOR_LOGICAL_EQ(ElemType, int, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); //CV_OPERATOR_LOGICAL_EQ(int, ElemType, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); +//CV_OPERATOR_LOGICAL_EQ(ElemDepth, int, CV_DEPRECATED_ELEMDEPTH_CMP_INT_ATTR); +//CV_OPERATOR_LOGICAL_EQ(int, ElemDepth, CV_DEPRECATED_ELEMDEPTH_CMP_INT_ATTR); +CV_OPERATOR_LOGICAL_EQ(ElemDepth, ElemType, CV_DEPRECATED_ELEMDEPTH_CMP_ELEMTYPE_ATTR); +CV_OPERATOR_LOGICAL_EQ(ElemType, ElemDepth, CV_DEPRECATED_ELEMDEPTH_CMP_ELEMTYPE_ATTR); //CV_OPERATOR_LOGICAL_NOT_EQ(ElemType, int, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); //CV_OPERATOR_LOGICAL_NOT_EQ(int, ElemType, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); +//CV_OPERATOR_LOGICAL_NOT_EQ(ElemDepth, int, CV_DEPRECATED_ELEMDEPTH_CMP_INT_ATTR); +//CV_OPERATOR_LOGICAL_NOT_EQ(int, ElemDepth, CV_DEPRECATED_ELEMDEPTH_CMP_INT_ATTR); +CV_OPERATOR_LOGICAL_NOT_EQ(ElemDepth, ElemType, CV_DEPRECATED_ELEMDEPTH_CMP_ELEMTYPE_ATTR); +CV_OPERATOR_LOGICAL_NOT_EQ(ElemType, ElemDepth, CV_DEPRECATED_ELEMDEPTH_CMP_ELEMTYPE_ATTR); CV_OPERATOR_LE(ElemType, int, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); CV_OPERATOR_LE(int, ElemType, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); +CV_OPERATOR_LE(ElemDepth, int, CV_DEPRECATED_ELEMDEPTH_CMP_INT_ATTR); +CV_OPERATOR_LE(int, ElemDepth, CV_DEPRECATED_ELEMDEPTH_CMP_INT_ATTR); +CV_OPERATOR_LE(ElemDepth, ElemType, CV_DEPRECATED_ELEMDEPTH_CMP_ELEMTYPE_ATTR); +CV_OPERATOR_LE(ElemType, ElemDepth, CV_DEPRECATED_ELEMDEPTH_CMP_ELEMTYPE_ATTR); CV_OPERATOR_LT(ElemType, int, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); CV_OPERATOR_LT(int, ElemType, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); +CV_OPERATOR_LT(ElemDepth, int, CV_DEPRECATED_ELEMDEPTH_CMP_INT_ATTR); +CV_OPERATOR_LT(int, ElemDepth, CV_DEPRECATED_ELEMDEPTH_CMP_INT_ATTR); +CV_OPERATOR_LT(ElemDepth, ElemType, CV_DEPRECATED_ELEMDEPTH_CMP_ELEMTYPE_ATTR); +CV_OPERATOR_LT(ElemType, ElemDepth, CV_DEPRECATED_ELEMDEPTH_CMP_ELEMTYPE_ATTR); CV_OPERATOR_GE(ElemType, int, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); CV_OPERATOR_GE(int, ElemType, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); +CV_OPERATOR_GE(ElemDepth, int, CV_DEPRECATED_ELEMDEPTH_CMP_INT_ATTR); +CV_OPERATOR_GE(int, ElemDepth, CV_DEPRECATED_ELEMDEPTH_CMP_INT_ATTR); +CV_OPERATOR_GE(ElemDepth, ElemType, CV_DEPRECATED_ELEMDEPTH_CMP_ELEMTYPE_ATTR); +CV_OPERATOR_GE(ElemType, ElemDepth, CV_DEPRECATED_ELEMDEPTH_CMP_ELEMTYPE_ATTR); CV_OPERATOR_GT(ElemType, int, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); CV_OPERATOR_GT(int, ElemType, CV_DEPRECATED_ELEMTYPE_CMP_INT_ATTR); +CV_OPERATOR_GT(ElemDepth, int, CV_DEPRECATED_ELEMDEPTH_CMP_INT_ATTR); +CV_OPERATOR_GT(int, ElemDepth, CV_DEPRECATED_ELEMDEPTH_CMP_INT_ATTR); +CV_OPERATOR_GT(ElemDepth, ElemType, CV_DEPRECATED_ELEMDEPTH_CMP_ELEMTYPE_ATTR); +CV_OPERATOR_GT(ElemType, ElemDepth, CV_DEPRECATED_ELEMDEPTH_CMP_ELEMTYPE_ATTR); #endif // CV_TYPE_COMPATIBLE_API diff --git a/modules/core/include/opencv2/core/check.hpp b/modules/core/include/opencv2/core/check.hpp index 451ca21e4051..fef66ea9c26d 100644 --- a/modules/core/include/opencv2/core/check.hpp +++ b/modules/core/include/opencv2/core/check.hpp @@ -99,6 +99,10 @@ static inline void CV_NORETURN check_failed_MatDepth(const int v1, const int v2, { check_failed_MatDepth(static_cast(v1), static_cast(v2), ctx); } +static inline void CV_NORETURN check_failed_MatDepth(const ElemType v1, const ElemType v2, const CheckContext& ctx) +{ + check_failed_MatDepth(CV_MAT_DEPTH(v1), CV_MAT_DEPTH(v2), ctx); +} #endif // CV_TRANSNATIONAL_API CV_EXPORTS void CV_NORETURN check_failed_MatType(const ElemType v1, const ElemType v2, const CheckContext& ctx); #ifdef CV_TRANSNATIONAL_API @@ -106,6 +110,10 @@ static inline void CV_NORETURN check_failed_MatType(const int v1, const int v2, { check_failed_MatType(static_cast(v1), static_cast(v2), ctx); } +static inline void CV_NORETURN check_failed_MatType(const ElemDepth v1, const ElemDepth v2, const CheckContext& ctx) +{ + check_failed_MatType(CV_MAKETYPE(v1, 1), CV_MAKETYPE(v2, 1), ctx); +} #endif // CV_TRANSNATIONAL_API CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v1, const int v2, const CheckContext& ctx); diff --git a/modules/core/include/opencv2/core/cuda.hpp b/modules/core/include/opencv2/core/cuda.hpp index 326171dce5ef..68030a9b5f58 100644 --- a/modules/core/include/opencv2/core/cuda.hpp +++ b/modules/core/include/opencv2/core/cuda.hpp @@ -130,6 +130,11 @@ class CV_EXPORTS_W GpuMat : GpuMat(_rows, _cols, static_cast(_type), _allocator) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline GpuMat(int _rows, int _cols, ElemDepth _type, GpuMat::Allocator* _allocator = GpuMat::defaultAllocator()) + : GpuMat(_rows, _cols, CV_MAKETYPE(_type, 1), _allocator) + { + } #endif // CV_TYPE_COMPATIBLE_API CV_WRAP GpuMat(Size size, ElemType type, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); #ifdef CV_TYPE_COMPATIBLE_API @@ -138,6 +143,11 @@ class CV_EXPORTS_W GpuMat : GpuMat(_size, static_cast(_type), _allocator) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline GpuMat(Size _size, ElemDepth _type, GpuMat::Allocator* _allocator = GpuMat::defaultAllocator()) + : GpuMat(_size, CV_MAKETYPE(_type, 1), _allocator) + { + } #endif // CV_TYPE_COMPATIBLE_API //! constucts GpuMat and fills it with the specified value _s @@ -148,6 +158,11 @@ class CV_EXPORTS_W GpuMat : GpuMat(_rows, _cols, static_cast(_type), s, _allocator) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline GpuMat(int _rows, int _cols, ElemDepth _type, Scalar s, GpuMat::Allocator* _allocator = GpuMat::defaultAllocator()) + : GpuMat(_rows, _cols, CV_MAKETYPE(_type, 1), s, _allocator) + { + } #endif // CV_TYPE_COMPATIBLE_API CV_WRAP GpuMat(Size size, ElemType type, Scalar s, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); #ifdef CV_TYPE_COMPATIBLE_API @@ -156,6 +171,11 @@ class CV_EXPORTS_W GpuMat : GpuMat(_size, static_cast(_type), s, _allocator) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline GpuMat(Size _size, ElemDepth _type, Scalar s, GpuMat::Allocator* _allocator = GpuMat::defaultAllocator()) + : GpuMat(_size, CV_MAKETYPE(_type, 1), s, _allocator) + { + } #endif // CV_TYPE_COMPATIBLE_API //! copy constructor @@ -169,6 +189,11 @@ class CV_EXPORTS_W GpuMat : GpuMat(_rows, _cols, static_cast(_type), _data, _step) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline GpuMat(int _rows, int _cols, ElemDepth _type, void* _data, size_t _step = Mat::AUTO_STEP) + : GpuMat(_rows, _cols, CV_MAKETYPE(_type, 1), _data, _step) + { + } #endif // CV_TYPE_COMPATIBLE_API CV_WRAP GpuMat(Size size, ElemType type, void* data, size_t step = Mat::AUTO_STEP); #ifdef CV_TYPE_COMPATIBLE_API @@ -177,6 +202,11 @@ class CV_EXPORTS_W GpuMat : GpuMat(_size, static_cast(_type), _data, _step) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline GpuMat(Size _size, ElemDepth _type, void* _data, size_t _step = Mat::AUTO_STEP) + : GpuMat(_size, CV_MAKETYPE(_type, 1), _data, _step) + { + } #endif // CV_TYPE_COMPATIBLE_API //! creates a GpuMat header for a part of the bigger matrix @@ -200,6 +230,11 @@ class CV_EXPORTS_W GpuMat { create(_rows, _cols, static_cast(_type)); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline void create(int _rows, int _cols, ElemDepth _type) + { + create(_rows, _cols, CV_MAKETYPE(_type, 1)); + } #endif // CV_TYPE_COMPATIBLE_API CV_WRAP void create(Size size, ElemType type); #ifdef CV_TYPE_COMPATIBLE_API @@ -208,6 +243,11 @@ class CV_EXPORTS_W GpuMat { create(_size, static_cast(_type)); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline void create(Size _size, ElemDepth _type) + { + create(_size, CV_MAKETYPE(_type, 1)); + } #endif // CV_TYPE_COMPATIBLE_API //! decreases reference counter, deallocate the data when reference counter reaches 0 @@ -280,61 +320,91 @@ class CV_EXPORTS_W GpuMat //! converts GpuMat to another datatype (Blocking call) CV_WRAP void convertTo(OutputArray dst, ElemDepth ddepth) const; #ifdef CV_TYPE_COMPATIBLE_API - CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) + CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(dtype, ddepth) inline void convertTo(OutputArray dst, int ddepth) const { convertTo(dst, static_cast(ddepth)); } + CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(dtype, ddepth) + inline void convertTo(OutputArray dst, ElemType ddepth) const + { + convertTo(dst, CV_MAT_DEPTH(ddepth)); + } #endif // CV_TYPE_COMPATIBLE_API //! converts GpuMat to another datatype (Non-Blocking call) CV_WRAP void convertTo(OutputArray dst, ElemDepth ddepth, Stream& stream) const; #ifdef CV_TYPE_COMPATIBLE_API - CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) + CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(dtype, ddepth) inline void convertTo(OutputArray dst, int ddepth, Stream& stream) const { convertTo(dst, static_cast(ddepth), stream); } + CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(dtype, ddepth) + inline void convertTo(OutputArray dst, ElemType ddepth, Stream& stream) const + { + convertTo(dst, CV_MAT_DEPTH(ddepth), stream); + } #endif // CV_TYPE_COMPATIBLE_API //! converts GpuMat to another datatype with scaling (Blocking call) CV_WRAP void convertTo(OutputArray dst, ElemDepth ddepth, double alpha, double beta = 0.0) const; #ifdef CV_TYPE_COMPATIBLE_API - CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) + CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(dtype, ddepth) inline void convertTo(OutputArray dst, int ddepth, double alpha, double beta = 0.0) const { convertTo(dst, static_cast(ddepth), alpha, beta ); } + CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(dtype, ddepth) + inline void convertTo(OutputArray dst, ElemType ddepth, double alpha, double beta = 0.0) const + { + convertTo(dst, CV_MAT_DEPTH(ddepth), alpha, beta); + } #endif // CV_TYPE_COMPATIBLE_API //! converts GpuMat to another datatype with scaling (Non-Blocking call) CV_WRAP void convertTo(OutputArray dst, ElemDepth ddepth, double alpha, Stream& stream) const; #ifdef CV_TYPE_COMPATIBLE_API - CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) + CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(dtype, ddepth) inline void convertTo(OutputArray dst, int ddepth, double alpha, Stream& stream) const { convertTo(dst, static_cast(ddepth), alpha, stream); } + CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(dtype, ddepth) + inline void convertTo(OutputArray dst, ElemType ddepth, double alpha, Stream& stream) const + { + convertTo(dst, CV_MAT_DEPTH(ddepth), alpha, stream); + } #endif // CV_TYPE_COMPATIBLE_API //! converts GpuMat to another datatype with scaling (Non-Blocking call) CV_WRAP void convertTo(OutputArray dst, ElemDepth ddepth, double alpha, double beta, Stream& stream) const; #ifdef CV_TYPE_COMPATIBLE_API - CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) + CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(dtype, ddepth) inline void convertTo(OutputArray dst, int ddepth, double alpha, double beta, Stream& stream) const { convertTo(dst, static_cast(ddepth), alpha, beta, stream); } + CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(dtype, ddepth) + inline void convertTo(OutputArray dst, ElemType ddepth, double alpha, double beta, Stream& stream) const + { + convertTo(dst, CV_MAT_DEPTH(ddepth), alpha, beta, stream); + } #endif // CV_TYPE_COMPATIBLE_API CV_WRAP void assignTo(GpuMat& m, ElemDepth depth = CV_DEPTH_AUTO) const; #ifdef CV_TYPE_COMPATIBLE_API - CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(type, depth) inline void assignTo(GpuMat& m, int _depth) const { assignTo(m, static_cast(_depth) ); } + CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(type, depth) + inline void assignTo(GpuMat& m, ElemType _depth) const + { + assignTo(m, CV_MAT_DEPTH(_depth)); + } #endif // CV_TYPE_COMPATIBLE_API //! returns pointer to y-th row @@ -454,6 +524,11 @@ static inline void createContinuous(int _rows, int _cols, int _type, OutputArray { createContinuous(_rows, _cols, static_cast(_type), arr); } +CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) +static inline void createContinuous(int _rows, int _cols, ElemDepth _type, OutputArray arr) +{ + createContinuous(_rows, _cols, CV_MAKETYPE(_type, 1), arr); +} #endif // CV_TYPE_COMPATIBLE_API /** @brief Ensures that the size of a matrix is big enough and the matrix has a proper type. @@ -472,6 +547,11 @@ static inline void ensureSizeIsEnough(int _rows, int _cols, int _type, OutputArr { ensureSizeIsEnough(_rows, _cols, static_cast(_type), arr); } +CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) +static inline void ensureSizeIsEnough(int _rows, int _cols, ElemDepth _type, OutputArray arr) +{ + ensureSizeIsEnough(_rows, _cols, CV_MAKETYPE(_type, 1), arr); +} #endif // CV_TYPE_COMPATIBLE_API /** @brief BufferPool for use with CUDA streams @@ -606,6 +686,11 @@ class CV_EXPORTS_W BufferPool { return getBuffer(_rows, _cols, static_cast(_type)); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline GpuMat getBuffer(int _rows, int _cols, ElemDepth _type) + { + return getBuffer(_rows, _cols, CV_MAKETYPE(_type, 1)); + } #endif // CV_TYPE_COMPATIBLE_API //! Allocates a new GpuMat of given size and type. @@ -616,6 +701,11 @@ class CV_EXPORTS_W BufferPool { return getBuffer(_size, static_cast(_type)); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline GpuMat getBuffer(Size _size, ElemDepth _type) + { + return getBuffer(_size, CV_MAKETYPE(_type, 1)); + } #endif // CV_TYPE_COMPATIBLE_API //! Returns the allocator associated with the stream. @@ -666,6 +756,11 @@ class CV_EXPORTS_W HostMem : HostMem(_rows, _cols, static_cast(_type), _alloc_type) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline HostMem(int _rows, int _cols, ElemDepth _type, HostMem::AllocType _alloc_type = HostMem::AllocType::PAGE_LOCKED) + : HostMem(_rows, _cols, CV_MAKETYPE(_type, 1), _alloc_type) + { + } #endif // CV_TYPE_COMPATIBLE_API CV_WRAP HostMem(Size size, ElemType type, HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); #ifdef CV_TYPE_COMPATIBLE_API @@ -674,6 +769,11 @@ class CV_EXPORTS_W HostMem : HostMem(_size, static_cast(_type), _alloc_type) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline HostMem(Size _size, ElemDepth _type, HostMem::AllocType _alloc_type = HostMem::AllocType::PAGE_LOCKED) + : HostMem(_size, CV_MAKETYPE(_type, 1), _alloc_type) + { + } #endif // CV_TYPE_COMPATIBLE_API //! creates from host memory with coping data @@ -697,6 +797,11 @@ class CV_EXPORTS_W HostMem { create(_rows, _cols, static_cast(_type)); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline void create(int _rows, int _cols, ElemDepth _type) + { + create(_rows, _cols, CV_MAKETYPE(_type, 1)); + } #endif // CV_TYPE_COMPATIBLE_API void create(Size size, ElemType type); #ifdef CV_TYPE_COMPATIBLE_API @@ -705,6 +810,11 @@ class CV_EXPORTS_W HostMem { create(_size, static_cast(_type)); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline void create(Size _size, ElemDepth _type) + { + create(_size, CV_MAKETYPE(_type, 1)); + } #endif // CV_TYPE_COMPATIBLE_API //! creates alternative HostMem header for the same data, with different diff --git a/modules/core/include/opencv2/core/cuda.inl.hpp b/modules/core/include/opencv2/core/cuda.inl.hpp index 04a219300cc2..97a738758f29 100644 --- a/modules/core/include/opencv2/core/cuda.inl.hpp +++ b/modules/core/include/opencv2/core/cuda.inl.hpp @@ -357,6 +357,11 @@ GpuMat createContinuous(int rows, int cols, int type) { return createContinuous(rows, cols, static_cast(type)); } +static inline +GpuMat createContinuous(int rows, int cols, ElemDepth type) +{ + return createContinuous(rows, cols, static_cast(type)); +} #endif // CV_TRANSNATIONAL_API static inline @@ -371,6 +376,11 @@ void createContinuous(Size size, int type, OutputArray arr) { createContinuous(size, static_cast(type), arr); } +static inline +void createContinuous(Size size, ElemDepth type, OutputArray arr) +{ + createContinuous(size, static_cast(type), arr); +} #endif // CV_TRANSNATIONAL_API static inline @@ -387,6 +397,11 @@ GpuMat createContinuous(Size size, int type) { return createContinuous(size, static_cast(type)); } +static inline +GpuMat createContinuous(Size size, ElemDepth type) +{ + return createContinuous(size, static_cast(type)); +} #endif // CV_TRANSNATIONAL_API static inline @@ -401,6 +416,11 @@ void ensureSizeIsEnough(Size size, int type, OutputArray arr) { ensureSizeIsEnough(size, static_cast(type), arr); } +static inline +void ensureSizeIsEnough(Size size, ElemDepth type, OutputArray arr) +{ + ensureSizeIsEnough(size, static_cast(type), arr); +} #endif // CV_TRANSNATIONAL_API static inline diff --git a/modules/core/include/opencv2/core/hal/hal.hpp b/modules/core/include/opencv2/core/hal/hal.hpp index eb175fb601bb..f9a7065f19cc 100644 --- a/modules/core/include/opencv2/core/hal/hal.hpp +++ b/modules/core/include/opencv2/core/hal/hal.hpp @@ -205,10 +205,14 @@ struct CV_EXPORTS DFT1D { static Ptr create(int len, int count, ElemDepth depth, int flags, bool * useBuffer = 0); #ifdef CV_TYPE_COMPATIBLE_API - CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(type, depth) static inline Ptr create(int len, int count, int depth, int flags, bool * useBuffer = 0) { return create(len, count, static_cast(depth), flags, useBuffer); } + CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(type, depth) + static inline Ptr create(int len, int count, ElemType depth, int flags, bool * useBuffer = 0) + { return create(len, count, CV_MAT_DEPTH(depth), flags, useBuffer); + } #endif // CV_TYPE_COMPATIBLE_API virtual void apply(const uchar *src, uchar *dst) = 0; virtual ~DFT1D() {} @@ -220,12 +224,18 @@ struct CV_EXPORTS DFT2D int src_channels, int dst_channels, int flags, int nonzero_rows = 0); #ifdef CV_TYPE_COMPATIBLE_API - CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(type, depth) static inline Ptr create(int width, int height, int depth, int src_channels, int dst_channels, int flags, int nonzero_rows = 0) { return create(width, height, static_cast(depth), src_channels, dst_channels, flags, nonzero_rows); } + CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(type, depth) + static inline Ptr create(int width, int height, ElemType depth, + int src_channels, int dst_channels, + int flags, int nonzero_rows = 0) + { return create(width, height, static_cast(depth), src_channels, dst_channels, flags, nonzero_rows); + } #endif // CV_TYPE_COMPATIBLE_API virtual void apply(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step) = 0; virtual ~DFT2D() {} @@ -235,10 +245,14 @@ struct CV_EXPORTS DCT2D { static Ptr create(int width, int height, ElemDepth depth, int flags); #ifdef CV_TYPE_COMPATIBLE_API - CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(type, depth) static inline Ptr create(int width, int height, int depth, int flags) { return create(width, height, static_cast(depth), flags); } + CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(type, depth) + static inline Ptr create(int width, int height, ElemType depth, int flags) + { return create(width, height, static_cast(depth), flags); + } #endif // CV_TYPE_COMPATIBLE_API virtual void apply(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step) = 0; virtual ~DCT2D() {} diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index 25908b1355c1..b99bfb05c855 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -84,6 +84,10 @@ __CV_ENUM_FLAGS_BITWISE_OR(MagicFlag, ElemType, AccessFlag); __CV_ENUM_FLAGS_BITWISE_OR(MagicFlag, MagicFlag, AccessFlag); #endif +#ifdef CV_TRANSNATIONAL_API +__CV_ENUM_FLAGS_BITWISE_OR(MagicFlag, MagicFlag, ElemDepth); +#endif + CV__DEBUG_NS_BEGIN class CV_EXPORTS _OutputArray; @@ -392,6 +396,11 @@ class CV_EXPORTS _OutputArray : public _InputArray { create(_sz, static_cast(_type), i, allowTransposed, fixedDepthMask); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline void create(Size _sz, ElemDepth _type, int i = -1, bool allowTransposed = false, _OutputArray::DepthMask fixedDepthMask = static_cast<_OutputArray::DepthMask>(0)) const + { + create(_sz, CV_MAKETYPE(_type, 1), i, allowTransposed, fixedDepthMask); + } #endif // CV_TYPE_COMPATIBLE_API void create(int rows, int cols, ElemType type, int i = -1, bool allowTransposed = false, _OutputArray::DepthMask fixedDepthMask = static_cast<_OutputArray::DepthMask>(0)) const; #ifdef CV_TYPE_COMPATIBLE_API @@ -400,6 +409,11 @@ class CV_EXPORTS _OutputArray : public _InputArray { create(_rows, _cols, static_cast(_type), i, allowTransposed, fixedDepthMask); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline void create(int _rows, int _cols, ElemDepth _type, int i = -1, bool allowTransposed = false, _OutputArray::DepthMask fixedDepthMask = static_cast<_OutputArray::DepthMask>(0)) const + { + create(_rows, _cols, CV_MAKETYPE(_type, 1), i, allowTransposed, fixedDepthMask); + } #endif // CV_TYPE_COMPATIBLE_API void create(int dims, const int* size, ElemType type, int i = -1, bool allowTransposed = false, _OutputArray::DepthMask fixedDepthMask = static_cast<_OutputArray::DepthMask>(0)) const; #ifdef CV_TYPE_COMPATIBLE_API @@ -408,6 +422,11 @@ class CV_EXPORTS _OutputArray : public _InputArray { create(_dims, _size, static_cast(_type), i, allowTransposed, fixedDepthMask); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline void create(int _dims, const int* _size, ElemDepth _type, int i = -1, bool allowTransposed = false, _OutputArray::DepthMask fixedDepthMask = static_cast<_OutputArray::DepthMask>(0)) const + { + create(_dims, _size, CV_MAKETYPE(_type, 1), i, allowTransposed, fixedDepthMask); + } #endif // CV_TYPE_COMPATIBLE_API void createSameSize(const _InputArray& arr, ElemType mtype) const; #ifdef CV_TYPE_COMPATIBLE_API @@ -416,6 +435,11 @@ class CV_EXPORTS _OutputArray : public _InputArray { createSameSize(arr, static_cast(mtype)); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(mtype, mtype) + inline void createSameSize(const _InputArray& arr, ElemDepth mtype) const + { + createSameSize(arr, CV_MAKETYPE(mtype, 1)); + } #endif // CV_TYPE_COMPATIBLE_API void release() const; void clear() const; @@ -531,6 +555,11 @@ class CV_EXPORTS MatAllocator { return allocate(dims, _sizes, static_cast(_type), _data, _step, flags, _usageFlags); } + inline virtual UMatData* allocate(int dims, const int* _sizes, ElemDepth _type, + void* _data, size_t* _step, AccessFlag flags, UMatUsageFlags _usageFlags) const + { + return allocate(dims, _sizes, CV_MAKETYPE(_type, 1), _data, _step, flags, _usageFlags); + } #endif // CV_TRANSNATIONAL_API virtual bool allocate(UMatData* data, AccessFlag accessflags, UMatUsageFlags usageFlags) const = 0; virtual void deallocate(UMatData* data) const = 0; @@ -876,6 +905,11 @@ class CV_EXPORTS Mat : Mat(_rows, _cols, static_cast(_type)) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline Mat(int _rows, int _cols, ElemDepth _type) + : Mat(_rows, _cols, CV_MAKETYPE(_type, 1)) + { + } #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -891,6 +925,11 @@ class CV_EXPORTS Mat : Mat(_size, static_cast(_type)) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline Mat(Size _size, ElemDepth _type) + : Mat(_size, CV_MAKETYPE(_type, 1)) + { + } #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -909,6 +948,11 @@ class CV_EXPORTS Mat : Mat(_rows, _cols, static_cast(_type), s) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline Mat(int _rows, int _cols, ElemDepth _type, const Scalar& s) + : Mat(_rows, _cols, CV_MAKETYPE(_type, 1), s) + { + } #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -927,6 +971,11 @@ class CV_EXPORTS Mat : Mat(_size, static_cast(_type), s) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline Mat(Size _size, ElemDepth _type, const Scalar& s) + : Mat(_size, CV_MAKETYPE(_type, 1), s) + { + } #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -942,6 +991,11 @@ class CV_EXPORTS Mat : Mat(ndims, _sizes, static_cast(_type)) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline Mat(int ndims, const int* _sizes, ElemDepth _type) + : Mat(ndims, _sizes, CV_MAKETYPE(_type, 1)) + { + } #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -956,6 +1010,11 @@ class CV_EXPORTS Mat : Mat(_sizes, static_cast(_type)) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline Mat(const std::vector& _sizes, ElemDepth _type) + : Mat(_sizes, CV_MAKETYPE(_type, 1)) + { + } #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -974,6 +1033,11 @@ class CV_EXPORTS Mat : Mat(ndims, _sizes, static_cast(_type), s) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline Mat(int ndims, const int* _sizes, ElemDepth _type, const Scalar& s) + : Mat(ndims, _sizes, CV_MAKETYPE(_type, 1), s) + { + } #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -991,6 +1055,11 @@ class CV_EXPORTS Mat : Mat(_sizes, static_cast(_type), s) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline Mat(const std::vector& _sizes, ElemDepth _type, const Scalar& s) + : Mat(_sizes, CV_MAKETYPE(_type, 1), s) + { + } #endif // CV_TYPE_COMPATIBLE_API @@ -1024,6 +1093,11 @@ class CV_EXPORTS Mat : Mat(_rows, _cols, static_cast(_type), _data, _step) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline Mat(int _rows, int _cols, ElemDepth _type, void* _data, size_t _step = AUTO_STEP) + : Mat(_rows, _cols, CV_MAKETYPE(_type, 1), _data, _step) + { + } #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -1047,6 +1121,11 @@ class CV_EXPORTS Mat : Mat(_size, static_cast(_type), _data, _step) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline Mat(Size _size, ElemDepth _type, void* _data, size_t _step = AUTO_STEP) + : Mat(_size, CV_MAKETYPE(_type, 1), _data, _step) + { + } #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -1069,6 +1148,11 @@ class CV_EXPORTS Mat : Mat(ndims, _sizes, static_cast(_type), _data, steps) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline Mat(int ndims, const int* _sizes, ElemDepth _type, void* _data, const size_t* steps = 0) + : Mat(ndims, _sizes, CV_MAKETYPE(_type, 1), _data, steps) + { + } #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -1090,6 +1174,11 @@ class CV_EXPORTS Mat : Mat(_sizes, static_cast(_type), _data, steps) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline Mat(const std::vector& _sizes, ElemDepth _type, void* _data, const size_t* steps = 0) + : Mat(_sizes, CV_MAKETYPE(_type, 1), _data, steps) + { + } #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -1374,11 +1463,16 @@ class CV_EXPORTS Mat */ void convertTo(OutputArray m, ElemDepth ddepth, double alpha = 1, double beta = 0) const; #ifdef CV_TYPE_COMPATIBLE_API - CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) + CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(dtype, ddepth) inline void convertTo(OutputArray m, int ddepth, double alpha = 1, double beta = 0) const { convertTo(m, static_cast(ddepth), alpha, beta); } + CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(dtype, ddepth) + inline void convertTo(OutputArray m, ElemType ddepth, double alpha = 1, double beta = 0) const + { + convertTo(m, CV_MAT_DEPTH(ddepth), alpha, beta); + } #endif // CV_TYPE_COMPATIBLE_API /** @brief Provides a functional form of convertTo. @@ -1390,11 +1484,16 @@ class CV_EXPORTS Mat void assignTo(Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const; #ifdef CV_TYPE_COMPATIBLE_API - CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(type, depth) inline void assignTo(Mat& m, int _depth) const { assignTo(m, static_cast(_depth)); } + CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(type, depth) + inline void assignTo(Mat& m, ElemType _depth) const + { + assignTo(m, CV_MAT_DEPTH(_depth)); + } #endif // CV_TYPE_COMPATIBLE_API /** @brief Sets all or some of the array elements to the specified value. @@ -1515,6 +1614,8 @@ class CV_EXPORTS Mat #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) static MatExpr zeros(int rows, int cols, int _type); + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + static MatExpr zeros(int rows, int cols, ElemDepth _type); #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -1525,6 +1626,8 @@ class CV_EXPORTS Mat #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) static MatExpr zeros(Size size, int _type); + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + static MatExpr zeros(Size size, ElemDepth _type); #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -1536,6 +1639,8 @@ class CV_EXPORTS Mat #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) static MatExpr zeros(int ndims, const int* sz, int _type); + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + static MatExpr zeros(int ndims, const int* sz, ElemDepth _type); #endif // CV_TYPE_COMPATIBLE_API /** @brief Returns an array of all 1's of the specified size and type. @@ -1558,6 +1663,8 @@ class CV_EXPORTS Mat #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) static MatExpr ones(int rows, int cols, int _type); + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + static MatExpr ones(int rows, int cols, ElemDepth _type); #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -1568,6 +1675,8 @@ class CV_EXPORTS Mat #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) static MatExpr ones(Size size, int _type); + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + static MatExpr ones(Size size, ElemDepth _type); #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -1579,6 +1688,8 @@ class CV_EXPORTS Mat #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) static MatExpr ones(int ndims, const int* sz, int _type); + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + static MatExpr ones(int ndims, const int* sz, ElemDepth _type); #endif // CV_TYPE_COMPATIBLE_API /** @brief Returns an identity matrix of the specified size and type. @@ -1599,6 +1710,8 @@ class CV_EXPORTS Mat #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) static MatExpr eye(int rows, int cols, int _type); + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + static MatExpr eye(int rows, int cols, ElemDepth _type); #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -1609,6 +1722,8 @@ class CV_EXPORTS Mat #ifdef CV_TYPE_COMPATIBLE_API CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, type) static MatExpr eye(Size size, int _type); + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + static MatExpr eye(Size size, ElemDepth _type); #endif // CV_TYPE_COMPATIBLE_API /** @brief Allocates new array data if needed. @@ -1651,6 +1766,11 @@ class CV_EXPORTS Mat { create(_rows, _cols, static_cast(_type)); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline void create(int _rows, int _cols, ElemDepth _type) + { + create(_rows, _cols, CV_MAKETYPE(_type, 1)); + } #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -1664,6 +1784,11 @@ class CV_EXPORTS Mat { create(_size, static_cast(_type)); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline void create(Size _size, ElemDepth _type) + { + create(_size, CV_MAKETYPE(_type, 1)); + } #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -1678,6 +1803,11 @@ class CV_EXPORTS Mat { create(ndims, _sizes, static_cast(_type)); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline void create(int ndims, const int* _sizes, ElemDepth _type) + { + create(ndims, _sizes, CV_MAKETYPE(_type, 1)); + } #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -1691,6 +1821,11 @@ class CV_EXPORTS Mat { create(sizes, static_cast(_type)); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline void create(const std::vector& sizes, ElemDepth _type) + { + create(sizes, CV_MAKETYPE(_type, 1)); + } #endif // CV_TYPE_COMPATIBLE_API /** @brief Increments the reference counter. @@ -2046,11 +2181,16 @@ class CV_EXPORTS Mat int checkVector(int elemChannels, ElemDepth depth = CV_DEPTH_AUTO, bool requireContinuous = true) const; #ifdef CV_TYPE_COMPATIBLE_API - CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(type, depth) inline int checkVector(int elemChannels, int _depth, bool requireContinuous = true) const { return checkVector(elemChannels, static_cast(_depth), requireContinuous); } + CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(type, depth) + inline int checkVector(int elemChannels, ElemType _depth, bool requireContinuous = true) const + { + return checkVector(elemChannels, CV_MAT_DEPTH(_depth), requireContinuous); + } #endif // CV_TYPE_COMPATIBLE_API /** @brief Returns a pointer to the specified matrix row. @@ -2630,6 +2770,11 @@ class CV_EXPORTS UMat : UMat(_rows, _cols, static_cast(_type), _usageFlags) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline UMat(int _rows, int _cols, ElemDepth _type, UMatUsageFlags _usageFlags = USAGE_DEFAULT) + : UMat(_rows, _cols, CV_MAKETYPE(_type, 1), _usageFlags) + { + } #endif // CV_TYPE_COMPATIBLE_API UMat(Size size, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); #ifdef CV_TYPE_COMPATIBLE_API @@ -2638,6 +2783,11 @@ class CV_EXPORTS UMat : UMat(_size, static_cast(_type), _usageFlags) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline UMat(Size _size, ElemDepth _type, UMatUsageFlags _usageFlags = USAGE_DEFAULT) + : UMat(_size, CV_MAKETYPE(_type, 1), _usageFlags) + { + } #endif // CV_TYPE_COMPATIBLE_API //! constucts 2D matrix and fills it with the specified value _s. UMat(int rows, int cols, ElemType type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); @@ -2647,6 +2797,11 @@ class CV_EXPORTS UMat : UMat(_rows, _cols, static_cast(_type), s, _usageFlags) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline UMat(int _rows, int _cols, ElemDepth _type, const Scalar& s, UMatUsageFlags _usageFlags = USAGE_DEFAULT) + : UMat(_rows, _cols, CV_MAKETYPE(_type, 1), s, _usageFlags) + { + } #endif // CV_TYPE_COMPATIBLE_API UMat(Size size, ElemType type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); #ifdef CV_TYPE_COMPATIBLE_API @@ -2655,6 +2810,11 @@ class CV_EXPORTS UMat : UMat(_size, static_cast(_type), s, _usageFlags) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline UMat(Size _size, ElemDepth _type, const Scalar& s, UMatUsageFlags _usageFlags = USAGE_DEFAULT) + : UMat(_size, CV_MAKETYPE(_type, 1), s, _usageFlags) + { + } #endif // CV_TYPE_COMPATIBLE_API //! constructs n-dimensional matrix @@ -2665,6 +2825,11 @@ class CV_EXPORTS UMat : UMat(ndims, _sizes, static_cast(_type), _usageFlags) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline UMat(int ndims, const int* _sizes, ElemDepth _type, UMatUsageFlags _usageFlags = USAGE_DEFAULT) + : UMat(ndims, _sizes, CV_MAKETYPE(_type, 1), _usageFlags) + { + } #endif // CV_TYPE_COMPATIBLE_API UMat(int ndims, const int* sizes, ElemType type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); #ifdef CV_TYPE_COMPATIBLE_API @@ -2673,6 +2838,11 @@ class CV_EXPORTS UMat : UMat(ndims, _sizes, static_cast(_type), s, _usageFlags) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline UMat(int ndims, const int* _sizes, ElemDepth _type, const Scalar& s, UMatUsageFlags _usageFlags = USAGE_DEFAULT) + : UMat(ndims, _sizes, CV_MAKETYPE(_type, 1), s, _usageFlags) + { + } #endif // CV_TYPE_COMPATIBLE_API //! copy constructor @@ -2732,21 +2902,31 @@ class CV_EXPORTS UMat //! converts matrix to another datatype with optional scaling. See cvConvertScale. void convertTo(OutputArray m, ElemDepth ddepth, double alpha = 1, double beta = 0) const; #ifdef CV_TYPE_COMPATIBLE_API - CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) + CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(dtype, ddepth) inline void convertTo(OutputArray m, int ddepth, double alpha = 1, double beta = 0) const { convertTo(m, static_cast(ddepth), alpha, beta); } + CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(dtype, ddepth) + inline void convertTo(OutputArray m, ElemType ddepth, double alpha = 1, double beta = 0) const + { + convertTo(m, CV_MAT_DEPTH(ddepth), alpha, beta); + } #endif // CV_TYPE_COMPATIBLE_API void assignTo(UMat& m, ElemDepth depth = CV_DEPTH_AUTO) const; #ifdef CV_TYPE_COMPATIBLE_API - CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(type, depth) inline void assignTo(UMat& m, int _depth) const { assignTo(m, static_cast(_depth)); } + CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(type, depth) + inline void assignTo(UMat& m, ElemType _depth) const + { + assignTo(m, CV_MAT_DEPTH(_depth)); + } #endif // CV_TYPE_COMPATIBLE_API //! sets every matrix element to s @@ -2776,6 +2956,11 @@ class CV_EXPORTS UMat { return zeros(_rows, _cols, static_cast(_type)); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + static inline UMat zeros(int _rows, int _cols, ElemDepth _type) + { + return zeros(_rows, _cols, CV_MAKETYPE(_type, 1)); + } #endif // CV_TYPE_COMPATIBLE_API static UMat zeros(Size size, ElemType type); #ifdef CV_TYPE_COMPATIBLE_API @@ -2784,6 +2969,11 @@ class CV_EXPORTS UMat { return zeros(_size, static_cast(_type)); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + static inline UMat zeros(Size _size, ElemDepth _type) + { + return zeros(_size, CV_MAKETYPE(_type, 1)); + } #endif // CV_TYPE_COMPATIBLE_API static UMat zeros(int ndims, const int* sz, ElemType type); #ifdef CV_TYPE_COMPATIBLE_API @@ -2792,6 +2982,11 @@ class CV_EXPORTS UMat { return zeros(ndims, _sz, static_cast(_type)); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + static inline UMat zeros(int ndims, const int* _sz, ElemDepth _type) + { + return zeros(ndims, _sz, CV_MAKETYPE(_type, 1)); + } #endif // CV_TYPE_COMPATIBLE_API static UMat ones(int rows, int cols, ElemType type); #ifdef CV_TYPE_COMPATIBLE_API @@ -2800,6 +2995,11 @@ class CV_EXPORTS UMat { return ones(_rows, _cols, static_cast(_type)); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + static inline UMat ones(int _rows, int _cols, ElemDepth _type) + { + return ones(_rows, _cols, CV_MAKETYPE(_type, 1)); + } #endif // CV_TYPE_COMPATIBLE_API static UMat ones(Size size, ElemType type); #ifdef CV_TYPE_COMPATIBLE_API @@ -2808,6 +3008,11 @@ class CV_EXPORTS UMat { return ones(_size, static_cast(_type)); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + static inline UMat ones(Size _size, ElemDepth _type) + { + return ones(_size, CV_MAKETYPE(_type, 1)); + } #endif // CV_TYPE_COMPATIBLE_API static UMat ones(int ndims, const int* sz, ElemType type); #ifdef CV_TYPE_COMPATIBLE_API @@ -2816,6 +3021,11 @@ class CV_EXPORTS UMat { return ones(ndims, _sz, static_cast(_type)); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + static inline UMat ones(int ndims, const int* _sz, ElemDepth _type) + { + return ones(ndims, _sz, CV_MAKETYPE(_type, 1)); + } #endif // CV_TYPE_COMPATIBLE_API static UMat eye(int rows, int cols, ElemType type); #ifdef CV_TYPE_COMPATIBLE_API @@ -2824,6 +3034,11 @@ class CV_EXPORTS UMat { return eye(_rows, _cols, static_cast(_type)); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + static inline UMat eye(int _rows, int _cols, ElemDepth _type) + { + return eye(_rows, _cols, CV_MAKETYPE(_type, 1)); + } #endif // CV_TYPE_COMPATIBLE_API static UMat eye(Size size, ElemType type); #ifdef CV_TYPE_COMPATIBLE_API @@ -2832,6 +3047,11 @@ class CV_EXPORTS UMat { return eye(_size, static_cast(_type)); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + static inline UMat eye(Size _size, ElemDepth _type) + { + return eye(_size, CV_MAKETYPE(_type, 1)); + } #endif // CV_TYPE_COMPATIBLE_API //! allocates new matrix data unless the matrix already has specified size and type. @@ -2843,6 +3063,11 @@ class CV_EXPORTS UMat { create(_rows, _cols, static_cast(_type), _usageFlags); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline void create(int _rows, int _cols, ElemDepth _type, UMatUsageFlags _usageFlags = USAGE_DEFAULT) + { + create(_rows, _cols, CV_MAKETYPE(_type, 1), _usageFlags); + } #endif // CV_TYPE_COMPATIBLE_API void create(Size size, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); #ifdef CV_TYPE_COMPATIBLE_API @@ -2851,6 +3076,11 @@ class CV_EXPORTS UMat { create(_size, static_cast(_type), _usageFlags); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline void create(Size _size, ElemDepth _type, UMatUsageFlags _usageFlags = USAGE_DEFAULT) + { + create(_size, CV_MAKETYPE(_type, 1), _usageFlags); + } #endif // CV_TYPE_COMPATIBLE_API void create(int ndims, const int* sizes, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); #ifdef CV_TYPE_COMPATIBLE_API @@ -2859,6 +3089,11 @@ class CV_EXPORTS UMat { create(ndims, _sizes, static_cast(_type), _usageFlags); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline void create(int ndims, const int* _sizes, ElemDepth _type, UMatUsageFlags _usageFlags = USAGE_DEFAULT) + { + create(ndims, _sizes, CV_MAKETYPE(_type, 1), _usageFlags); + } #endif // CV_TYPE_COMPATIBLE_API void create(const std::vector& sizes, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); #ifdef CV_TYPE_COMPATIBLE_API @@ -2867,6 +3102,11 @@ class CV_EXPORTS UMat { create(sizes, static_cast(_type), _usageFlags); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) + inline void create(const std::vector& sizes, ElemDepth _type, UMatUsageFlags _usageFlags = USAGE_DEFAULT) + { + create(sizes, CV_MAKETYPE(_type, 1), _usageFlags); + } #endif // CV_TYPE_COMPATIBLE_API //! increases the reference counter; use with care to avoid memleaks @@ -2921,11 +3161,16 @@ class CV_EXPORTS UMat int checkVector(int elemChannels, ElemDepth depth = CV_DEPTH_AUTO, bool requireContinuous = true) const; #ifdef CV_TYPE_COMPATIBLE_API - CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(type, depth) inline int checkVector(int elemChannels, int _depth, bool requireContinuous = true) const { return checkVector(elemChannels, static_cast(_depth), requireContinuous ); } + CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(type, depth) + inline int checkVector(int elemChannels, ElemType _depth, bool requireContinuous = true) const + { + return checkVector(elemChannels, CV_MAT_DEPTH(_depth), requireContinuous ); + } #endif // CV_TYPE_COMPATIBLE_API UMat(UMat&& m); @@ -3089,6 +3334,11 @@ class CV_EXPORTS SparseMat : Hdr(_dims, _sizes, static_cast(_type)) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(_type, _type) + inline Hdr(int _dims, const int* _sizes, ElemDepth _type) + : Hdr(_dims, _sizes, CV_MAKETYPE(_type, 1)) + { + } #endif // CV_TYPE_COMPATIBLE_API void clear(); int refcount; @@ -3129,6 +3379,11 @@ class CV_EXPORTS SparseMat : SparseMat(_dims, _sizes, static_cast(_type)) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(_type, _type) + inline SparseMat(int _dims, const int* _sizes, ElemDepth _type) + : SparseMat(_dims, _sizes, CV_MAKETYPE(_type, 1)) + { + } #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -3161,11 +3416,16 @@ class CV_EXPORTS SparseMat //! multiplies all the matrix elements by the specified scale factor alpha and converts the results to the specified data type void convertTo(SparseMat& m, ElemDepth ddepth, double alpha = 1) const; #ifdef CV_TYPE_COMPATIBLE_API - CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) + CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(dtype, ddepth) inline void convertTo(SparseMat& m, int ddepth, double alpha = 1) const { convertTo(m, static_cast(ddepth), alpha ); } + CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(dtype, ddepth) + inline void convertTo(SparseMat& m, ElemType ddepth, double alpha = 1) const + { + convertTo(m, CV_MAT_DEPTH(ddepth), alpha ); + } #endif // CV_TYPE_COMPATIBLE_API //! converts sparse matrix to dense n-dim matrix with optional type conversion and scaling. /*! @@ -3177,22 +3437,32 @@ class CV_EXPORTS SparseMat */ void convertTo(Mat& m, ElemDepth ddepth, double alpha = 1, double beta = 0) const; #ifdef CV_TYPE_COMPATIBLE_API - CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) + CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(dtype, ddepth) inline void convertTo(Mat& m, int ddepth, double alpha = 1, double beta = 0) const { convertTo(m, static_cast(ddepth), alpha, beta ); } + CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(dtype, ddepth) + inline void convertTo(Mat& m, ElemType ddepth, double alpha = 1, double beta = 0) const + { + convertTo(m, CV_MAT_DEPTH(ddepth), alpha, beta ); + } #endif // CV_TYPE_COMPATIBLE_API // not used now void assignTo(SparseMat& m, ElemDepth depth = CV_DEPTH_AUTO) const; #ifdef CV_TYPE_COMPATIBLE_API - CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(type, depth) inline void assignTo(SparseMat& m, int _depth) const { assignTo(m, static_cast(_depth) ); } + CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(type, depth) + inline void assignTo(SparseMat& m, ElemType _depth) const + { + assignTo(m, CV_MAT_DEPTH(_depth) ); + } #endif // CV_TYPE_COMPATIBLE_API //! reallocates sparse matrix. @@ -3208,6 +3478,11 @@ class CV_EXPORTS SparseMat { create(_dims, _sizes, static_cast(_type)); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(_type, _type) + inline void create(int _dims, const int* _sizes, ElemDepth _type) + { + create(_dims, _sizes, CV_MAKETYPE(_type, 1)); + } #endif // CV_TYPE_COMPATIBLE_API //! sets all the sparse matrix elements to 0, which means clearing the hash table. void clear(); @@ -3887,11 +4162,16 @@ class CV_EXPORTS MatOp virtual void assign(const MatExpr& expr, Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const = 0; #ifdef CV_TYPE_COMPATIBLE_API - CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(type, depth) inline virtual void assign(const MatExpr& expr, Mat& m, int _depth) const { assign(expr, m, static_cast(_depth)); } + CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(type, depth) + inline virtual void assign(const MatExpr& expr, Mat& m, ElemType _depth) const + { + assign(expr, m, CV_MAT_DEPTH(_depth)); + } #endif // CV_TYPE_COMPATIBLE_API virtual void roi(const MatExpr& expr, const Range& rowRange, const Range& colRange, MatExpr& res) const; diff --git a/modules/core/include/opencv2/core/ocl.hpp b/modules/core/include/opencv2/core/ocl.hpp index 60d3e52cc3d0..e0e04e50c224 100644 --- a/modules/core/include/opencv2/core/ocl.hpp +++ b/modules/core/include/opencv2/core/ocl.hpp @@ -314,6 +314,11 @@ static inline void convertFromBuffer(void* cl_mem_buffer, size_t step, int rows, { convertFromBuffer(cl_mem_buffer, step, rows, cols, static_cast(type), dst); } +CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(type, type) +static inline void convertFromBuffer(void* cl_mem_buffer, size_t step, int rows, int cols, ElemDepth type, UMat& dst) +{ + convertFromBuffer(cl_mem_buffer, step, rows, cols, CV_MAKETYPE(type, 1), dst); +} #endif // CV_TYPE_COMPATIBLE_API /** @brief Convert OpenCL image2d_t to UMat @@ -744,6 +749,13 @@ static inline const char* convertTypeStr(int sdepth, int ddepth, int cn, char* b { return convertTypeStr(static_cast(sdepth), static_cast(ddepth), cn, buf); } +# ifdef OPENCV_ENABLE_DEPRECATED_WARNING_ELEMDEPTH_ELEMTYPE_OVERLOAD +CV_DEPRECATED_MSG(CV_DEPRECATED_PARAM(ElemType, stype, ElemDepth, sdepth) ". Similarly, " CV_DEPRECATED_PARAM(ElemType, dtype, ElemDepth, ddepth)) +# endif +static inline const char* convertTypeStr(ElemType sdepth, ElemType ddepth, int cn, char* buf) +{ + return convertTypeStr(CV_MAT_DEPTH(sdepth), CV_MAT_DEPTH(ddepth), cn, buf); +} #endif // CV_TYPE_COMPATIBLE_API CV_EXPORTS const char* typeToStr(int t); CV_EXPORTS const char* memopTypeToStr(int t); @@ -752,11 +764,16 @@ CV_EXPORTS const char* getOpenCLErrorString(int errorCode); CV_EXPORTS String kernelToStr(InputArray _kernel, ElemDepth ddepth = CV_DEPTH_AUTO, const char * name = NULL); #ifdef CV_TYPE_COMPATIBLE_API -CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) +CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(dtype, ddepth) static inline String kernelToStr(InputArray _kernel, int ddepth, const char * name = NULL) { return kernelToStr(_kernel, static_cast(ddepth), name); } +CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(dtype, ddepth) +static inline String kernelToStr(InputArray _kernel, ElemType ddepth, const char * name = NULL) +{ + return kernelToStr(_kernel, CV_MAT_DEPTH(ddepth), name); +} #endif // CV_TYPE_COMPATIBLE_API CV_EXPORTS void getPlatfomsInfo(std::vector& platform_info); @@ -817,11 +834,16 @@ class CV_EXPORTS Image2D */ static bool isFormatSupported(ElemDepth depth, int cn, bool norm); #ifdef CV_TYPE_COMPATIBLE_API - CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(type, depth) + CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(type, depth) static inline bool isFormatSupported(int depth, int cn, bool norm) { return isFormatSupported(static_cast(depth), cn, norm); } + CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(type, depth) + static inline bool isFormatSupported(ElemType depth, int cn, bool norm) + { + return isFormatSupported(CV_MAT_DEPTH(depth), cn, norm); + } #endif // CV_TYPE_COMPATIBLE_API void* ptr() const; diff --git a/modules/core/include/opencv2/core/opengl.hpp b/modules/core/include/opencv2/core/opengl.hpp index d404fb9946cc..4c3ab66e3d25 100644 --- a/modules/core/include/opencv2/core/opengl.hpp +++ b/modules/core/include/opencv2/core/opengl.hpp @@ -117,6 +117,11 @@ class CV_EXPORTS Buffer : Buffer(arows, acols, static_cast(atype), abufId, autoRelease) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(atype, atype) + inline Buffer(int arows, int acols, ElemDepth atype, unsigned int abufId, bool autoRelease = false) + : Buffer(arows, acols, CV_MAKETYPE(atype, 1), abufId, autoRelease) + { + } #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -132,6 +137,11 @@ class CV_EXPORTS Buffer : Buffer(asize, static_cast(atype), abufId, autoRelease) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(atype, atype) + inline Buffer(Size asize, ElemDepth atype, unsigned int abufId, bool autoRelease = false) + : Buffer(asize, CV_MAKETYPE(atype, 1), abufId, autoRelease) + { + } #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -148,6 +158,11 @@ class CV_EXPORTS Buffer : Buffer(arows, acols, static_cast(atype), target, autoRelease) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(atype, atype) + inline Buffer(int arows, int acols, ElemDepth atype, Target target = ARRAY_BUFFER, bool autoRelease = false) + : Buffer(arows, acols, CV_MAKETYPE(atype, 1), target, autoRelease) + { + } #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -163,6 +178,11 @@ class CV_EXPORTS Buffer : Buffer(asize, static_cast(atype), target, autoRelease) { } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(atype, atype) + inline Buffer(Size asize, ElemDepth atype, Target target = ARRAY_BUFFER, bool autoRelease = false) + : Buffer(asize, CV_MAKETYPE(atype, 1), target, autoRelease) + { + } #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -187,6 +207,11 @@ class CV_EXPORTS Buffer { create(arows, acols, static_cast(atype), target, autoRelease); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(atype, atype) + inline void create(int arows, int acols, ElemDepth atype, Target target = ARRAY_BUFFER, bool autoRelease = false) + { + create(arows, acols, CV_MAKETYPE(atype, 1), target, autoRelease); + } #endif // CV_TYPE_COMPATIBLE_API /** @overload @@ -202,6 +227,11 @@ class CV_EXPORTS Buffer { create(asize, static_cast(atype), target, autoRelease); } + CV_DEPRECATED_ELEMDEPTH_TO_ELEMTYPE_ATTR(atype, atype) + inline void create(Size asize, ElemDepth atype, Target target = ARRAY_BUFFER, bool autoRelease = false) + { + create(asize, CV_MAKETYPE(atype, 1), target, autoRelease); + } #endif // CV_TYPE_COMPATIBLE_API /** @brief Decrements the reference counter and destroys the buffer object if needed. @@ -418,11 +448,16 @@ class CV_EXPORTS Texture2D */ void copyTo(OutputArray arr, ElemDepth ddepth = CV_32F, bool autoRelease = false) const; #ifdef CV_TYPE_COMPATIBLE_API - CV_DEPRECATED_INT_TO_ELEMTYPE_ATTR(dtype, ddepth) + CV_DEPRECATED_INT_TO_ELEMDEPTH_ATTR(dtype, ddepth) inline void copyTo(OutputArray arr, int ddepth, bool autoRelease = false) const { copyTo(arr, static_cast(ddepth), autoRelease ); } + CV_DEPRECATED_ELEMTYPE_TO_ELEMDEPTH_ATTR(dtype, ddepth) + inline void copyTo(OutputArray arr, ElemType ddepth, bool autoRelease = false) const + { + copyTo(arr, CV_MAT_DEPTH(ddepth), autoRelease ); + } #endif // CV_TYPE_COMPATIBLE_API /** @brief Binds texture to current active texture unit for GL_TEXTURE_2D target. diff --git a/modules/core/src/matrix_expressions.cpp b/modules/core/src/matrix_expressions.cpp index c292abe7336e..384a6b23ebfc 100644 --- a/modules/core/src/matrix_expressions.cpp +++ b/modules/core/src/matrix_expressions.cpp @@ -1763,40 +1763,80 @@ MatExpr Mat::zeros(int rows, int cols, int type) return zeros(rows, cols, static_cast(type)); } +MatExpr Mat::zeros(int rows, int cols, ElemDepth type) +{ + return zeros(rows, cols, static_cast(type)); +} + MatExpr Mat::zeros(Size size, int type) { return zeros(size, static_cast(type)); } +MatExpr Mat::zeros(Size size, ElemDepth type) +{ + return zeros(size, static_cast(type)); +} + MatExpr Mat::zeros(int ndims, const int* sz, int type) { return zeros(ndims, sz, static_cast(type)); } +MatExpr Mat::zeros(int ndims, const int* sz, ElemDepth type) +{ + return zeros(ndims, sz, static_cast(type)); +} + MatExpr Mat::ones(int rows, int cols, int type) { return ones(rows, cols, static_cast(type)); } +MatExpr Mat::ones(int rows, int cols, ElemDepth type) +{ + return ones(rows, cols, static_cast(type)); +} + MatExpr Mat::ones(Size size, int type) { return ones(size, static_cast(type)); } +MatExpr Mat::ones(Size size, ElemDepth type) +{ + return ones(size, static_cast(type)); +} + MatExpr Mat::ones(int ndims, const int* sz, int type) { return ones(ndims, sz, static_cast(type)); } +MatExpr Mat::ones(int ndims, const int* sz, ElemDepth type) +{ + return ones(ndims, sz, static_cast(type)); +} + MatExpr Mat::eye(int rows, int cols, int type) { return eye(rows, cols, static_cast(type)); } +MatExpr Mat::eye(int rows, int cols, ElemDepth type) +{ + return eye(rows, cols, static_cast(type)); +} + MatExpr Mat::eye(Size size, int type) { return eye(size, static_cast(type)); } + +MatExpr Mat::eye(Size size, ElemDepth type) +{ + return eye(size, static_cast(type)); +} #endif // CV_TYPE_COMPATIBLE_API } // cv::