OpenCV - C++ - cv::circle

OpenCV - C++ - cv::circle

https://docs.opencv.org/4.2.0/d6/d6e/group__imgproc__draw.html

1. cv::circle

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

Python
img = cv.circle(img, center, radius, color[, thickness[, lineType[, shift]]])

#include

Draws a circle.
画一个圆。

The function cv::circle draws a simple or filled circle with a given center and radius.
函数 cv::circle 绘制具有给定中心和半径的空心或实心圆。

2. Parameters

img - Image where the circle is drawn.
center - Center of the circle cv::Point (x, y).
radius - Radius of the circle.
color - Circle color cv::Scalar (B, G, R).
thickness - Thickness of the circle outline, if positive. Negative values, like FILLED, mean that a filled circle is to be drawn. (圆形轮廓的粗细 (如果为正)。负值 (如 FILLED) 表示要绘制实心圆。)
lineType - Type of the circle boundary. See LineTypes (圆边界的类型。)
shift - Number of fractional bits in the coordinates of the center and in the radius value. (中心坐标和半径值中的小数位数。)

3. Example

//============================================================================
// Name        : cv::circle
// Author      : Yongqiang Cheng
// Version     : Feb 22, 2020
// Copyright   : Copyright (c) 2019 Yongqiang Cheng
// Description : Hello World in C++, Ansi-style
//============================================================================

#include 
#include 
#include 
#include 

int main(int argc, char** argv)
{
	// First create a black image.
	cv::Mat image(500, 500, CV_8UC3, cv::Scalar(0, 0, 0));

	// Check if the image is created successfully.
	if (!image.data)
	{
		std::cout << "Could not open or find the image" << std::endl;
		exit(EXIT_FAILURE);
	}

	// unfilled circle - draws a circle.
	cv::Point centerCircle1(250, 250);
	int radiusCircle = 30;
	cv::Scalar colorCircle1(0, 0, 255); // (B, G, R)
	int thicknessCircle1 = 2;

	cv::circle(image, centerCircle1, radiusCircle, colorCircle1, thicknessCircle1);

	// filled circle - draws a circle.
	cv::Point centerCircle2(400, 100);
	cv::Scalar colorCircle2(0, 255, 0); // (B, G, R)

	// FILLED = -1
	cv::circle(image, centerCircle2, radiusCircle, colorCircle2, cv::FILLED);

	cv::namedWindow("Display window", cv::WINDOW_AUTOSIZE);
	cv::imshow("Display window", image);

	cv::waitKey(0);

	return 0;
}

OpenCV - C++ - cv::circle_第1张图片

你可能感兴趣的:(OpenCV,2,-,OpenCV,3,-,OpenCV,4)