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

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 imagecv::Mat image = cv::Mat::zeros( 512, 512, CV_8UC3 );// Define the center of the circlecv::Point center( 256, 256 );  // Center coordinates// Define the radius of the circleint radius = 100;  // Radius in pixels// Define the color of the circlecv::Scalar color( 0, 255, 0 );  // Green color// Define the thickness of the circleint thickness = 2;  // Positive value for outline// Define the line typeint line_type = cv::LINE_AA;  // Anti-aliased line// Define the shift valueint shift = 0;  // No fractional bits// Draw the circlecv::circle( image, center, radius, color, thickness, line_type, shift );// Display the imagecv::imshow( "Circle Example", image );cv::waitKey( 0 );return 0;
}

运行结果

在这里插入图片描述


http://www.mrgr.cn/news/11006.html

相关文章:

  • 用Python插入SVG到PDF文档
  • 数学建模学习(118):牛顿冷却定律的原理解析、案例分析与Python求解
  • 【HuggingFace Transformers】BertIntermediate 和 BertPooler源码解析
  • 沈阳网站建设手机能看的网站
  • 0基础学习Python路径(29)collections模块
  • ubuntu系统在线安装下载firefox-esr流览器
  • WIN11环境下,如何在指定目录快速启动jupyter lab或jupyter notebook
  • MongoDB适用场景
  • 空气净化器怎么选能除猫毛?宠物空气净化器除味好的分享
  • GLM-4-Flash 大模型API免费了,手把手构建“儿童绘本”应用实战(附源码)
  • redis面试(二十三)写锁释放
  • 国产游戏技术的崛起:能否挑战全球引领地位?
  • 【单调栈】|代码随想录算法训练营第42天|42. 接雨水、 84.柱状图中最大的矩形
  • 王立铭脑科学50讲:29,敌对型社交,如何抑制自己的共攻击本能
  • 【搜索引擎】ElasticSearch 7.x版本
  • android aar适配uniapp
  • IDEA工具设置默认使用maven的settings.xml文件
  • 游戏开发设计模式之装饰模式
  • 汽车耐老化太阳跟踪聚光户外加速老化试验
  • 可集成多模型的机器人开发框架 dora:让机器人编程走向大众