1.矩形框
1.1使用对角线的两点pt1,pt2画一个矩形轮廓或者填充矩形
void rectangle(InputOutputArray img, Point pt1, Point pt2,
const Scalar& color, int thickness = 1,
int lineType = LINE_8, int shift = 0);
rectangle(matImage,Point(20,200),Point(200,300),Scalar(255,0,0),1,1,0);
1.2使用矩阵类rec画一个矩形轮廓或者填充矩形
void rectangle(CV_IN_OUT Mat& img, Rect rec,
const Scalar& color, int thickness = 1,
int lineType = LINE_8, int shift = 0);
//Rect(int a,int b,int c,int d)a,b为矩形的左上角坐标,c,d为矩形的长和宽
rectangle(matImage,Rect(100,300,20,200),Scalar(0,0,255),1,1,0);
参考文献: