|| !_src1.sameSize(_src2)
|| _src1.type() != _src2.type())
{
- if (checkScalar(_src1, _src2.type(), _src1.kind(), _src2.kind()))
+ bool is_src1_scalar = checkScalar(_src1, _src2.type(), _src1.kind(), _src2.kind());
+ bool is_src2_scalar = checkScalar(_src2, _src1.type(), _src2.kind(), _src1.kind());
+
+ if (is_src1_scalar && !is_src2_scalar)
{
op = op == CMP_LT ? CMP_GT : op == CMP_LE ? CMP_GE :
op == CMP_GE ? CMP_LE : op == CMP_GT ? CMP_LT : op;
compare(_src2, _src1, _dst, op);
return;
}
- else if( !checkScalar(_src2, _src1.type(), _src2.kind(), _src1.kind()) )
+ else if( (is_src1_scalar && is_src2_scalar) || (!is_src1_scalar && !is_src2_scalar) )
CV_Error( CV_StsUnmatchedSizes,
"The operation is neither 'array op array' (where arrays have the same size and the same type), "
"nor 'array op scalar', nor 'scalar op array'" );
EXPECT_TRUE(dst1.empty());
EXPECT_TRUE(dst2.empty());
}
+
+TEST(Compare, regression_8999)
+{
+ Mat_<double> A(4,1); A << 1, 3, 2, 4;
+ Mat_<double> B(1,1); B << 2;
+ Mat C;
+ ASSERT_ANY_THROW({
+ compare(A, B, C, CMP_LT);
+ });
+}