详解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 学习笔记
Dec 27 Python
python方向键控制上下左右代码
Jan 20 Python
简单实现python画圆功能
Jan 25 Python
利用python实现在微信群刷屏的方法
Feb 21 Python
Django的models中on_delete参数详解
Jul 16 Python
flask框架路由常用定义方式总结
Jul 23 Python
Python MySQL 日期时间格式化作为参数的操作
Mar 02 Python
Python自动登录QQ的实现示例
Aug 28 Python
python3排序的实例方法
Oct 20 Python
详解python中的三种命令行模块(sys.argv,argparse,click)
Dec 15 Python
解决pytorch 的state_dict()拷贝问题
Mar 03 Python
Python 绘制多因子柱状图
May 11 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
ThinkPHP CURD方法之page方法详解
2014/06/18 PHP
PHP执行SQL文件并将SQL文件导入到数据库
2015/09/17 PHP
php使用glob函数遍历文件和目录详解
2016/09/23 PHP
PHP链表操作简单示例
2016/10/15 PHP
IE 下Enter提交表单存在重复提交问题的解决方法
2014/05/04 Javascript
nodejs命令行参数处理模块commander使用实例
2014/09/17 NodeJs
JavaScript indexOf方法入门实例(计算指定字符在字符串中首次出现的位置)
2014/10/17 Javascript
jQuery学习笔记之2个小技巧
2015/01/19 Javascript
javascript判断移动端访问设备并解析对应CSS的方法
2015/02/05 Javascript
angularjs学习笔记之简单介绍
2015/09/26 Javascript
页面内容排序插件jSort使用方法
2015/10/10 Javascript
Angular实现图片裁剪工具ngImgCrop实践
2017/08/17 Javascript
JS 实现微信扫一扫功能
2018/09/14 Javascript
Vue.js实现tab切换效果
2019/07/24 Javascript
在vue中给后台接口传的值为数组的格式代码
2020/11/12 Javascript
[45:52]完美世界DOTA2联赛PWL S3 Forest vs INK ICE 第二场 12.09
2020/12/12 DOTA
python pickle 和 shelve模块的用法
2013/09/16 Python
Python BeautifulSoup中文乱码问题的2种解决方法
2014/04/22 Python
浅谈python 线程池threadpool之实现
2017/11/17 Python
解决Python requests库编码 socks5代理的问题
2018/05/07 Python
pandas 把数据写入txt文件每行固定写入一定数量的值方法
2018/12/28 Python
numpy库与pandas库axis=0,axis= 1轴的用法详解
2019/05/27 Python
python使用writerows写csv文件产生多余空行的处理方法
2019/08/01 Python
python连接、操作mongodb数据库的方法实例详解
2019/09/11 Python
Pytorch之Variable的用法
2019/12/31 Python
python3正则模块re的使用方法详解
2020/02/11 Python
python新式类和经典类的区别实例分析
2020/03/23 Python
Python解析微信dat文件的方法
2020/11/30 Python
高一历史教学反思
2014/01/13 职场文书
政府法律服务方案
2014/06/14 职场文书
战略性融资合作协议书范本
2014/10/17 职场文书
教师个人师德工作总结2015
2015/05/12 职场文书
2015社区个人工作总结范文
2015/05/13 职场文书
XX部保密工作制度范本
2019/08/27 职场文书
MongoDB使用profile分析慢查询的步骤
2021/04/30 MongoDB
Python Pandas 删除列操作
2022/03/16 Python