opencv-Mat补充
来源:互联网 发布:淘宝闲置物品怎么下架 编辑:程序博客网 时间:2024/06/11 16:47
opencv2.4.3所给代码如下:
/* For description look into the help() function. */#include "opencv2/core/core.hpp"#include <iostream>//#include <opencv2/core/core.hpp>//#include <opencv2/highgui/highgui.hpp>//#include <cv.h>//#include <iostream>using namespace std;using namespace cv;void help(){ cout << "\n--------------------------------------------------------------------------" << endl << "This program shows how to create matrices(cv::Mat) in OpenCV and its serial" << " out capabilities" << endl << "That is, cv::Mat M(...); M.create and cout << M. " << endl << "Shows how output can be formated to OpenCV, python, numpy, csv and C styles." << endl << "Usage:" << endl << "./cvout_sample" << endl << "--------------------------------------------------------------------------" << endl << endl;}int main(int,char**){ help(); // create by using the constructor Mat M(2,2, CV_8UC3, Scalar(0,0,255)); cout << "M = " << endl << " " << M << endl << endl; // create by using the create function() M.create(4,4, CV_8UC(2)); cout << "M = "<< endl << " " << M << endl << endl; // create multidimensional matrices int sz[3] = {2,2,2}; Mat L(3,sz, CV_8UC(1), Scalar::all(0)); // Cannot print via operator << // Create using MATLAB style eye, ones or zero matrix Mat E = Mat::eye(4, 4, CV_64F); cout << "E = " << endl << " " << E << endl << endl; Mat O = Mat::ones(2, 2, CV_32F); cout << "O = " << endl << " " << O << endl << endl; Mat Z = Mat::zeros(3,3, CV_8UC1); cout << "Z = " << endl << " " << Z << endl << endl; // create a 3x3 double-precision identity matrix Mat C = (Mat_<double>(3,3) << 0, -1, 0, -1, 5, -1, 0, -1, 0); cout << "C = " << endl << " " << C << endl << endl; Mat RowClone = C.row(1).clone(); cout << "RowClone = " << endl << " " << RowClone << endl << endl; // Fill a matrix with random values Mat R = Mat(3, 2, CV_8UC3); randu(R, Scalar::all(0), Scalar::all(255)); // Demonstrate the output formating options cout << "R (default) = " << endl << R << endl << endl; cout << "R (python) = " << endl << format(R,"python") << endl << endl; cout << "R (numpy) = " << endl << format(R,"numpy" ) << endl << endl; cout << "R (csv) = " << endl << format(R,"csv" ) << endl << endl; cout << "R (c) = " << endl << format(R,"C" ) << endl << endl; Point2f P(5, 1); cout << "Point (2D) = " << P << endl << endl; Point3f P3f(2, 6, 7); cout << "Point (3D) = " << P3f << endl << endl; vector<float> v; v.push_back( (float)CV_PI); v.push_back(2); v.push_back(3.01f); cout << "Vector of floats via Mat = " << Mat(v) << endl << endl; vector<Point2f> vPoints(20); for (size_t E = 0; E < vPoints.size(); ++E) vPoints[E] = Point2f((float)(E * 5), (float)(E % 7)); cout << "A vector of 2D Points = " << vPoints << endl << endl; return 0;}
![](http://img.my.csdn.net/uploads/201303/24/1364093535_8910.png)
![](http://img.my.csdn.net/uploads/201303/24/1364093541_2878.png)
- opencv-Mat补充
- OpenCV Mat
- opencv-Mat
- Mat--opencv
- opencv---mat
- opencv Mat
- opencv mat
- OpenCV Mat
- opencv-mat
- opencv MAT
- opencv-Mat
- OpenCV: Mat
- OpenCV-----Mat
- opencv mat
- 【opencv】 opencv之Mat详解
- 【opencv】opencv之Mat属性
- opencv入门(Mat)
- opencv Mat() 构造函数
- libevent timer定时器
- snmptrap、snmpinform和snmptrapd的详细介绍及其用法
- 再看ADO.NET
- 一口一口吃掉Struts(九)——国际化问题(2)
- linux下作业控制
- opencv-Mat补充
- Hdu 1039 - Easier Done Than Said?
- JDBC连接MySQL数据库
- 低电平中断和下降沿中断的区别
- PDF library in Java
- 面向对象
- Netty框架入门
- Lua syntax
- web性能优化14法则