Skip to content

Commit

Permalink
Add ElemDepth enum
Browse files Browse the repository at this point in the history
  • Loading branch information
cv3d committed Sep 22, 2018
1 parent d1f6ee6 commit e1c13c0
Show file tree
Hide file tree
Showing 68 changed files with 570 additions and 564 deletions.
66 changes: 33 additions & 33 deletions modules/core/include/opencv2/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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<ElemType>(ddepth));
add(src1, src2, dst, mask, static_cast<ElemDepth>(ddepth));
}
#endif // CV_TYPE_COMPATIBLE_API

Expand Down Expand Up @@ -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.
Expand All @@ -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<ElemType>(ddepth));
subtract(src1, src2, dst, mask, static_cast<ElemDepth>(ddepth));
}
#endif // CV_TYPE_COMPATIBLE_API

Expand All @@ -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<ElemType>(ddepth));
multiply(src1, src2, dst, scale, static_cast<ElemDepth>(ddepth));
}
#endif // CV_TYPE_COMPATIBLE_API

Expand All @@ -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<ElemType>(ddepth));
divide(src1, src2, dst, scale, static_cast<ElemDepth>(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<ElemType>(ddepth));
divide(scale, src2, dst, static_cast<ElemDepth>(ddepth));
}
#endif // CV_TYPE_COMPATIBLE_API

Expand Down Expand Up @@ -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<ElemType>(ddepth));
addWeighted(src1, alpha, src2, beta, gamma, dst, static_cast<ElemDepth>(ddepth));
}
#endif // CV_TYPE_COMPATIBLE_API

Expand Down Expand Up @@ -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<ElemType>(dtype), nidx, normType, K, mask, update, crosscheck);
batchDistance(src1, src2, dist, static_cast<ElemDepth>(ddepth), nidx, normType, K, mask, update, crosscheck);
}
#endif // CV_TYPE_COMPATIBLE_API

Expand Down Expand Up @@ -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<ElemType>(ddepth), mask);
normalize(src, dst, alpha, beta, norm_type, static_cast<ElemDepth>(ddepth), mask);
}
#endif // CV_TYPE_COMPATIBLE_API

Expand Down Expand Up @@ -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<ElemType>(ddepth));
reduce(src, dst, dim, rtype, static_cast<ElemDepth>(ddepth));
}
#endif // CV_TYPE_COMPATIBLE_API

Expand Down Expand Up @@ -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<ElemType>(ddepth));
mulTransposed(src, dst, aTa, delta, scale, static_cast<ElemDepth>(ddepth));
}
#endif // CV_TYPE_COMPATIBLE_API

Expand Down Expand Up @@ -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<ElemType>(ctype));
calcCovarMatrix(samples, nsamples, covar, mean, flags, static_cast<ElemDepth>(ctype));
}
#endif // CV_TYPE_COMPATIBLE_API

Expand All @@ -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<ElemType>(ctype));
calcCovarMatrix(samples, covar, mean, flags, static_cast<ElemDepth>(ctype));
}
#endif // CV_TYPE_COMPATIBLE_API

Expand Down
4 changes: 2 additions & 2 deletions modules/core/include/opencv2/core/affine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ namespace cv
static const int channels = 16;
static const int fmt = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8);
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
static const ElemType depth = DataType<channel_type>::depth;
static const ElemDepth depth = DataType<channel_type>::depth;
static const ElemType type = CV_MAKETYPE(depth, channels);
#endif

Expand All @@ -313,7 +313,7 @@ namespace cv

namespace traits {
template<typename _Tp>
struct Depth< Affine3<_Tp> > { static const ElemType value = Depth<_Tp>::value; };
struct Depth< Affine3<_Tp> > { static const ElemDepth value = Depth<_Tp>::value; };
template<typename _Tp>
struct Type< Affine3<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 16); };
} // namespace
Expand Down
16 changes: 8 additions & 8 deletions modules/core/include/opencv2/core/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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. " \
Expand Down Expand Up @@ -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<int>(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<int>(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<int>(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<int>(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<int>(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<int>(CV_MIN_DEPTH(left, right));
}
Expand Down
16 changes: 8 additions & 8 deletions modules/core/include/opencv2/core/check.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
namespace cv {

/** Returns string of cv::Mat depth value: CV_8U -> "CV_8U" or "<invalid depth>" */
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<ElemType>(depth));
return depthToString(static_cast<ElemDepth>(depth));
}
#endif // CV_TRANSNATIONAL_API

Expand All @@ -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<ElemType>(depth));
return depthToString_(static_cast<ElemDepth>(depth));
}
#endif // CV_TRANSNATIONAL_API

Expand Down Expand Up @@ -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<ElemType>(v1), static_cast<ElemType>(v2), ctx);
check_failed_MatDepth(static_cast<ElemDepth>(v1), static_cast<ElemDepth>(v2), ctx);
}
#endif // CV_TRANSNATIONAL_API
CV_EXPORTS void CV_NORETURN check_failed_MatType(const ElemType v1, const ElemType v2, const CheckContext& ctx);
Expand All @@ -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<ElemType>(v), ctx);
check_failed_MatDepth(static_cast<ElemDepth>(v), ctx);
}
#endif // CV_TRANSNATIONAL_API
CV_EXPORTS void CV_NORETURN check_failed_MatType(const ElemType v, const CheckContext& ctx);
Expand Down

0 comments on commit e1c13c0

Please sign in to comment.