标签:star val enter 中心 point 通道 第一个 邻接 椭圆
Mat类的构造函数有20多种,详见https://docs.opencv.org/4.1.1/d3/d63/classcv_1_1Mat.html#af1d014cecd1510cdf580bf2ed7e5aafc;
现列出几种常用构造函数以及方法:
1.Mat(int rows,int cols ,int type);
parameters:
rows | Number of rows in a 2D array. |
cols | Number of columns in a 2D array. |
type | Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. |
2.Mat(Size size ,int type);
Parameters :
size | 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the number of columns go in the reverse order. |
type | Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. |
3. Mat(int rows,int cols ,int type,const Scalar & s);
Parameters:
rows | Number of rows in a 2D array. |
cols | Number of columns in a 2D array. |
type | Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. |
s | An optional value to initialize each matrix element with. To set all the matrix elements to the particular value after the construction, use the assignment operator Mat::operator=(const Scalar& value) . |
4.Mat(Size size ,int type,const Scalar & s);
Parameters:
size | 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the number of columns go in the reverse order. |
type | Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. |
s | An optional value to initialize each matrix element with. To set all the matrix elements to the particular value after the construction, use the assignment operator Mat::operator=(const Scalar& value) . |
Mat img;//创建无初始化矩阵
Mat img1(200,100,CV_8UC1);//200行,100列(长200,宽100)
Mat img2(Size(200,100),CV_8UC3,Scalar(0,255,0));//长100,宽200
Mat img3(200,100,CV_8UC3,Scalar(0,255,0));//创建200行,100列的8位三通道矩阵
Mat img4(200,100,CV_8UC1,Scalar(255));//创建单通道矩阵
方法:
参考:https://docs.opencv.org/4.1.1/d3/d63/classcv_1_1Mat.html#a33fd5d125b4c302b0c9aa86980791a77;
第一个参数,InputOutputArray img,要绘制椭圆的图像;
第二个参数,const RotatedRect& box,通过RotatedRect选择椭圆表示,这意味着函数在旋转矩形中画一个椭圆;
第三个参数,Point center,椭圆的中心点;
第四个参数,Size axes,椭圆主轴尺寸的一半;
第五个参数,double angle,椭圆旋转角,以度为单位;
第六个参数,double startAngle,椭圆弧的起始角,以度为单位;
第七个参数,double endAngle,椭圆弧的结束角,以度为单位;
第八个参数,const Scalar& color,绘制椭圆线的颜色;
第九个参数,int thickness = 1,线段的粗细;
第十个参数,int lineType = LINE_8,线段的类型;
线的类型:
FILLED,填充;
LINE_4,4连通的线条;
LINE_8 ,8连通的线条;
LINE_AA ,抗锯齿线条;
标签:star val enter 中心 point 通道 第一个 邻接 椭圆
原文地址:https://www.cnblogs.com/xingyuanzier/p/11588868.html