core: inconsistency of addition for multi-channel Mat and Scalar #16739
Labels
bug
category: core
future
This issue can't be fixed during restrictions of the compatibility requirements
pr: Discussion Required
RFC
OpenCV 3.4.9 / 4.2.0:
arg1 - uint8 matrix with 3 channels:
Mat m__1_2_3(Size(2, 2), CV_8UC3, Scalar(1, 2, 3));
arg2:
5
Scalar(5)
(identical toScalar(5, 0, 0, 0)
)Scalar(5, 1e-6, 0)
Scalar::all(5)
(identical toScalar(5, 5, 5, 5)
)Result variants:
[6, 2, 3]
- modified 1st channel only[6, 7, 8]
- all channels are modified5
Scalar(5)
Scalar
(5, 1e-6, 0)
Scalar::all(5)
cv::add(arg1, arg2, res)
res = arg1 + arg2
#14738
res = 1.001 * arg1 + arg2
#14738
#16538
Analyse:
Scalar(5, 1e-6, 0)
(arg3) andScalar::all(5)
(arg4) are consistent and adequate5
) may have designed to use with complex numbers (emulation through matrices with 2 channels) where5
is interpreted as a real number.5
intoScalar
(no explicit bug/feature) converts this intoScalar(5, 0, 0, 0)
. Extra overloads may help to avoid implicit conversions (but may break user code).Related unclear stuff:
Mat::eye()
without element initializer.explicit
forVec
andScalar
constructors: cv::Matx33f tmp = true compiles #11956MatExpr
stuffThe text was updated successfully, but these errors were encountered: