#include "draw.h"
#include "stdio.h"
using namespace cv;
void draw_route(const double(*C)[2], int *Shortest_Route)
{
Size size(560, 560);
Mat img = Mat::zeros(size, CV_8UC3);
img += Scalar(255, 255, 255);
rectangle(img, Rect(30, 30, 500, 500), Scalar(0, 255, 0));
for (int i = 0; i < 31; i++) //画点
{
Point p((C[i][0] / 10), (C[i][1] / 10));
circle(img, p, 3, Scalar(255, 0, 0));
}
for (int i = 0; i < 30; i++) //画线
{
Point p1((C[*(Shortest_Route + i)][0] / 10), (C[*(Shortest_Route + i)][1] / 10));
Point p2((C[*(Shortest_Route + i + 1)][0] / 10), (C[*(Shortest_Route + i + 1)][1] / 10));
line(img, p1, p2, Scalar(255, 0, 255));
}
Point p1((C[*(Shortest_Route)][0] / 10), (C[*(Shortest_Route)][1] / 10));
Point p2((C[*(Shortest_Route + 30)][0] / 10), (C[*(Shortest_Route + 30)][1] / 10));
line(img, p1, p2, Scalar(255, 0, 255));
IplImage *src; //给图片添加标注
s
Opencv绘制曲线,并添加标注
最新推荐文章于 2024-05-04 17:21:20 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)