详解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中的正则表达式
Apr 28 Python
使用anaconda的pip安装第三方python包的操作步骤
Jun 11 Python
Python将list中的string批量转化成int/float的方法
Jun 26 Python
Python2包含中文报错的解决方法
Jul 09 Python
python 通过SSHTunnelForwarder隧道连接redis的方法
Feb 19 Python
PyQt5实现简易计算器
May 30 Python
Python Pandas中根据列的值选取多行数据
Jul 08 Python
python 函数的缺省参数使用注意事项分析
Sep 17 Python
python判断链表是否有环的实例代码
Jan 31 Python
Python私有属性私有方法应用实例解析
Sep 15 Python
Pytorch 如何实现LSTM时间序列预测
May 17 Python
tensorboard 可视化之localhost:6006不显示的解决方案
May 22 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使用curl和正则表达式抓取网页数据示例
2014/04/13 PHP
php使用imagick模块实现图片缩放、裁剪、压缩示例
2014/04/17 PHP
PHP读取配置文件类实例(可读取ini,yaml,xml等)
2015/07/28 PHP
thinkPHP3.2.3结合Laypage实现的分页功能示例
2018/05/28 PHP
laravel 解决crontab不执行的问题
2019/10/22 PHP
js隐藏与显示回到顶部按钮及window.onscroll事件应用
2013/01/25 Javascript
JavaScript中setAttribute用法介绍
2013/07/20 Javascript
jquery.post用法示例代码
2014/01/03 Javascript
js中opener与parent的区别详细解析
2014/01/14 Javascript
Jquery easyUI 更新行示例
2014/03/06 Javascript
JS实现局部选择打印和局部不选择打印
2014/04/03 Javascript
$.each遍历对象、数组的属性值并进行处理
2014/07/18 Javascript
js实现鼠标感应向下滑动隐藏菜单的方法
2015/02/20 Javascript
jQuery制作可自定义大小的拼图游戏
2015/03/30 Javascript
javascript实现根据时间段显示问候语的方法
2015/06/18 Javascript
JS实现的样式切换功能tableCSS实例
2016/12/30 Javascript
JavaScript实现简单的四则运算计算器完整实例
2017/04/28 Javascript
js,jq,css多方面实现简易下拉菜单功能
2017/05/13 Javascript
Vue 项目部署到服务器的问题解决方法
2017/12/05 Javascript
Python操作MongoDB详解及实例
2017/05/18 Python
Python实现将SQLite中的数据直接输出为CVS的方法示例
2017/07/13 Python
简单谈谈python中的lambda表达式
2018/01/19 Python
python实现汽车管理系统
2018/11/30 Python
深入理解Django-Signals信号量
2019/02/19 Python
使用Python实现将list中的每一项的首字母大写
2019/06/11 Python
Python流程控制 while循环实现解析
2019/09/02 Python
Python如何执行精确的浮点数运算
2020/07/31 Python
pandas按照列的值排序(某一列或者多列)
2020/12/13 Python
夜大自我鉴定
2013/10/31 职场文书
文明家庭先进事迹材
2014/01/27 职场文书
2014年体育部工作总结
2014/11/13 职场文书
高考升学宴答谢词
2015/01/20 职场文书
2015年文员个人工作总结
2015/04/09 职场文书
MySQL大小写敏感的注意事项
2021/05/24 MySQL
win11如何查看端口是否被占用? Win11查看端口是否占用的技巧
2022/04/05 数码科技
python数字图像处理实现图像的形变与缩放
2022/06/28 Python