Rect()函数
基本概念:
Rect(int x, int y, int width, int height);
参数含义:
Rect(左上角x坐标 , 左上角y坐标,矩形的宽,矩形的高)
例如我们画一个图 Rect(20,50,30,40), 我用matlab画了一下,比较直观
代码:
Rect(0, 0.4 * img1.rows, 0.2 * img1.cols, 0.2 * img1.rows)
那对于Rect(20,50,30,40)有哪些常用的操作?
rect.area(); //返回面积,1200
rect.size();//返回尺寸,30x40
rect.tl();// 返回左上角坐标(20,50)
rect.br();//返回右下角坐标(50,10)
rect.width();//返回宽度30
rect.height();//返回高度40
rect.contains(Point(x,y)) ; //返回布尔true/false, 判断x,y是否在这个矩形中
交集、并集, 矩阵对比,很像C语言
rect = rect1 & rect2;
rect = rect1 | rect2;
rect1 == rect2; //返回布尔值
rect1 != rect2 ; //返回布尔值
Rectangle用法
void cvRectangle( CvArr* img, CvPoint pt1, CvPoint pt2, CvScalar color,
int thickness=1,