- 操作系统: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;
}
 
运行结果




















