Point 二维点坐标(x,y)

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

 

Point3 3维点坐标(x,y,z)

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

 

Size_  尺寸(width, height)

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

Rect_  矩形区域(x,y,width,height) ,(x,y)左上角坐标, 范围[x, x + width), [y, y + height)

rect = rect ± point //矩形偏移(shifting a rectangle by a certain offset)
rect = rect ± size //改变大小(expanding or shrinking a rectangle by a certain amount)
rect += point, rect -= point, rect += size, rect -= size //(augmenting operations)
rect = rect1 & rect2 //矩形交集(rectangle intersection)
rect = rect1 | rect2 //包含r1r2的最小矩形(minimum area rectangle containing rect2 and rect3 )
rect &= rect1, rect |= rect1 //(and the corresponding augmenting operations)
rect == rect1, rect != rect1 //(rectangle comparison)

RotatedRect  旋转矩形

// p中心点(不是左上角坐标),size尺寸,angle旋转角度
RotatedRect::RotatedRect(const Point2f& p, const Size2f& size, float angle)
RotatedRect rRect = RotatedRect(Point2f(100,100), Size2f(100,50), 30);

Matx 小矩阵

template<typename_Tp, int m, int n> class Matx {...};
typedef Matx<float, 1, 2> Matx12f;
typedef Matx<double, 1, 2> Matx12d;
...
typedef Matx<float, 1, 6> Matx16f;
typedef Matx<double, 1, 6> Matx16d;
typedef Matx<float, 2, 1> Matx21f;
typedef Matx<double, 2, 1> Matx21d;
...
typedef Matx<float, 6, 1> Matx61f;
typedef Matx<double, 6, 1> Matx61d;
typedef Matx<float, 2, 2> Matx22f;
typedef Matx<double, 2, 2> Matx22d;
...
typedef Matx<float, 6, 6> Matx66f;
typedef Matx<double, 6, 6> Matx66d;

Matx33f m(1, 2, 3,
4, 5, 6,
7, 8, 9);
cout << sum(Mat(m*m.t())) << endl;//Matx转化为Mat

Vec  短向量,基于Matx

template<typename_Tp, int n> class Vec : public Matx<_Tp, n, 1> {...};
typedef Vec<uchar, 2> Vec2b;
typedef Vec<uchar, 3> Vec3b;
typedef Vec<uchar, 4> Vec4b;
typedef Vec<short, 2> Vec2s;
typedef Vec<short, 3> Vec3s;
typedef Vec<short, 4> Vec4s;
typedef Vec<int, 2> Vec2i;
typedef Vec<int, 3> Vec3i;
typedef Vec<int, 4> Vec4i;
typedef Vec<float, 2> Vec2f;
typedef Vec<float, 3> Vec3f;
typedef Vec<float, 4> Vec4f;
typedef Vec<float, 6> Vec6f;
typedef Vec<double, 2> Vec2d;
typedef Vec<double, 3> Vec3d;
typedef Vec<double, 4> Vec4d;
typedef Vec<double, 6> Vec6d;

Scalar_  四维向量

template<typename_Tp> class Scalar_: public Vec<_Tp, 4> { ... };
typedef Scalar_<double> Scalar;

Range 范围,(start, end) 

Mat m(300,300,CV32F);
Mat part = m(Range::all(), Range(20, 200)); // 相当于matlab的m(:, 20 : 199)

Mat 矩阵结构

Mat img;
img.data  //数据区域的指针
img.dims  //矩阵维度
img.sizes  //维度
img.elemSize()  //每个元素占的字节空间大小,与元素类型相关,如CV_8U
img.step[]  //用来计算元素地址, M.step[i] 表示所有比i大的维度所占空间大小
img.step[i] >= M.step[i+1]*img.sizes[i+1];