mirror of
https://github.com/opencv/opencv.git
synced 2026-12-01 21:58:44 -06:00
Merge pull request #30220 from vrabaud:small
check element count in isScalarLikeMat for 1x1 multi-channel Mats
This commit is contained in:
@@ -413,7 +413,7 @@ inline bool isScalarLikeMat(const _InputArray& sc, int cn)
|
||||
}
|
||||
else
|
||||
return false;
|
||||
if (!continuous || nval > 4)
|
||||
if (!continuous || nval > 4 || (nval != 1 && nval != cn))
|
||||
return false;
|
||||
return (rows == 1 && cols == 1) || (rows == cn && cols == 1) || (rows == 1 && cols == cn);
|
||||
}
|
||||
|
||||
@@ -3262,4 +3262,13 @@ TEST(Core_Mat, fitSameSize_keeps_layout)
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Mat, ScalarMul) {
|
||||
cv::Mat cv_mat_1x1_c3(1, 1, CV_32FC3, cv::Scalar(1, 2, 3));
|
||||
cv::Mat cv_mat_mul = cv_mat_1x1_c3.mul(cv::Scalar(2, 3, 4));
|
||||
ASSERT_EQ(cv_mat_mul.rows, 1);
|
||||
ASSERT_EQ(cv_mat_mul.cols, 1);
|
||||
ASSERT_EQ(cv_mat_mul.type(), CV_32FC3);
|
||||
ASSERT_EQ(cv_mat_mul.at<cv::Vec3f>(0, 0), cv::Vec3f(2, 6, 12));
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
||||
Reference in New Issue
Block a user