Merge pull request #27322 from vrabaud:zeros

Add missing Mat_<_Tp>::zeros(int _ndims, const int* _sizes)
This commit is contained in:
Alexander Smorkalov 2025-05-17 09:55:05 +03:00 committed by GitHub
commit f3cffcd85d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -3024,6 +3024,12 @@ Mat_<_Tp>& Mat_<_Tp>::operator = (const MatExpr& e)
return *this;
}
template<typename _Tp> inline
MatExpr Mat_<_Tp>::zeros(int _ndims, const int* _sizes)
{
return Mat::zeros(_ndims, _sizes, traits::Type<_Tp>::value);
}
template<typename _Tp> inline
MatExpr Mat_<_Tp>::zeros(int rows, int cols)
{

View File

@ -1418,6 +1418,13 @@ TEST(Core_Mat, copyMakeBoderUndefinedBehavior)
EXPECT_EQ(0, cv::norm(src.col(2), dst(Rect(5,1,1,4))));
}
TEST(Core_Mat, zeros)
{
// Should not fail during linkage.
const int dims[] = {2, 2, 4};
cv::Mat1f mat = cv::Mat1f::zeros(3, dims);
}
TEST(Core_Matx, fromMat_)
{
Mat_<double> a = (Mat_<double>(2,2) << 10, 11, 12, 13);