OpenCV中一些数据结构的别名

来源:互联网 发布:电脑mac备份文件在哪里 编辑:程序博客网 时间:2024/05/29 13:46

  在平时做项目过程中经常把一些数据类型、数据结构通过typedef转换为别名。项目初期一些没想好的数据类型可以先用别名代替,确定之后就可以直接修改别名;当然别名可以起的有一定的含义,这样开发者在使用的时候,意义更明确,代码跟简洁;跨平台时,只需修改别名定义即可,开发者也无需关注底层的数据结构。OpenCV中也存在这样的别名。
  

1.Mat矩阵元素的类型

enum{CV_8U=0,CV_8S=1,   CV_16U=2,CV_16S=3,   CV_32S=4,CV_32F=5,   CV_64F=6};

2.Point_ 二维点坐标(x,y)

typedef Point_<int> Point2i;typedef Point_<float> Point2f;typedef Point_<double> Point2d;typedef Point2i Point;

3.Point3_ 三维点坐标(x,y,z)

typedef Point3_<int> Point3i;typedef Point3_<float> Point3f;typedef Point3_<double> Point3d;

4.Size_ 矩阵尺寸(width,height)

typedef Size_<int> Size2i;typedef Size_<float> Size2f;typedef Size2i Size;

5.Rect_ 矩阵(x,y,width,height)

rect = rect ± point       //矩形偏移rect = rect ± size       //改变大小rect += point, rect -= point, rect += size, rect -= size rect = rect1 & rect2      //矩形交集rect = rect1 | rect2      //包含r1r2的最小矩形rect &= rect1, rect |= rect1 rect == rect1, rect != rect1 

6.Matx 小矩阵

typedef Matx<float, 1, 2> Matx12f;typedef Matx<double, 1, 2> Matx12d;Matx33f m(1, 2, 3,4, 5, 6,7, 8, 9);

7.Vec 短向量,基于Matx

typedef Vec<int, 4> Vec4i;typedef Vec<uchar, 2> Vec2b;typedef Vec<short, 3> Vec3s;typedef Vec<float, 2> Vec2f;typedef Vec<double, 6> Vec6d;
0 0
原创粉丝点击