Opencv学习:学习画图形

日常坑爹opencv

1、绘制线段

 

1
2
3
4
5
6
Mat picture(500,500,CV_8UC3,Scalar(0,0,0,0.5));
Point point1 = Point(100, 100);
Point point2 = Point(400, 400);
line(picture, point1, point2, Scalar(0, 255, 0), 2);
imshow("sbn", picture);
waitKey(0);

 显示结果如下

 

 

复制代码
    Mat picture(500,500,CV_8UC3,Scalar(0,0,0,0.5));
    Point point1 = Point(100, 100);
    Point point2 = Point(400, 400);
    Point point3 = Point(100, 200);
    Point point4 = Point(400, 200);
    line(picture, point1, point2, Scalar(0, 255, 0), 2);
    line(picture, point3, point4, Scalar(0, 255, 255), 2);
    imshow("sbn", picture);
    waitKey(0);
复制代码

 

 

2、绘制三角形

复制代码
    Mat picture(500,500,CV_8UC3,Scalar(0,0,0,0.5));
    Point point1 = Point(200, 150);
    Point point2 = Point(50, 250);
    Point point3 = Point(400, 380);
    Point point4 = Point(200, 150);
    line(picture, point1, point2, Scalar(24, 224, 139), 2);
    line(picture, point2, point3, Scalar(24, 224, 139), 2);
    line(picture, point3, point1, Scalar(24, 224, 139), 2);
    imshow("sbn", picture);
    waitKey(0);
复制代码

 

 

3、绘制圆形

    Mat picture(500,500,CV_8UC3,Scalar(0,0,0,0.5));
    Point point1 = Point(200, 150);
    circle(picture, point1, 50, Scalar(255, 255, 255, 255), 2);
    imshow("sbn", picture);
    waitKey(0);

 

 4、绘制椭圆

 

    Mat picture(500,500,CV_8UC3,Scalar(0,0,0,0.5));
    Point point1 = Point(200, 150);
    ellipse(picture,Point(256,256),Size(150, 100),0,0, 360,Scalar(255, 129, 0),2,-1);
    imshow("sbn", picture);
    waitKey(0);

 

5.绘制矩形

    Mat picture(500,500,CV_8UC3,Scalar(0,0,0,0.5));
    rectangle(picture, Point(50, 100), Point(200, 300), Scalar(0, 255, 255), -1);
    imshow("sbn", picture);
    waitKey(0);

 

 

 

 

5、加入文字

 

posted on   大湿Mastwet  阅读(261)  评论(0编辑  收藏  举报

编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示