首先贴一个最简单的程序:访问:https://blog.youkuaiyun.com/guduruyu/article/details/70069426
//创建一个用于绘制图像的空白图
cv::Mat image = cv::Mat::ones(480, 640, CV_8UC3);
//设置蓝色背景
image.setTo(cv::Scalar(100, 0, 0));
//输入拟合点
std::vector<cv::Point> points;
points.push_back(cv::Point(200, 240));
points.push_back(cv::Point(300, 400));
points.push_back(cv::Point(400, 360));
points.push_back(cv::Point(500, 300));
points.push_back(cv::Point(500, 200));
points.push_back(cv::Point(300, 150));
//将拟合点绘制到空白图上
for (int i = 0; i < points.size(); i++)
{
cv::circle(image, points[i], 5, cv::Scalar(0, 0, 255), 2, 8, 0);
}
//获取拟合椭圆的外包围矩形
cv::RotatedRect rotate_rect = cv::fitEllipse(points);
//绘制拟合椭圆
cv::ellipse(image, rotate_rect, cv::Scalar(0, 255, 255), 2, 8);
cv::imshow("image", image);
cv::waitKey(0);
其次<