opencv绘制几何形状

1、绘制线

void line(InputOutputArray img, Point pt1, Point pt2, const Scalar& color,
                     int thickness = 1, int lineType = LINE_8, int shift = 0);

参数shift:表示坐标的缩小倍数;当shift = 1,缩小一倍;shift = 2,缩小两倍

2、绘制箭头

void arrowedLine(InputOutputArray img, Point pt1, Point pt2, const Scalar& color,
                     int thickness=1, int line_type=8, int shift=0, double tipLength=0.1);
从pt1指向pt2的箭头,
参数tipLength:表示箭头长度(相对于线段的长度)
比如当tipLength =1时,箭头长度等于线段长度

3、绘制矩形

void rectangle(InputOutputArray img, Point pt1, Point pt2,
                          const Scalar& color, int thickness = 1,
                          int lineType = LINE_8, int shift = 0);
参数thickness为负数则填充整个矩形
参数pt1:左上角点            参数pt2:右下角点

4、旋转矩形

RotatedRect(const Point2f& center, const Size2f& size, float angle);
参数center:矩形的质心(中心)
参数size:矩形的宽、高
参数angle:旋转角度(顺时针)

5、绘制圆

circle(InputOutputArray img, Point center, int radius,
                       const Scalar& color, int thickness = 1,
                       int lineType = LINE_8, int shift = 0);
参数thickness为负数则填充整个圆

6、绘制椭圆

void ellipse(InputOutputArray img, Point center, Size axes,
                        double angle, double startAngle, double endAngle,
                        const Scalar& color, int thickness = 1,
                        int lineType = LINE_8, int shift = 0);
参数axes:代表椭圆的长轴和短轴
参数angle:代表旋转角度(顺时针)
参数startAngle和endAngle:起始角度和终端角度(顺时针过去)

7、绘制矩形的内接椭圆

void ellipse(InputOutputArray img, const RotatedRect& box, const Scalar& color,
                        int thickness = 1, int lineType = LINE_8);
参数box:设置的旋转矩形;比如RotatedRect  box(Piont(100,100),Size(100,50),0);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值