mirror of
https://github.com/opencv/opencv.git
synced 2026-07-25 21:33:04 +04:00
core: deprecate MatCommaInitializer_
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
using namespace cv;
|
||||
|
||||
int main(){
|
||||
Mat input_image = (Mat_<uchar>(8, 8) <<
|
||||
Mat input_image = Mat_<uchar>({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_<int>(3, 3) <<
|
||||
Mat kernel = Mat_<int>({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);
|
||||
|
||||
@@ -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_<float>(3,3) <<
|
||||
1, 1, 1,
|
||||
1, -8, 1,
|
||||
1, 1, 1); // an approximation of second derivative, a quite strong kernel
|
||||
Mat kernel = Mat_<float>({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
|
||||
|
||||
+5
-3
@@ -273,9 +273,11 @@ int main(int argc, char *argv[])
|
||||
namedWindow("Output3", 1);
|
||||
imshow("Input", src);
|
||||
|
||||
kernel = (Mat_<double>(3, 3) << 1, 0, -1,
|
||||
1, 0, -1,
|
||||
1, 0, -1);
|
||||
kernel = Mat_<double>({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
|
||||
|
||||
@@ -51,9 +51,11 @@ int main( int argc, char* argv[])
|
||||
waitKey();
|
||||
|
||||
//![kern]
|
||||
Mat kernel = (Mat_<char>(3,3) << 0, -1, 0,
|
||||
-1, 5, -1,
|
||||
0, -1, 0);
|
||||
Mat kernel = Mat_<char>({3,3}, {
|
||||
0, -1, 0,
|
||||
-1, 5, -1,
|
||||
0, -1, 0
|
||||
});
|
||||
//![kern]
|
||||
|
||||
t = (double)getTickCount();
|
||||
|
||||
+1
-6
@@ -54,14 +54,9 @@ int main(int,char**)
|
||||
//! [matlab]
|
||||
|
||||
// create a 3x3 double-precision identity matrix
|
||||
//! [comma]
|
||||
Mat C = (Mat_<double>(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_<double>({0, -1, 0, -1, 5, -1, 0, -1, 0})).reshape(3);
|
||||
Mat C = Mat_<double>({3, 3}, {0, -1, 0, -1, 5, -1, 0, -1, 0});
|
||||
cout << "C = " << endl << " " << C << endl << endl;
|
||||
//! [list]
|
||||
|
||||
|
||||
@@ -201,9 +201,11 @@ int main(int argc, char *argv[])
|
||||
namedWindow("Output", 1);
|
||||
imshow("Input", src);
|
||||
|
||||
kernel = (Mat_<float>(3, 3) << 1, 0, -1,
|
||||
2, 0, -2,
|
||||
1, 0, -1);
|
||||
kernel = Mat_<float>({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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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_<double>(3,1) << 0, 0, 1);
|
||||
Mat normal = Mat_<double>({3,1}, {0, 0, 1});
|
||||
Mat normal1 = R1*normal;
|
||||
//! [compute-plane-normal-at-camera-pose-1]
|
||||
|
||||
|
||||
+1
-1
@@ -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_<double>(3,1) << 0, 0, 1);
|
||||
Mat normal = Mat_<double>({3,1}, {0, 0, 1});
|
||||
Mat normal1 = R1*normal;
|
||||
//! [compute-plane-normal-at-camera-pose-1]
|
||||
|
||||
|
||||
+17
-11
@@ -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_<double>(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_<double>({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_<double>(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_<double>({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_<double>(3,3) << 700.0, 0.0, 320.0,
|
||||
0.0, 700.0, 240.0,
|
||||
0, 0, 1);
|
||||
Mat cameraMatrix = Mat_<double>({3,3}, {
|
||||
700.0, 0.0, 320.0,
|
||||
0.0, 700.0, 240.0,
|
||||
0, 0, 1
|
||||
});
|
||||
//! [camera-intrinsics-from-Blender]
|
||||
|
||||
//! [extract-rotation]
|
||||
|
||||
@@ -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_<double>(3,1) << corners1[i].x, corners1[i].y, 1);
|
||||
Mat pt1 = Mat_<double>({3,1}, {corners1[i].x, corners1[i].y, 1});
|
||||
Mat pt2 = H * pt1;
|
||||
pt2 /= pt2.at<double>(2);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ int main(int, char**)
|
||||
{
|
||||
for (int j = 0; j < image.cols; j++)
|
||||
{
|
||||
Mat sampleMat = (Mat_<float>(1,2) << j,i);
|
||||
Mat sampleMat = Mat_<float>({1,2}, {(float)j,(float)i});
|
||||
float response = svm->predict(sampleMat);
|
||||
|
||||
if (response == 1)
|
||||
|
||||
@@ -96,7 +96,7 @@ int main()
|
||||
{
|
||||
for (int j = 0; j < I.cols; j++)
|
||||
{
|
||||
Mat sampleMat = (Mat_<float>(1,2) << j, i);
|
||||
Mat sampleMat = Mat_<float>({1,2}, {(float)j, (float)i});
|
||||
float response = svm->predict(sampleMat);
|
||||
|
||||
if (response == 1) I.at<Vec3b>(i,j) = green;
|
||||
|
||||
@@ -17,9 +17,9 @@ using namespace cv;
|
||||
int main()
|
||||
{
|
||||
//! [example]
|
||||
Mat m1 = (Mat_<uchar>(2,2) << 1,4,7,10);
|
||||
Mat m2 = (Mat_<uchar>(2,2) << 2,5,8,11);
|
||||
Mat m3 = (Mat_<uchar>(2,2) << 3,6,9,12);
|
||||
Mat m1 = Mat_<uchar>({2,2}, {1,4,7,10});
|
||||
Mat m2 = Mat_<uchar>({2,2}, {2,5,8,11});
|
||||
Mat m3 = Mat_<uchar>({2,2}, {3,6,9,12});
|
||||
|
||||
Mat channels[3] = {m1, m2, m3};
|
||||
Mat m;
|
||||
|
||||
@@ -20,7 +20,7 @@ int main()
|
||||
{
|
||||
{
|
||||
//! [example]
|
||||
Mat m = (Mat_<uchar>(3,2) << 1,2,3,4,5,6);
|
||||
Mat m = Mat_<uchar>({3,2}, {1,2,3,4,5,6});
|
||||
Mat col_sum, row_sum;
|
||||
|
||||
reduce(m, col_sum, 0, REDUCE_SUM, CV_32F);
|
||||
|
||||
Reference in New Issue
Block a user