详解opencv中画圆circle函数和椭圆ellipse函数


Posted in Python onDecember 27, 2019

1.      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);

ellipse函数将椭圆画到图像 lmg 上, 椭圆中心为点center,并且大小位于矩形 axes 内,椭圆旋转角度为 angle, 扩展的弧度从 0 度到 360 度,

图形颜色为 Scalar(x, y,z),线宽 (thickness)为 1,线型(lineType)为 8 (8 联通线型)。

2.     void circle(InputOutputArray img,  Point center,  int radius,  const Scalar& color,   int thickness = 1,   int lineType = LINE_8,  int shift = 0);

img :表示输入的图像 

center:  圆心坐标 

radius: 圆的半径

color:Scalar类型,表示圆的颜色,例如蓝色为Scalar(255,0,0)

thickness:线的宽度 

lineType:线的类型,(默认为8联通型)

#include<iostream>
#include<opencv2/opencv.hpp>
using namespace cv;
using namespace std;
#define WINDOW_NAME1 "绘制图1"
#define WINDOW_NAME2 "绘制图2"
#define WINDOW_WIDTH 600  //定义窗口大小
string image = "C:\\Users\\asus\\Pictures\\Saved Pictures\\123.jpg";
void DrawEllipse(Mat img, double angle);
void DrawFi1ledCirc1e(Mat img, Point center);
int main()
{ 
  Mat atomImage = Mat::zeros(WINDOW_WIDTH, WINDOW_WIDTH, CV_8UC3);
  Mat rookImage = Mat::zeros(WINDOW_WIDTH, WINDOW_WIDTH, CV_8UC3);
  //绘制椭圆
  DrawEllipse(atomImage, 90);
  DrawEllipse(atomImage, 0);
  DrawEllipse(atomImage, 45);
  DrawEllipse(atomImage, -45);
  //绘制圆心
  DrawFi1ledCirc1e(atomImage, Point(WINDOW_WIDTH / 2,WINDOW_WIDTH / 2));
  imshow(WINDOW_NAME1, atomImage);
  waitKey(0);
  return 0;
}
void DrawEllipse(Mat img, double angle) {
  int thickness = 2;
  int lineType = 8;
  ellipse(img, Point(WINDOW_WIDTH / 2, WINDOW_WIDTH / 2),
    Size(WINDOW_WIDTH / 4, WINDOW_WIDTH / 16), angle, 0, 360, Scalar(255, 129, 0),
    thickness, lineType);
}
void DrawFi1ledCirc1e(Mat img, Point center) {
  int thickness = -1;
  int lineType = 8;
  circle(img, center, WINDOW_WIDTH / 32, Scalar(0, 0, 255), thickness, lineType);
}

详解opencv中画圆circle函数和椭圆ellipse函数

总结

以上所述是小编给大家介绍的opencv中画圆circle函数和椭圆ellipse函数,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对三水点靠木网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!

Python 相关文章推荐
王纯业的Python学习笔记 下载
Feb 10 Python
easy_install python包安装管理工具介绍
Feb 10 Python
通过python将大量文件按修改时间分类的方法
Oct 17 Python
python url 参数修改方法
Dec 26 Python
pyqt5移动鼠标显示坐标的方法
Jun 21 Python
Python IDLE或shell中切换路径的操作
Mar 09 Python
python闭包、深浅拷贝、垃圾回收、with语句知识点汇总
Mar 11 Python
keras .h5转移动端的.tflite文件实现方式
May 25 Python
什么是python的必选参数
Jun 21 Python
pytorch查看模型weight与grad方式
Jun 24 Python
Python实现简单的猜单词小游戏
Oct 28 Python
python实现监听键盘
Apr 26 Python
如何更改 pandas dataframe 中两列的位置
Dec 27 #Python
使用OpenCV circle函数图像上画圆的示例代码
Dec 27 #Python
python的slice notation的特殊用法详解
Dec 27 #Python
详解Python Opencv和PIL读取图像文件的差别
Dec 27 #Python
pandas 对group进行聚合的例子
Dec 27 #Python
pandas-resample按时间聚合实例
Dec 27 #Python
python 实现简单的FTP程序
Dec 27 #Python
You might like
php中is_null,empty,isset,unset 的区别详细介绍
2013/04/28 PHP
phpmailer中文乱码问题的解决方法
2014/04/22 PHP
phpmyadmin出现Cannot start session without errors问题解决方法
2014/08/14 PHP
PHP也能干大事 随机函数
2015/04/14 PHP
js实现页面打印功能实例代码(附去页眉页脚功能代码)
2009/12/15 Javascript
jquery.fileEveryWhere.js 一个跨浏览器的file显示插件
2011/10/24 Javascript
JS自调用匿名函数具体实现
2014/02/11 Javascript
jquery中交替点击事件的实现代码
2014/02/14 Javascript
jquery实现类似EasyUI的页面布局可改变左右的宽度
2020/09/12 Javascript
javascript异步编程代码书写规范Promise学习笔记
2015/02/11 Javascript
javascript设计模式之module(模块)模式
2016/08/19 Javascript
jquery拼接ajax 的json和字符串拼接的方法
2017/03/11 Javascript
JavaScript该如何学习 怎样轻松学习JavaScript
2017/06/12 Javascript
使用jquery模拟a标签的click事件无法实现跳转的解决
2018/12/04 jQuery
nodejs 使用http进行post或get请求的实例(携带cookie)
2019/01/03 NodeJs
Vue动态面包屑功能的实现方法
2019/07/01 Javascript
js实现滑动滑块验证登录
2020/07/24 Javascript
vue a标签点击实现赋值方式
2020/09/07 Javascript
python实现定制交互式命令行的方法
2014/07/03 Python
初步介绍Python中的pydoc模块和distutils模块
2015/04/13 Python
关于pip的安装,更新,卸载模块以及使用方法(详解)
2017/05/19 Python
python3.5+tesseract+adb实现西瓜视频或头脑王者辅助答题
2018/01/17 Python
python实现word 2007文档转换为pdf文件
2018/03/15 Python
pandas 根据列的值选取所有行的示例
2018/11/07 Python
使用Django2快速开发Web项目的详细步骤
2019/01/06 Python
详解10个可以快速用Python进行数据分析的小技巧
2019/06/24 Python
python可以用哪些数据库
2020/06/22 Python
CSS3 中的@keyframes介绍
2014/09/02 HTML / CSS
html5中canvas学习笔记1-画板的尺寸与实际显示尺寸
2013/01/06 HTML / CSS
德国最大的拼图在线商店:Puzzle.de
2016/12/17 全球购物
医院护士的求职信范文
2013/12/26 职场文书
《油菜花开了》教学反思
2014/02/22 职场文书
优秀大学生事迹材料
2014/12/24 职场文书
学前班语言教学计划
2015/01/20 职场文书
2015年宣传思想工作总结
2015/05/22 职场文书
毕业生入职感言
2015/07/31 职场文书