From 92e7e7d8e8be9e8721f408603b5fbb7e9bd5e10f Mon Sep 17 00:00:00 2001 From: Bo Li Date: Mon, 11 Feb 2013 15:09:42 +0100 Subject: [PATCH] fix issue 2788 --- modules/core/src/arithm.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp index 0fa306cd9..5fda1415c 100644 --- a/modules/core/src/arithm.cpp +++ b/modules/core/src/arithm.cpp @@ -1242,11 +1242,15 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, Mat src1 = _src1.getMat(), src2 = _src2.getMat(); 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();