Merge branch '2.4'
This commit is contained in:
@@ -1243,10 +1243,14 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
|
||||
bool haveMask = !_mask.empty();
|
||||
bool reallocate = false;
|
||||
|
||||
bool src1Scalar = checkScalar(src1, src2.type(), kind1, kind2);
|
||||
bool src2Scalar = checkScalar(src2, src1.type(), kind2, kind1);
|
||||
|
||||
if( (kind1 == kind2 || src1.channels() == 1) && src1.dims <= 2 && src2.dims <= 2 &&
|
||||
src1.size() == src2.size() && src1.type() == src2.type() &&
|
||||
!haveMask && ((!_dst.fixedType() && (dtype < 0 || CV_MAT_DEPTH(dtype) == src1.depth())) ||
|
||||
(_dst.fixedType() && _dst.type() == _src1.type())) )
|
||||
(_dst.fixedType() && _dst.type() == _src1.type())) &&
|
||||
((src1Scalar && src2Scalar) || (!src1Scalar && !src2Scalar)) )
|
||||
{
|
||||
_dst.create(src1.size(), src1.type());
|
||||
Mat dst = _dst.getMat();
|
||||
|
@@ -94,7 +94,7 @@ template<typename T1, typename T2=T1, typename T3=T1> struct OpAdd
|
||||
typedef T1 type1;
|
||||
typedef T2 type2;
|
||||
typedef T3 rtype;
|
||||
T3 operator ()(T1 a, T2 b) const { return saturate_cast<T3>(a + b); }
|
||||
T3 operator ()(const T1 a, const T2 b) const { return saturate_cast<T3>(a + b); }
|
||||
};
|
||||
|
||||
template<typename T1, typename T2=T1, typename T3=T1> struct OpSub
|
||||
@@ -102,7 +102,7 @@ template<typename T1, typename T2=T1, typename T3=T1> struct OpSub
|
||||
typedef T1 type1;
|
||||
typedef T2 type2;
|
||||
typedef T3 rtype;
|
||||
T3 operator ()(T1 a, T2 b) const { return saturate_cast<T3>(a - b); }
|
||||
T3 operator ()(const T1 a, const T2 b) const { return saturate_cast<T3>(a - b); }
|
||||
};
|
||||
|
||||
template<typename T1, typename T2=T1, typename T3=T1> struct OpRSub
|
||||
@@ -110,7 +110,7 @@ template<typename T1, typename T2=T1, typename T3=T1> struct OpRSub
|
||||
typedef T1 type1;
|
||||
typedef T2 type2;
|
||||
typedef T3 rtype;
|
||||
T3 operator ()(T1 a, T2 b) const { return saturate_cast<T3>(b - a); }
|
||||
T3 operator ()(const T1 a, const T2 b) const { return saturate_cast<T3>(b - a); }
|
||||
};
|
||||
|
||||
template<typename T> struct OpMin
|
||||
@@ -118,7 +118,7 @@ template<typename T> struct OpMin
|
||||
typedef T type1;
|
||||
typedef T type2;
|
||||
typedef T rtype;
|
||||
T operator ()(T a, T b) const { return std::min(a, b); }
|
||||
T operator ()(const T a, const T b) const { return std::min(a, b); }
|
||||
};
|
||||
|
||||
template<typename T> struct OpMax
|
||||
@@ -126,7 +126,7 @@ template<typename T> struct OpMax
|
||||
typedef T type1;
|
||||
typedef T type2;
|
||||
typedef T rtype;
|
||||
T operator ()(T a, T b) const { return std::max(a, b); }
|
||||
T operator ()(const T a, const T b) const { return std::max(a, b); }
|
||||
};
|
||||
|
||||
inline Size getContinuousSize( const Mat& m1, int widthScale=1 )
|
||||
|
@@ -1530,4 +1530,24 @@ TEST(Multiply, FloatingPointRounding)
|
||||
cv::multiply(src, s, dst, 1, CV_16U);
|
||||
// with CV_32F this produce result 16202
|
||||
ASSERT_EQ(dst.at<ushort>(0,0), 16201);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Core_Add, AddToColumnWhen3Rows)
|
||||
{
|
||||
cv::Mat m1 = (cv::Mat_<double>(3, 2) << 1, 2, 3, 4, 5, 6);
|
||||
m1.col(1) += 10;
|
||||
|
||||
cv::Mat m2 = (cv::Mat_<double>(3, 2) << 1, 12, 3, 14, 5, 16);
|
||||
|
||||
ASSERT_EQ(0, countNonZero(m1 - m2));
|
||||
}
|
||||
|
||||
TEST(Core_Add, AddToColumnWhen4Rows)
|
||||
{
|
||||
cv::Mat m1 = (cv::Mat_<double>(4, 2) << 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
m1.col(1) += 10;
|
||||
|
||||
cv::Mat m2 = (cv::Mat_<double>(4, 2) << 1, 12, 3, 14, 5, 16, 7, 18);
|
||||
|
||||
ASSERT_EQ(0, countNonZero(m1 - m2));
|
||||
}
|
||||
|
Reference in New Issue
Block a user