Opencv Mat 类 (一)
我有一个梦想,我写的代码,可以像诗一样优美。我有一个梦想,我做的设计,能恰到好处,既不过度,也无不足。
opencv,一直零零散散的看着,总没有沉下心来总结。
正好手里的项目涉及到了opencv的相关内容,趁着这个机会,总结回顾下,也算是巩固知识点了(总结的不对的地方,欢迎各位指正)。
opencv中一个很重要的点就是Mat类了,当然回顾也应该从这里开始,话不多说,上干货!
先上代码,再一一过。
void useMat()
{
Mat img = imread("1.jpg", IMREAD_COLOR);//加载图片
if (img.empty())
{
cout << "read picture failed";
return;
}
cout << "flags = " << img.flags << endl;
cout << "dims = " << img.dims << endl;//矩阵维度
cout << "rows = " << img.rows << endl;//行数
cout << "cols = " << img.cols << endl;//列数
cout << "depths = " << img.depth() << endl;//深度
cout << "channels = " << img.channels() << endl;//通道数
cout << "iscontinuous = " << img.isContinuous() << endl;
cout << "isSubMatrix() = " << img.isSubmatrix() << endl;
cout << "type() = " << img.type() << endl;//类型
Mat mat(2, 3, CV_64FC2, Scalar(1.0, 3.0));
cout << "mat = " << endl << mat << endl;
cout << "rows = " << mat.rows << endl;
cout << "cols = " << mat.cols << endl;
cout << "channel = " << mat.channels() << endl;
cout <<

最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



