OpenCV官方文档 circle()
void circle(
InputOutputArray img, //在此图像上画圆
Point center, //圆心
int radius,//半径
const Scalar& color, //画笔颜色
int thickness = 1,//线宽
int lineType = LINE_8, //边缘类型
int shift = 0 //中心坐标和半径的缩小倍数
);
#include "stdafx.h"
#include
#include
using namespace cv;
using namespace std;
int main()
{
Mat img = imread("画板.bmp");
//画圆
circle(img, Point(200, 200), 100, Scalar(255, 0, 0), 1, 8, 0);
line(img, Point(200, 200), Point(300, 200), Scalar(0, 0, 255));
circle(img, Point(200, 200), 100, Scalar(255, 0, 0), 1, 8, 1);
line(img, Point(100, 100), Point(150, 100), Scalar(0, 0, 2552));
circle(img, Point(200, 200), 100, Scalar(255, 0, 0), 1, 8, 2);
line(img, Point(50, 50), Point(75, 50), Scalar(0, 0, 255));
imshow("画板", img);
waitKey(0);
return 0;
}
OpenCV官方文档 ellipse()
void ellipse(
InputOutputArray img,
const RotatedRect& box,
const Scalar& color,
int thickness = 1,
int lineType = LINE_8
);
RotatedRect::RotatedRect(
const Point2f& _center,
const Size2f& _size,
float _angle
)
void ellipse(
InputOutputArray img,
Point center, //椭圆中心坐标
Size axes,//长轴和短轴
double angle,
double startAngle,
double endAngle,
const Scalar& color,
int thickness = 1,
int lineType = LINE_8,
int shift = 0
);
#include "stdafx.h"
#include
#include
using namespace cv;
using namespace std;
int main()
{
Mat img = imread("画板.bmp");
//画圆
circle(img, Point(200, 200), 100, Scalar(255, 0, 0), 1, 8, 0);
circle(img, Point(200, 200), 100, Scalar(255, 0, 0), 1, 8, 1);
circle(img, Point(200, 200), 100, Scalar(255, 0, 0), 1, 8, 2);
//画椭圆(第一种方法)
ellipse(img, RotatedRect(Point2f(350, 350), Size2f(100, 200), 90), Scalar(0, 0, 0), 1, 8);
//画椭圆(第二种方法)
ellipse(img, Point(350, 350), Size(50, 100), 0, 0, 360, Scalar(0, 0, 255), 1, 8, 0);
ellipse(img, Point(350, 350), Size(50, 100), 45, 0, 360, Scalar(255, 0, 255), 1, 8, 0);
ellipse(img, Point(350, 350), Size(50, 100), 135, 0, 360, Scalar(0, 255, 255), 1, 8, 0);
imshow("画板", img);
waitKey(0);
return 0;
}