首页 > 其他 > 详细

Opencv学习:学习画图形

时间:2020-05-21 13:57:54      阅读:103      评论:0      收藏:0      [点我收藏+]

日常坑爹opencv

1、绘制线段

 

	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、加入文字

 

Opencv学习:学习画图形

原文:https://www.cnblogs.com/bigtwetwet/p/12929802.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!