From 201381e0194ee451aff113e26c464b4aff0c7db2 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Tue, 19 May 2026 06:11:12 +0300 Subject: [PATCH] core: deprecate MatCommaInitializer_ --- .../mat_the_basic_image_container.markdown | 4 +- modules/core/include/opencv2/core/mat.hpp | 11 +- modules/core/include/opencv2/core/mat.inl.hpp | 2 +- .../core/include/opencv2/core/matx.inl.hpp | 4 +- modules/core/test/test_mat.cpp | 12 + .../imgproc/test/test_connectedcomponents.cpp | 497 ++++++++---------- samples/cpp/image_alignment.cpp | 27 +- samples/cpp/kalman.cpp | 2 +- samples/cpp/select3dobj.cpp | 2 +- .../tutorial_code/ImgProc/HitMiss/HitMiss.cpp | 10 +- .../ImgTrans/imageSegmentation.cpp | 9 +- .../how_to_use_OpenCV_parallel_for_new.cpp | 8 +- .../mat_mask_operations.cpp | 8 +- .../mat_the_basic_image_container.cpp | 7 +- .../core/univ_intrin/univ_intrin.cpp | 10 +- .../Homography/decompose_homography.cpp | 2 +- .../homography_from_camera_displacement.cpp | 2 +- .../panorama_stitching_rotating_camera.cpp | 28 +- .../Homography/perspective_correction.cpp | 2 +- .../introduction_to_svm.cpp | 2 +- .../ml/non_linear_svms/non_linear_svms.cpp | 2 +- .../cpp/tutorial_code/snippets/core_merge.cpp | 6 +- .../tutorial_code/snippets/core_reduce.cpp | 2 +- samples/dnn/object_detection.cpp | 2 +- 24 files changed, 324 insertions(+), 337 deletions(-) diff --git a/doc/tutorials/core/mat_the_basic_image_container/mat_the_basic_image_container.markdown b/doc/tutorials/core/mat_the_basic_image_container/mat_the_basic_image_container.markdown index 18c431a244..5018386838 100644 --- a/doc/tutorials/core/mat_the_basic_image_container/mat_the_basic_image_container.markdown +++ b/doc/tutorials/core/mat_the_basic_image_container/mat_the_basic_image_container.markdown @@ -201,9 +201,7 @@ object in multiple ways: ![](images/MatBasicContainerOut3.png) -- For small matrices you may use comma separated initializers or initializer lists (C++11 support is required in the last case): - - @snippet mat_the_basic_image_container.cpp comma +- For small matrices you may use initializer lists: @snippet mat_the_basic_image_container.cpp list diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index 78f7487e51..955ebe1858 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -548,6 +548,13 @@ public: double angle = 30, a = cos(angle*CV_PI/180), b = sin(angle*CV_PI/180); Mat R = (Mat_(2,2) << a, -b, b, a); \endcode + + \deprecated Use constructors with std::initializer_list instead: + \code + Mat_ m1({1, 2, 3, 4}); // 4x1 Mat + Mat_ m2({2, 3}, {1, 2, 3, 4, 5, 6}); // 2x3 Mat + + Mat_ R({2, 2}, {a, -b, b, a}); // from example */ template class MatCommaInitializer_ { @@ -1083,7 +1090,7 @@ public: /** @overload */ - template explicit Mat(const MatCommaInitializer_<_Tp>& commaInitializer); + template CV_DEPRECATED_EXTERNAL explicit Mat(const MatCommaInitializer_<_Tp>& commaInitializer); //! download data from GpuMat explicit Mat(const cuda::GpuMat& m); @@ -2338,7 +2345,7 @@ public: template explicit Mat_(const Matx::channel_type, m, n>& mtx, bool copyData=true); explicit Mat_(const Point_::channel_type>& pt, bool copyData=true); explicit Mat_(const Point3_::channel_type>& pt, bool copyData=true); - explicit Mat_(const MatCommaInitializer_<_Tp>& commaInitializer); + CV_DEPRECATED_EXTERNAL explicit Mat_(const MatCommaInitializer_<_Tp>& commaInitializer); Mat_(std::initializer_list<_Tp> values); explicit Mat_(const std::initializer_list sizes, const std::initializer_list<_Tp> values); diff --git a/modules/core/include/opencv2/core/mat.inl.hpp b/modules/core/include/opencv2/core/mat.inl.hpp index f034064351..9cc2d63334 100644 --- a/modules/core/include/opencv2/core/mat.inl.hpp +++ b/modules/core/include/opencv2/core/mat.inl.hpp @@ -3011,7 +3011,7 @@ MatCommaInitializer_<_Tp>::operator Mat_<_Tp>() const } -template static inline +template CV_DEPRECATED_EXTERNAL static inline MatCommaInitializer_<_Tp> operator << (const Mat_<_Tp>& m, T2 val) { MatCommaInitializer_<_Tp> commaInitializer((Mat_<_Tp>*)&m); diff --git a/modules/core/include/opencv2/core/matx.inl.hpp b/modules/core/include/opencv2/core/matx.inl.hpp index faa3e749d6..b6a26250cd 100644 --- a/modules/core/include/opencv2/core/matx.inl.hpp +++ b/modules/core/include/opencv2/core/matx.inl.hpp @@ -115,7 +115,7 @@ public: int idx; }; -template static inline +template CV_DEPRECATED_EXTERNAL static inline MatxCommaInitializer<_Tp, m, n> operator << (const Matx<_Tp, m, n>& mtx, _T2 val) { MatxCommaInitializer<_Tp, m, n> commaInitializer((Matx<_Tp, m, n>*)&mtx); @@ -738,7 +738,7 @@ public: Vec<_Tp, m> operator *() const; }; -template static inline +template CV_DEPRECATED_EXTERNAL static inline VecCommaInitializer<_Tp, cn> operator << (const Vec<_Tp, cn>& vec, _T2 val) { VecCommaInitializer<_Tp, cn> commaInitializer((Vec<_Tp, cn>*)&vec); diff --git a/modules/core/test/test_mat.cpp b/modules/core/test/test_mat.cpp index 33f438d0c4..846bff6d94 100644 --- a/modules/core/test/test_mat.cpp +++ b/modules/core/test/test_mat.cpp @@ -1465,6 +1465,8 @@ TEST(Core_Matx, from_initializer_list) Mat_ a = (Mat_(2,2) << 10, 11, 12, 13); Matx22d b = {10, 11, 12, 13}; ASSERT_EQ( cvtest::norm(a, b, NORM_INF), 0.); + Mat_ c({2, 2}, {10, 11, 12, 13}); + ASSERT_EQ( cvtest::norm(c, b, NORM_INF), 0.); } TEST(Core_Mat, regression_9507) @@ -1918,6 +1920,11 @@ TEST(Mat, from_initializer_list) auto D = Mat_({2, 3}, {1, 2, 3, 4, 5, 6}); EXPECT_EQ(2, D.rows); EXPECT_EQ(3, D.cols); + + double angle = 30, a = cos(angle*CV_PI/180), b = sin(angle*CV_PI/180); + Mat R({2, 2}, {a, -b, b, a}); + ASSERT_EQ(CV_64FC1, R.type()); + ASSERT_EQ(cv::Size(2, 2), R.size()); } TEST(Mat_, from_initializer_list) @@ -1929,6 +1936,11 @@ TEST(Mat_, from_initializer_list) ASSERT_DOUBLE_EQ(cvtest::norm(A, B, NORM_INF), 0.); ASSERT_DOUBLE_EQ(cvtest::norm(A, C, NORM_INF), 0.); ASSERT_DOUBLE_EQ(cvtest::norm(B, C, NORM_INF), 0.); + + double angle = 30, a = cos(angle*CV_PI/180), b = sin(angle*CV_PI/180); + Mat_ R({2, 2}, {a, -b, b, a}); + ASSERT_EQ(CV_64FC1, R.type()); + ASSERT_EQ(cv::Size(2, 2), R.size()); } diff --git a/modules/imgproc/test/test_connectedcomponents.cpp b/modules/imgproc/test/test_connectedcomponents.cpp index 7c4cebaa76..7d58f714e0 100644 --- a/modules/imgproc/test/test_connectedcomponents.cpp +++ b/modules/imgproc/test/test_connectedcomponents.cpp @@ -240,8 +240,8 @@ TEST(Imgproc_ConnectedComponents, missing_background_pixels) TEST(Imgproc_ConnectedComponents, spaghetti_bbdt_sauf_stats) { - cv::Mat1b img(16, 16); - img << 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + cv::Mat1b img({16, 16}, { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, @@ -256,7 +256,8 @@ TEST(Imgproc_ConnectedComponents, spaghetti_bbdt_sauf_stats) 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1; + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + }); cv::Mat1i labels; cv::Mat1i stats; @@ -360,68 +361,64 @@ TEST(Imgproc_ConnectedComponents, spaghetti_bbdt_sauf_stats) TEST(Imgproc_ConnectedComponents, chessboard_even) { - cv::Size size(16, 16); - cv::Mat1b input(size); - cv::Mat1i output_8c(size); - cv::Mat1i output_4c(size); + const auto size = {16, 16}; + cv::Mat1b input(size, { + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 + }); + cv::Mat1i output_8c(size, { + 1, 0, 1,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 0, 39, 0, 40, 0, + 0, 41, 0, 42, 0, 43, 0, 44, 0, 45, 0, 46, 0, 47, 0, 48, + 49, 0, 50, 0, 51, 0, 52, 0, 53, 0, 54, 0, 55, 0, 56, 0, + 0, 57, 0, 58, 0, 59, 0, 60, 0, 61, 0, 62, 0, 63, 0, 64, + 65, 0, 66, 0, 67, 0, 68, 0, 69, 0, 70, 0, 71, 0, 72, 0, + 0, 73, 0, 74, 0, 75, 0, 76, 0, 77, 0, 78, 0, 79, 0, 80, + 81, 0, 82, 0, 83, 0, 84, 0, 85, 0, 86, 0, 87, 0, 88, 0, + 0, 89, 0, 90, 0, 91, 0, 92, 0, 93, 0, 94, 0, 95, 0, 96, + 97, 0, 98, 0, 99, 0, 100, 0, 101, 0, 102, 0, 103, 0, 104, 0, + 0, 105, 0, 106, 0, 107, 0, 108, 0, 109, 0, 110, 0, 111, 0, 112, + 113, 0, 114, 0, 115, 0, 116, 0, 117, 0, 118, 0, 119, 0, 120, 0, + 0, 121, 0, 122, 0, 123, 0, 124, 0, 125, 0, 126, 0, 127, 0, 128 + }); // Chessboard image with even number of rows and cols // Note that this is the maximum number of labels for 4-way connectivity - { - input << - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,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 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1; - - output_4c << - 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, - 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, - 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 0, - 0, 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, 30, 0, 31, 0, 32, - 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, 38, 0, 39, 0, 40, 0, - 0, 41, 0, 42, 0, 43, 0, 44, 0, 45, 0, 46, 0, 47, 0, 48, - 49, 0, 50, 0, 51, 0, 52, 0, 53, 0, 54, 0, 55, 0, 56, 0, - 0, 57, 0, 58, 0, 59, 0, 60, 0, 61, 0, 62, 0, 63, 0, 64, - 65, 0, 66, 0, 67, 0, 68, 0, 69, 0, 70, 0, 71, 0, 72, 0, - 0, 73, 0, 74, 0, 75, 0, 76, 0, 77, 0, 78, 0, 79, 0, 80, - 81, 0, 82, 0, 83, 0, 84, 0, 85, 0, 86, 0, 87, 0, 88, 0, - 0, 89, 0, 90, 0, 91, 0, 92, 0, 93, 0, 94, 0, 95, 0, 96, - 97, 0, 98, 0, 99, 0, 100, 0, 101, 0, 102, 0, 103, 0, 104, 0, - 0, 105, 0, 106, 0, 107, 0, 108, 0, 109, 0, 110, 0, 111, 0, 112, - 113, 0, 114, 0, 115, 0, 116, 0, 117, 0, 118, 0, 119, 0, 120, 0, - 0, 121, 0, 122, 0, 123, 0, 124, 0, 125, 0, 126, 0, 127, 0, 128; - } int ccltype[] = { cv::CCL_DEFAULT, cv::CCL_WU, cv::CCL_GRANA, cv::CCL_BOLELLI, cv::CCL_SAUF, cv::CCL_BBDT, cv::CCL_SPAGHETTI }; @@ -448,65 +445,61 @@ TEST(Imgproc_ConnectedComponents, chessboard_even) TEST(Imgproc_ConnectedComponents, chessboard_odd) { - cv::Size size(15, 15); - cv::Mat1b input(size); - cv::Mat1i output_8c(size); - cv::Mat1i output_4c(size); + const auto size = {15, 15}; + cv::Mat1b input(size, { + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 + }); + cv::Mat1i output_8c(size, { + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 + }); + cv::Mat1i output_4c(size, { + 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, + 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, + 16, 0, 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, + 0, 24, 0, 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, 30, 0, + 31, 0, 32, 0, 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, 38, + 0, 39, 0, 40, 0, 41, 0, 42, 0, 43, 0, 44, 0, 45, 0, + 46, 0, 47, 0, 48, 0, 49, 0, 50, 0, 51, 0, 52, 0, 53, + 0, 54, 0, 55, 0, 56, 0, 57, 0, 58, 0, 59, 0, 60, 0, + 61, 0, 62, 0, 63, 0, 64, 0, 65, 0, 66, 0, 67, 0, 68, + 0, 69, 0, 70, 0, 71, 0, 72, 0, 73, 0, 74, 0, 75, 0, + 76, 0, 77, 0, 78, 0, 79, 0, 80, 0, 81, 0, 82, 0, 83, + 0, 84, 0, 85, 0, 86, 0, 87, 0, 88, 0, 89, 0, 90, 0, + 91, 0, 92, 0, 93, 0, 94, 0, 95, 0, 96, 0, 97, 0, 98, + 0, 99, 0, 100, 0, 101, 0, 102, 0, 103, 0, 104, 0, 105, 0, + 106, 0, 107, 0, 108, 0, 109, 0, 110, 0, 111, 0, 112, 0, 113 + }); // Chessboard image with odd number of rows and cols // Note that this is the maximum number of labels for 4-way connectivity - { - input << - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1; - - output_8c << - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 0, 1, 0, 1, 0, 1,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, 65, 0, 66, 0, 67, 0, 68, - 0, 69, 0, 70, 0, 71, 0, 72, 0, 73, 0, 74, 0, 75, 0, - 76, 0, 77, 0, 78, 0, 79, 0, 80, 0, 81, 0, 82, 0, 83, - 0, 84, 0, 85, 0, 86, 0, 87, 0, 88, 0, 89, 0, 90, 0, - 91, 0, 92, 0, 93, 0, 94, 0, 95, 0, 96, 0, 97, 0, 98, - 0, 99, 0, 100, 0, 101, 0, 102, 0, 103, 0, 104, 0, 105, 0, - 106, 0, 107, 0, 108, 0, 109, 0, 110, 0, 111, 0, 112, 0, 113; - } int ccltype[] = { cv::CCL_DEFAULT, cv::CCL_WU, cv::CCL_GRANA, cv::CCL_BOLELLI, cv::CCL_SAUF, cv::CCL_BBDT, cv::CCL_SPAGHETTI }; @@ -533,66 +526,61 @@ TEST(Imgproc_ConnectedComponents, chessboard_odd) TEST(Imgproc_ConnectedComponents, maxlabels_8conn_even) { - cv::Size size(16, 16); - cv::Mat1b input(size); - cv::Mat1i output_8c(size); - cv::Mat1i output_4c(size); - - { - input << - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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62, 0, 63, 0, 64, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0; - - output_4c << - 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, 30, 0, 31, 0, 32, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, 38, 0, 39, 0, 40, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 41, 0, 42, 0, 43, 0, 44, 0, 45, 0, 46, 0, 47, 0, 48, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 49, 0, 50, 0, 51, 0, 52, 0, 53, 0, 54, 0, 55, 0, 56, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 57, 0, 58, 0, 59, 0, 60, 0, 61, 0, 62, 0, 63, 0, 64, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0; - } + const auto size = {16, 16}; + cv::Mat1b input(size, { + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, 38, 0, 39, 0, 40, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 41, 0, 42, 0, 43, 0, 44, 0, 45, 0, 46, 0, 47, 0, 48, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 49, 0, 50, 0, 51, 0, 52, 0, 53, 0, 54, 0, 55, 0, 56, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 57, 0, 58, 0, 59, 0, 60, 0, 61, 0, 62, 0, 63, 0, 64, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }); + cv::Mat1i output_4c(size, { + 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, 30, 0, 31, 0, 32, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, 38, 0, 39, 0, 40, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 41, 0, 42, 0, 43, 0, 44, 0, 45, 0, 46, 0, 47, 0, 48, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 49, 0, 50, 0, 51, 0, 52, 0, 53, 0, 54, 0, 55, 0, 56, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 57, 0, 58, 0, 59, 0, 60, 0, 61, 0, 62, 0, 63, 0, 64, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }); int ccltype[] = { cv::CCL_DEFAULT, cv::CCL_WU, cv::CCL_GRANA, cv::CCL_BOLELLI, cv::CCL_SAUF, cv::CCL_BBDT, cv::CCL_SPAGHETTI }; @@ -619,63 +607,58 @@ TEST(Imgproc_ConnectedComponents, maxlabels_8conn_even) TEST(Imgproc_ConnectedComponents, maxlabels_8conn_odd) { - cv::Size size(15, 15); - cv::Mat1b input(size); - cv::Mat1i output_8c(size); - cv::Mat1i output_4c(size); - - { - input << - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1; - - output_8c << - 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, 30, 0, 31, 0, 32, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, 38, 0, 39, 0, 40, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 41, 0, 42, 0, 43, 0, 44, 0, 45, 0, 46, 0, 47, 0, 48, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 49, 0, 50, 0, 51, 0, 52, 0, 53, 0, 54, 0, 55, 0, 56, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 57, 0, 58, 0, 59, 0, 60, 0, 61, 0, 62, 0, 63, 0, 64; - - output_4c << - 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 17, 0, 18, 0, 19, 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+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 + }); + cv::Mat1i output_8c(size, { + 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, 30, 0, 31, 0, 32, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, 38, 0, 39, 0, 40, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 41, 0, 42, 0, 43, 0, 44, 0, 45, 0, 46, 0, 47, 0, 48, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 49, 0, 50, 0, 51, 0, 52, 0, 53, 0, 54, 0, 55, 0, 56, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 57, 0, 58, 0, 59, 0, 60, 0, 61, 0, 62, 0, 63, 0, 64 + }); + cv::Mat1i output_4c(size, { + 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, 30, 0, 31, 0, 32, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, 38, 0, 39, 0, 40, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 41, 0, 42, 0, 43, 0, 44, 0, 45, 0, 46, 0, 47, 0, 48, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 49, 0, 50, 0, 51, 0, 52, 0, 53, 0, 54, 0, 55, 0, 56, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 57, 0, 58, 0, 59, 0, 60, 0, 61, 0, 62, 0, 63, 0, 64 + }); int ccltype[] = { cv::CCL_DEFAULT, cv::CCL_WU, cv::CCL_GRANA, cv::CCL_BOLELLI, cv::CCL_SAUF, cv::CCL_BBDT, cv::CCL_SPAGHETTI }; @@ -702,24 +685,10 @@ TEST(Imgproc_ConnectedComponents, maxlabels_8conn_odd) TEST(Imgproc_ConnectedComponents, single_row) { - cv::Size size(1, 15); - cv::Mat1b input(size); - cv::Mat1i output_8c(size); - cv::Mat1i output_4c(size); - - { - input << - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1; - - - output_8c << - 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8; - - - output_4c << - 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8; - - } + const auto size = {1, 15}; + cv::Mat1b input(size, {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}); + cv::Mat1i output_8c(size, {1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8}); + cv::Mat1i output_4c(size, {1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8}); int ccltype[] = { cv::CCL_DEFAULT, cv::CCL_WU, cv::CCL_GRANA, cv::CCL_BOLELLI, cv::CCL_SAUF, cv::CCL_BBDT, cv::CCL_SPAGHETTI }; @@ -746,24 +715,10 @@ TEST(Imgproc_ConnectedComponents, single_row) TEST(Imgproc_ConnectedComponents, single_column) { - cv::Size size(15, 1); - cv::Mat1b input(size); - cv::Mat1i output_8c(size); - cv::Mat1i output_4c(size); - - { - input << - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1; - - - output_8c << - 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8; - - - output_4c << - 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8; - - } + const auto size = {15, 1}; + cv::Mat1b input(size, {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}); + cv::Mat1i output_8c(size, {1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8}); + cv::Mat1i output_4c(size, {1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8}); int ccltype[] = { cv::CCL_DEFAULT, cv::CCL_WU, cv::CCL_GRANA, cv::CCL_BOLELLI, cv::CCL_SAUF, cv::CCL_BBDT, cv::CCL_SPAGHETTI }; diff --git a/samples/cpp/image_alignment.cpp b/samples/cpp/image_alignment.cpp index fc7ab18a71..70d5c4eb3a 100644 --- a/samples/cpp/image_alignment.cpp +++ b/samples/cpp/image_alignment.cpp @@ -242,33 +242,38 @@ int main (const int argc, const char * argv[]) double angle; switch (mode_temp) { case MOTION_TRANSLATION: - warpGround = (Mat_(2,3) << 1, 0, (rng.uniform(10.f, 20.f)), - 0, 1, (rng.uniform(10.f, 20.f))); + warpGround = Mat_({2,3}, { + 1, 0, (rng.uniform(10.f, 20.f)), + 0, 1, (rng.uniform(10.f, 20.f)) + }); warpAffine(target_image, template_image, warpGround, Size(200,200), INTER_LINEAR + WARP_INVERSE_MAP); break; case MOTION_EUCLIDEAN: angle = CV_PI/30 + CV_PI*rng.uniform((double)-2.f, (double)2.f)/180; - warpGround = (Mat_(2,3) << cos(angle), -sin(angle), (rng.uniform(10.f, 20.f)), - sin(angle), cos(angle), (rng.uniform(10.f, 20.f))); + warpGround = Mat_({2,3}, { + (float)cos(angle), (float)-sin(angle), (rng.uniform(10.f, 20.f)), + (float)sin(angle), (float)cos(angle), (rng.uniform(10.f, 20.f)) + }); warpAffine(target_image, template_image, warpGround, Size(200,200), INTER_LINEAR + WARP_INVERSE_MAP); break; case MOTION_AFFINE: - warpGround = (Mat_(2,3) << (1-rng.uniform(-0.05f, 0.05f)), - (rng.uniform(-0.03f, 0.03f)), (rng.uniform(10.f, 20.f)), - (rng.uniform(-0.03f, 0.03f)), (1-rng.uniform(-0.05f, 0.05f)), - (rng.uniform(10.f, 20.f))); + warpGround = Mat_({2,3}, { + (1-rng.uniform(-0.05f, 0.05f)), (rng.uniform(-0.03f, 0.03f)), (rng.uniform(10.f, 20.f)), + (rng.uniform(-0.03f, 0.03f)), (1-rng.uniform(-0.05f, 0.05f)), (rng.uniform(10.f, 20.f)) + }); warpAffine(target_image, template_image, warpGround, Size(200,200), INTER_LINEAR + WARP_INVERSE_MAP); break; case MOTION_HOMOGRAPHY: - warpGround = (Mat_(3,3) << (1-rng.uniform(-0.05f, 0.05f)), - (rng.uniform(-0.03f, 0.03f)), (rng.uniform(10.f, 20.f)), + warpGround = Mat_({3,3}, { + (1-rng.uniform(-0.05f, 0.05f)), (rng.uniform(-0.03f, 0.03f)), (rng.uniform(10.f, 20.f)), (rng.uniform(-0.03f, 0.03f)), (1-rng.uniform(-0.05f, 0.05f)),(rng.uniform(10.f, 20.f)), - (rng.uniform(0.0001f, 0.0003f)), (rng.uniform(0.0001f, 0.0003f)), 1.f); + (rng.uniform(0.0001f, 0.0003f)), (rng.uniform(0.0001f, 0.0003f)), 1.f + }); warpPerspective(target_image, template_image, warpGround, Size(200,200), INTER_LINEAR + WARP_INVERSE_MAP); break; diff --git a/samples/cpp/kalman.cpp b/samples/cpp/kalman.cpp index daf0ba5a71..92c6ba68fa 100644 --- a/samples/cpp/kalman.cpp +++ b/samples/cpp/kalman.cpp @@ -46,7 +46,7 @@ int main(int, char**) img = Scalar::all(0); state.at(0) = 0.0f; state.at(1) = 2.f * (float)CV_PI / 6; - KF.transitionMatrix = (Mat_(2, 2) << 1, 1, 0, 1); + KF.transitionMatrix = Mat_({2, 2}, {1, 1, 0, 1}); setIdentity(KF.measurementMatrix); setIdentity(KF.processNoiseCov, Scalar::all(1e-5)); diff --git a/samples/cpp/select3dobj.cpp b/samples/cpp/select3dobj.cpp index 0f19eb2332..390d2db3fc 100644 --- a/samples/cpp/select3dobj.cpp +++ b/samples/cpp/select3dobj.cpp @@ -120,7 +120,7 @@ static Point3f image2plane(Point2f imgpt, const Mat& R, const Mat& tvec, { Mat R1 = R.clone(); R1.col(2) = R1.col(2)*Z + tvec; - Mat_ v = (cameraMatrix*R1).inv()*(Mat_(3,1) << imgpt.x, imgpt.y, 1); + Mat_ v = (cameraMatrix*R1).inv()*(Mat_({3,1}, {imgpt.x, imgpt.y, 1})); double iw = fabs(v(2,0)) > DBL_EPSILON ? 1./v(2,0) : 0; return Point3f((float)(v(0,0)*iw), (float)(v(1,0)*iw), (float)Z); } diff --git a/samples/cpp/tutorial_code/ImgProc/HitMiss/HitMiss.cpp b/samples/cpp/tutorial_code/ImgProc/HitMiss/HitMiss.cpp index 0901191b6f..494606d5ff 100644 --- a/samples/cpp/tutorial_code/ImgProc/HitMiss/HitMiss.cpp +++ b/samples/cpp/tutorial_code/ImgProc/HitMiss/HitMiss.cpp @@ -5,7 +5,7 @@ using namespace cv; int main(){ - Mat input_image = (Mat_(8, 8) << + Mat input_image = Mat_({8, 8}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 0, 255, 255, 255, 0, 0, 0, 0, @@ -13,12 +13,14 @@ int main(){ 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 255, 255, 0, 0, 255, 0, 255, 0, 0, 255, 0, - 0, 255, 255, 255, 0, 0, 0, 0); + 0, 255, 255, 255, 0, 0, 0, 0 + }); - Mat kernel = (Mat_(3, 3) << + Mat kernel = Mat_({3, 3}, { 0, 1, 0, 1, -1, 1, - 0, 1, 0); + 0, 1, 0 + }); Mat output_image; morphologyEx(input_image, output_image, MORPH_HITMISS, kernel); diff --git a/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp b/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp index 818fcb4735..e8e7644c6a 100644 --- a/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp +++ b/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp @@ -41,10 +41,11 @@ int main(int argc, char *argv[]) //! [sharp] // Create a kernel that we will use to sharpen our image - Mat kernel = (Mat_(3,3) << - 1, 1, 1, - 1, -8, 1, - 1, 1, 1); // an approximation of second derivative, a quite strong kernel + Mat kernel = Mat_({3,3}, { + 1, 1, 1, + 1, -8, 1, + 1, 1, 1 + }); // an approximation of second derivative, a quite strong kernel // do the laplacian filtering as it is // well, we need to convert everything in something more deeper then CV_8U diff --git a/samples/cpp/tutorial_code/core/how_to_use_OpenCV_parallel_for_/how_to_use_OpenCV_parallel_for_new.cpp b/samples/cpp/tutorial_code/core/how_to_use_OpenCV_parallel_for_/how_to_use_OpenCV_parallel_for_new.cpp index cab73874a4..52ecbe5cf1 100644 --- a/samples/cpp/tutorial_code/core/how_to_use_OpenCV_parallel_for_/how_to_use_OpenCV_parallel_for_new.cpp +++ b/samples/cpp/tutorial_code/core/how_to_use_OpenCV_parallel_for_/how_to_use_OpenCV_parallel_for_new.cpp @@ -273,9 +273,11 @@ int main(int argc, char *argv[]) namedWindow("Output3", 1); imshow("Input", src); - kernel = (Mat_(3, 3) << 1, 0, -1, - 1, 0, -1, - 1, 0, -1); + kernel = Mat_({3, 3}, { + 1, 0, -1, + 1, 0, -1, + 1, 0, -1 + }); /* Uncomment the kernels you want to use or write your own kernels to test out diff --git a/samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp b/samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp index c1c67b90ce..13f8249f4d 100644 --- a/samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp +++ b/samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp @@ -51,9 +51,11 @@ int main( int argc, char* argv[]) waitKey(); //![kern] - Mat kernel = (Mat_(3,3) << 0, -1, 0, - -1, 5, -1, - 0, -1, 0); + Mat kernel = Mat_({3,3}, { + 0, -1, 0, + -1, 5, -1, + 0, -1, 0 + }); //![kern] t = (double)getTickCount(); diff --git a/samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp b/samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp index d9e0d1f94d..aa8e3dc6f4 100644 --- a/samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp +++ b/samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp @@ -54,14 +54,9 @@ int main(int,char**) //! [matlab] // create a 3x3 double-precision identity matrix - //! [comma] - Mat C = (Mat_(3,3) << 0, -1, 0, -1, 5, -1, 0, -1, 0); - cout << "C = " << endl << " " << C << endl << endl; - //! [comma] - // do the same with initializer_list //! [list] - C = (Mat_({0, -1, 0, -1, 5, -1, 0, -1, 0})).reshape(3); + Mat C = Mat_({3, 3}, {0, -1, 0, -1, 5, -1, 0, -1, 0}); cout << "C = " << endl << " " << C << endl << endl; //! [list] diff --git a/samples/cpp/tutorial_code/core/univ_intrin/univ_intrin.cpp b/samples/cpp/tutorial_code/core/univ_intrin/univ_intrin.cpp index 52018461c3..e79a634e9a 100644 --- a/samples/cpp/tutorial_code/core/univ_intrin/univ_intrin.cpp +++ b/samples/cpp/tutorial_code/core/univ_intrin/univ_intrin.cpp @@ -201,9 +201,11 @@ int main(int argc, char *argv[]) namedWindow("Output", 1); imshow("Input", src); - kernel = (Mat_(3, 3) << 1, 0, -1, - 2, 0, -2, - 1, 0, -1); + kernel = Mat_({3, 3}, { + 1., 0., -1., + 2., 0., -2., + 1., 0., -1. + }); t = (double)getTickCount(); @@ -227,4 +229,4 @@ int main(int argc, char *argv[]) waitKey(0); return 0; -} \ No newline at end of file +} diff --git a/samples/cpp/tutorial_code/features2D/Homography/decompose_homography.cpp b/samples/cpp/tutorial_code/features2D/Homography/decompose_homography.cpp index acc2faa88b..60388e301c 100644 --- a/samples/cpp/tutorial_code/features2D/Homography/decompose_homography.cpp +++ b/samples/cpp/tutorial_code/features2D/Homography/decompose_homography.cpp @@ -92,7 +92,7 @@ void decomposeHomography(const string &img1Path, const string &img2Path, const S //! [compute-camera-displacement] //! [compute-plane-normal-at-camera-pose-1] - Mat normal = (Mat_(3,1) << 0, 0, 1); + Mat normal = Mat_({3,1}, {0, 0, 1}); Mat normal1 = R1*normal; //! [compute-plane-normal-at-camera-pose-1] diff --git a/samples/cpp/tutorial_code/features2D/Homography/homography_from_camera_displacement.cpp b/samples/cpp/tutorial_code/features2D/Homography/homography_from_camera_displacement.cpp index 5bcb6dbb7b..628d42221b 100644 --- a/samples/cpp/tutorial_code/features2D/Homography/homography_from_camera_displacement.cpp +++ b/samples/cpp/tutorial_code/features2D/Homography/homography_from_camera_displacement.cpp @@ -112,7 +112,7 @@ void homographyFromCameraDisplacement(const string &img1Path, const string &img2 //! [compute-camera-displacement] //! [compute-plane-normal-at-camera-pose-1] - Mat normal = (Mat_(3,1) << 0, 0, 1); + Mat normal = Mat_({3,1}, {0, 0, 1}); Mat normal1 = R1*normal; //! [compute-plane-normal-at-camera-pose-1] diff --git a/samples/cpp/tutorial_code/features2D/Homography/panorama_stitching_rotating_camera.cpp b/samples/cpp/tutorial_code/features2D/Homography/panorama_stitching_rotating_camera.cpp index 3ab29280ae..9806531b89 100644 --- a/samples/cpp/tutorial_code/features2D/Homography/panorama_stitching_rotating_camera.cpp +++ b/samples/cpp/tutorial_code/features2D/Homography/panorama_stitching_rotating_camera.cpp @@ -14,23 +14,29 @@ void basicPanoramaStitching(const string &img1Path, const string &img2Path) Mat img2 = imread( samples::findFile( img2Path ) ); //! [camera-pose-from-Blender-at-location-1] - Mat c1Mo = (Mat_(4,4) << 0.9659258723258972, 0.2588190734386444, 0.0, 1.5529145002365112, - 0.08852133899927139, -0.3303661346435547, -0.9396926164627075, -0.10281121730804443, - -0.24321036040782928, 0.9076734185218811, -0.342020183801651, 6.130080699920654, - 0, 0, 0, 1); + Mat c1Mo = Mat_({4,4}, { + 0.9659258723258972, 0.2588190734386444, 0.0, 1.5529145002365112, + 0.08852133899927139, -0.3303661346435547, -0.9396926164627075, -0.10281121730804443, + -0.24321036040782928, 0.9076734185218811, -0.342020183801651, 6.130080699920654, + 0, 0, 0, 1 + }); //! [camera-pose-from-Blender-at-location-1] //! [camera-pose-from-Blender-at-location-2] - Mat c2Mo = (Mat_(4,4) << 0.9659258723258972, -0.2588190734386444, 0.0, -1.5529145002365112, - -0.08852133899927139, -0.3303661346435547, -0.9396926164627075, -0.10281121730804443, - 0.24321036040782928, 0.9076734185218811, -0.342020183801651, 6.130080699920654, - 0, 0, 0, 1); + Mat c2Mo = Mat_({4,4}, { + 0.9659258723258972, -0.2588190734386444, 0.0, -1.5529145002365112, + -0.08852133899927139, -0.3303661346435547, -0.9396926164627075, -0.10281121730804443, + 0.24321036040782928, 0.9076734185218811, -0.342020183801651, 6.130080699920654, + 0, 0, 0, 1 + }); //! [camera-pose-from-Blender-at-location-2] //! [camera-intrinsics-from-Blender] - Mat cameraMatrix = (Mat_(3,3) << 700.0, 0.0, 320.0, - 0.0, 700.0, 240.0, - 0, 0, 1); + Mat cameraMatrix = Mat_({3,3}, { + 700.0, 0.0, 320.0, + 0.0, 700.0, 240.0, + 0, 0, 1 + }); //! [camera-intrinsics-from-Blender] //! [extract-rotation] diff --git a/samples/cpp/tutorial_code/features2D/Homography/perspective_correction.cpp b/samples/cpp/tutorial_code/features2D/Homography/perspective_correction.cpp index 9d5bc2442e..0b6a11ea34 100644 --- a/samples/cpp/tutorial_code/features2D/Homography/perspective_correction.cpp +++ b/samples/cpp/tutorial_code/features2D/Homography/perspective_correction.cpp @@ -53,7 +53,7 @@ void perspectiveCorrection(const string &img1Path, const string &img2Path, const hconcat(img1, img2, img_draw_matches); for (size_t i = 0; i < corners1.size(); i++) { - Mat pt1 = (Mat_(3,1) << corners1[i].x, corners1[i].y, 1); + Mat pt1 = Mat_({3,1}, {corners1[i].x, corners1[i].y, 1}); Mat pt2 = H * pt1; pt2 /= pt2.at(2); diff --git a/samples/cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp b/samples/cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp index a5bcf98cc0..a3ee002167 100644 --- a/samples/cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp +++ b/samples/cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp @@ -41,7 +41,7 @@ int main(int, char**) { for (int j = 0; j < image.cols; j++) { - Mat sampleMat = (Mat_(1,2) << j,i); + Mat sampleMat = Mat_({1,2}, {(float)j,(float)i}); float response = svm->predict(sampleMat); if (response == 1) diff --git a/samples/cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp b/samples/cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp index f8b7a373cc..1dd61c05fd 100644 --- a/samples/cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp +++ b/samples/cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp @@ -96,7 +96,7 @@ int main() { for (int j = 0; j < I.cols; j++) { - Mat sampleMat = (Mat_(1,2) << j, i); + Mat sampleMat = Mat_({1,2}, {(float)j, (float)i}); float response = svm->predict(sampleMat); if (response == 1) I.at(i,j) = green; diff --git a/samples/cpp/tutorial_code/snippets/core_merge.cpp b/samples/cpp/tutorial_code/snippets/core_merge.cpp index 404a0d3eb4..0699e695e5 100644 --- a/samples/cpp/tutorial_code/snippets/core_merge.cpp +++ b/samples/cpp/tutorial_code/snippets/core_merge.cpp @@ -17,9 +17,9 @@ using namespace cv; int main() { //! [example] - Mat m1 = (Mat_(2,2) << 1,4,7,10); - Mat m2 = (Mat_(2,2) << 2,5,8,11); - Mat m3 = (Mat_(2,2) << 3,6,9,12); + Mat m1 = Mat_({2,2}, {1,4,7,10}); + Mat m2 = Mat_({2,2}, {2,5,8,11}); + Mat m3 = Mat_({2,2}, {3,6,9,12}); Mat channels[3] = {m1, m2, m3}; Mat m; diff --git a/samples/cpp/tutorial_code/snippets/core_reduce.cpp b/samples/cpp/tutorial_code/snippets/core_reduce.cpp index b9d89629bb..0bcbf5cc1f 100644 --- a/samples/cpp/tutorial_code/snippets/core_reduce.cpp +++ b/samples/cpp/tutorial_code/snippets/core_reduce.cpp @@ -20,7 +20,7 @@ int main() { { //! [example] - Mat m = (Mat_(3,2) << 1,2,3,4,5,6); + Mat m = Mat_({3,2}, {1,2,3,4,5,6}); Mat col_sum, row_sum; reduce(m, col_sum, 0, REDUCE_SUM, CV_32F); diff --git a/samples/dnn/object_detection.cpp b/samples/dnn/object_detection.cpp index a0c255fd4e..63f7726506 100644 --- a/samples/dnn/object_detection.cpp +++ b/samples/dnn/object_detection.cpp @@ -324,7 +324,7 @@ inline void preprocess(const Mat& frame, Net& net, Size inpSize, float scale, if (net.getLayer(0)->outputNameToIndex("im_info") != -1) // Faster-RCNN or R-FCN { resize(frame, frame, inpSize); - Mat imInfo = (Mat_(1, 3) << inpSize.height, inpSize.width, 1.6f); + Mat imInfo = Mat_({1, 3}, {(float)inpSize.height, (float)inpSize.width, 1.6f}); net.setInput(imInfo, "im_info"); } }