当前位置: 首页 > article >正文

OpenCV绘图函数(2)绘制圆形函数circle()的使用

  • 操作系统:ubuntu22.04
  • OpenCV版本:OpenCV4.9
  • IDE:Visual Studio Code
  • 编程语言:C++11

算法描述

绘制一个圆。
cv::circle 函数用于绘制一个给定中心和半径的简单圆或填充圆。

函数原型

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

参数

  • 参数img 绘制圆的图像。
  • 参数center 圆的中心点。
  • 参数radius 圆的半径。
  • 参数color 圆的颜色。
  • 参数thickness 如果为正数,则代表圆轮廓的厚度;如果是负数(如FILLED),则表示绘制填充的圆。
  • 参数lineType 圆边界的类型。参见LineTypes。
  • 参数shift 中心坐标和半径值中的小数位数。

代码示例

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>

int main()
{
    // Create a blank image
    cv::Mat image = cv::Mat::zeros( 512, 512, CV_8UC3 );

    // Define the center of the circle
    cv::Point center( 256, 256 );  // Center coordinates

    // Define the radius of the circle
    int radius = 100;  // Radius in pixels

    // Define the color of the circle
    cv::Scalar color( 0, 255, 0 );  // Green color

    // Define the thickness of the circle
    int thickness = 2;  // Positive value for outline

    // Define the line type
    int line_type = cv::LINE_AA;  // Anti-aliased line

    // Define the shift value
    int shift = 0;  // No fractional bits

    // Draw the circle
    cv::circle( image, center, radius, color, thickness, line_type, shift );

    // Display the image
    cv::imshow( "Circle Example", image );
    cv::waitKey( 0 );

    return 0;
}

运行结果

在这里插入图片描述


http://www.kler.cn/a/280155.html

相关文章:

  • Godot《躲避小兵》实战之游戏开始界面制作
  • 关于crontab使用
  • C++细节整理
  • Element-UI自学实践(二)
  • Ai+若依(页面调整--去除若依的各种痕迹,采用自己的):【07篇】
  • java框架第一课(mybatis认识)
  • 浅谈FlashAttention优化原理
  • EazyDraw for Mac 矢量图绘制设计软件
  • 【机器学习】6. 线性回归、损失计算、最小二乘法、岭回归
  • 打渔的寓言--汽车软件开发技术进化史
  • 还在拼接字符串生成XML?(Java)
  • 力扣1590.使数组和能被P整除
  • ViewModel(8)单元测试
  • 华为od(D卷)路口最短时间问题
  • Android12 Toast连续多次点击后不显示
  • 【python】数据分析统计
  • 转-600条最强linux命令
  • js知识补充
  • oracle内存结构--PGA(进程全局区)私有的
  • PPT布局图片文本解析检测系统源码分享 # [一条龙教学YOLOV8标注好的数据集一键训练_70+全套改进创新点发刊_Web前端展示]