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;
}

运行结果

在这里插入图片描述

  • 6
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值