Opencv繪製曲線,並新增標註

2021-09-14 00:10:48 字數 2634 閱讀 9965

#include "draw.h"

#include "stdio.h"

using namespace cv;

void draw_route(const double(*c)[2], int *shortest_route)

for (int i = 0; i < 30; i++) //畫線

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; //給新增標註

src = &iplimage(img);

cvfont font, font1;

double hscale = 0.9;

double vscale = 0.9;

int linewidth = 1;

cvinitfont(&font, cv_font_hershey_******x | cv_font_italic, hscale, vscale, 0, linewidth);

cvinitfont(&font1, cv_font_hershey_******x | cv_font_italic, hscale - 0.4, vscale - 0.4, 0, linewidth);

cvputtext(src, "the shortest route", cvpoint(150, 25), &font, cv_rgb(0, 0, 0));

for (int i = 0; i < 31; i++) //新增城市名字

namedwindow("the shortest route", cv_window_normal); //使視窗可以調節大小

imshow("the shortest route", img);

waitkey(0);

}void draw_lbest(const int nc_max, double *l_best)

iplimage *src; //給新增標註

src = &iplimage(img);

cvfont font, font1;

double hscale = 0.9;

double vscale = 0.9;

int linewidth = 1;

cvinitfont(&font, cv_font_hershey_******x | cv_font_italic, hscale, vscale, 0, linewidth);

cvinitfont(&font1, cv_font_hershey_******x | cv_font_italic, hscale - 0.3, vscale - 0.3, 0, linewidth);

cvputtext(src, "length of the route", cvpoint(150, 25), &font, cv_rgb(0, 0, 0));

cvputtext(src, "length", cvpoint(30, 60), &font1, cv_rgb(0, 0, 255));

cvputtext(src, "iterations", cvpoint(400, 520), &font1, cv_rgb(0, 0, 255));

namedwindow("length of the route", cv_window_normal); //使視窗可以調節大小

imshow("length of the route", img);

waitkey(0);}

void draw_lbest_aco(const int nc_max, double *l_best)

iplimage *src; //給新增標註

src = &iplimage(img);

cvfont font, font1;

double hscale = 0.9;

double vscale = 0.9;

int linewidth = 1;

cvinitfont(&font, cv_font_hershey_******x | cv_font_italic, hscale, vscale, 0, linewidth);

cvinitfont(&font1, cv_font_hershey_******x | cv_font_italic, hscale - 0.3, vscale - 0.3, 0, linewidth);

cvputtext(src, "profit", cvpoint(30, 60), &font1, cv_rgb(0, 0, 255));

cvputtext(src, "iterations", cvpoint(400, 520), &font1, cv_rgb(0, 0, 255));

namedwindow("length of the route", cv_window_normal); //使視窗可以調節大小

imshow("length of the route", img);

waitkey(0);

}

OpenCV學習 繪製貝賽爾曲線

出處 trainingtools.cpp 定義控制台應用程式的入口點。include stdafx.h include include include include include include using namespace std const int ww max mark count 40...

OpenCV之查詢並繪製輪廓

在opencv中,用findcontours 函式從二值圖中查詢輪廓。原型 void findcontourd inputarray image,outputarray contours,outputarray hierarchy,int mode,int mrthod,point offset p...

matlab繪製曲面並標註座標軸

首先看公式 r 的取值為 0,1 且取值的間隔為0.01 z 的取值為 0,1 且取值的間隔為0.01 看matlab的m檔案 r 0 0.01 1 z 0 0.01 1 meshgrid r,z 以矩陣的形勢進行運算出nn的值。for row 1 1 101 for col 1 1 101 nn ...