mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
Merge pull request #9034 from sovrasov:mats_from_initializer_list
Add constructors taking initializer_list for some of OpenCV data types (#9034) * Add a constructor taking initializer_list for Matx * Add a constructor taking initializer list for Mat and Mat_ * Add one more method to initialize Mat to the corresponding tutorial * Add a note how to initialize Matx * CV_CXX_11->CV_CXX11
This commit is contained in:
committed by
Alexander Alekhin
parent
11626fe32c
commit
e5fbb4f5d2
@@ -1398,6 +1398,15 @@ TEST(Core_Matx, fromMat_)
|
||||
ASSERT_EQ( cvtest::norm(a, b, NORM_INF), 0.);
|
||||
}
|
||||
|
||||
#ifdef CV_CXX11
|
||||
TEST(Core_Matx, from_initializer_list)
|
||||
{
|
||||
Mat_<double> a = (Mat_<double>(2,2) << 10, 11, 12, 13);
|
||||
Matx22d b = {10, 11, 12, 13};
|
||||
ASSERT_EQ( cvtest::norm(a, b, NORM_INF), 0.);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(Core_InputArray, empty)
|
||||
{
|
||||
vector<vector<Point> > data;
|
||||
@@ -1735,7 +1744,7 @@ TEST(Mat, regression_8680)
|
||||
ASSERT_EQ(mat.channels(), 2);
|
||||
}
|
||||
|
||||
#ifdef CV_CXX_11
|
||||
#ifdef CV_CXX11
|
||||
|
||||
TEST(Mat_, range_based_for)
|
||||
{
|
||||
@@ -1751,4 +1760,21 @@ TEST(Mat_, range_based_for)
|
||||
ASSERT_DOUBLE_EQ(norm(img, ref), 0.);
|
||||
}
|
||||
|
||||
TEST(Mat, from_initializer_list)
|
||||
{
|
||||
Mat A({1.f, 2.f, 3.f});
|
||||
Mat_<float> B(3, 1); B << 1, 2, 3;
|
||||
|
||||
ASSERT_EQ(A.type(), CV_32F);
|
||||
ASSERT_DOUBLE_EQ(norm(A, B, NORM_INF), 0.);
|
||||
}
|
||||
|
||||
TEST(Mat_, from_initializer_list)
|
||||
{
|
||||
Mat_<float> A = {1, 2, 3};
|
||||
Mat_<float> B(3, 1); B << 1, 2, 3;
|
||||
|
||||
ASSERT_DOUBLE_EQ(norm(A, B, NORM_INF), 0.);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user