Minor fix

This commit is contained in:
AlexeyAB 2020-05-20 19:51:06 +03:00
parent 03eee3092f
commit 4098e4882c
2 changed files with 22 additions and 1 deletions

View File

@ -155,6 +155,25 @@ void draw_label(image a, int r, int c, image label, const float *rgb)
} }
} }
void draw_weighted_label(image a, int r, int c, image label, const float *rgb, const float alpha)
{
int w = label.w;
int h = label.h;
if (r - h >= 0) r = r - h;
int i, j, k;
for (j = 0; j < h && j + r < a.h; ++j) {
for (i = 0; i < w && i + c < a.w; ++i) {
for (k = 0; k < label.c; ++k) {
float val1 = get_pixel(label, i, j, k);
float val2 = get_pixel(a, i + c, j + r, k);
float val_dst = val1 * rgb[k] * alpha + val2 * (1 - alpha);
set_pixel(a, i + c, j + r, k, val_dst);
}
}
}
}
void draw_box_bw(image a, int x1, int y1, int x2, int y2, float brightness) void draw_box_bw(image a, int x1, int y1, int x2, int y2, float brightness)
{ {
//normalize_image(a); //normalize_image(a);
@ -423,7 +442,8 @@ void draw_detections_v3(image im, detection *dets, int num, float thresh, char *
} }
} }
image label = get_label_v3(alphabet, labelstr, (im.h*.02)); image label = get_label_v3(alphabet, labelstr, (im.h*.02));
draw_label(im, top + width, left, label, rgb); //draw_label(im, top + width, left, label, rgb);
draw_weighted_label(im, top + width, left, label, rgb, 0.7);
free_image(label); free_image(label);
} }
if (selected_detections[i].det.mask) { if (selected_detections[i].det.mask) {

View File

@ -28,6 +28,7 @@ void draw_box(image a, int x1, int y1, int x2, int y2, float r, float g, float b
void draw_box_width(image a, int x1, int y1, int x2, int y2, int w, float r, float g, float b); void draw_box_width(image a, int x1, int y1, int x2, int y2, int w, float r, float g, float b);
void draw_bbox(image a, box bbox, int w, float r, float g, float b); void draw_bbox(image a, box bbox, int w, float r, float g, float b);
void draw_label(image a, int r, int c, image label, const float *rgb); void draw_label(image a, int r, int c, image label, const float *rgb);
void draw_weighted_label(image a, int r, int c, image label, const float *rgb, const float alpha);
void write_label(image a, int r, int c, image *characters, char *string, float *rgb); void write_label(image a, int r, int c, image *characters, char *string, float *rgb);
void draw_detections(image im, int num, float thresh, box *boxes, float **probs, char **names, image **labels, int classes); void draw_detections(image im, int num, float thresh, box *boxes, float **probs, char **names, image **labels, int classes);
void draw_detections_v3(image im, detection *dets, int num, float thresh, char **names, image **alphabet, int classes, int ext_output); void draw_detections_v3(image im, detection *dets, int num, float thresh, char **names, image **alphabet, int classes, int ext_output);