1 画线
void line(InputOutputArray img, Point pt1, Point pt2, const Scalar&color, int thickness = 1, int lineType = LINE_8, int shift = 0);
参数:
- img:绘画的图片
- pt1:端点位置1
- pt2:端点位置2
- color:画线的颜色
- thickness :线宽
- lineType :线型
- shift:点坐标中的小数位数
示例:
//画线
void draw_line(Mat &mat) {
Point p1(30,30);
Point p2;
p2.x = 140;
p2.y = 140;
Scalar color(200,70,30);
line(mat, p1, p2, color, 10,LINE_8);
}
2 画矩形
void rectangle(Mat& img, Rect rec, const Scalar& color, int thickness = 1, int lineType = LINE_8, int shift = 0);
参数:
- img:绘画的图片
- rec:矩形位置及大小
- color:画线的颜色
- thickness :线宽
- lineType :线型
- shift:点坐标中的小数位数
示例:
//画矩形
void draw_rect(Mat& mat){
Rect rect(200, 50, 300, 300);
Scalar color = Scalar(100, 170, 30);
rectangle(mat,rect, color,10, LINE_8);
}