Hình tròn có tâm và bán kính. Để vẽ hình tròn bằng OpenCV, cần định nghĩa tâm và bán kính. Hàm circle() được định nghĩa trong header <imgproc.hpp>.
Cú pháp cơ bản
circle(whiteMatrix, center, radius, line_Color, thickness);
Ví dụ
#include <iostream>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace cv;
using namespace std;
int main() {
Mat whiteMatrix(200, 200, CV_8UC3, Scalar(255, 255, 255));
Point center(100, 100);
int radius = 50;
Scalar line_Color(0, 0, 0);
int thickness = 2;
namedWindow("whiteMatrix");
circle(whiteMatrix, center, radius, line_Color, thickness);
imshow("WhiteMatrix", whiteMatrix);
waitKey(0);
return 0;
}
Kết quả
