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

作者:三行代码划江湖 时间:2023-08-10 22:11:40 

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函数,希望对大家有所帮助

来源:https://www.cnblogs.com/mld-code-life/p/11197736.html

标签:opencv,circle,ellipse,函数
0
投稿

猜你喜欢

  • Dreamweaver MX 2004 制作树状菜单教程[动画]

    2010-03-25 12:24:00
  • Go语言defer语句的三种机制整理

    2024-05-02 16:25:25
  • javascript定义变量时带var与不带var的区别分析

    2023-08-23 12:39:21
  • Python的内置数据类型中的数字

    2023-12-29 19:36:37
  • element-ui中表格设置正确的排序及设置默认排序

    2024-05-09 15:25:48
  • 分享一道笔试题[有n个直线最多可以把一个平面分成多少个部分]

    2024-04-25 13:09:11
  • dl.dt.dd.ul.li.ol区别及应用

    2008-05-24 09:42:00
  • sqlserver 中时间为空的处理小结

    2024-01-13 06:07:40
  • python字典遍历数据的具体做法

    2022-04-19 16:45:33
  • Python一行代码快速实现程序进度条示例

    2022-07-07 07:22:26
  • 对python的文件内注释 help注释方法

    2021-12-20 18:12:46
  • Pytest框架之fixture详解(三)

    2023-06-20 12:05:27
  • Python轻松破解加密压缩包教程详解

    2021-04-12 13:26:45
  • Opencv+Python实现图像运动模糊和高斯模糊的示例

    2022-08-06 12:25:19
  • 使用 GUID 值来作为数据库行标识讲解

    2024-01-24 01:10:24
  • Python HTML解析模块HTMLParser用法分析【爬虫工具】

    2023-10-04 02:07:09
  • MySQL 8.0.29 安装配置方法图文教程(windows zip版)

    2024-01-17 17:06:44
  • Go简单实现协程池的实现示例

    2024-02-19 07:35:16
  • python实现基于SVM手写数字识别功能

    2021-10-03 12:33:41
  • Sqlserver 2005使用XML一次更新多条记录的方法

    2024-01-28 19:50:04
  • asp之家 网络编程 m.aspxhome.com