Skip to content

Commit

Permalink
Minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyAB committed May 20, 2020
1 parent 03eee30 commit 4098e48
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
//normalize_image(a);
Expand Down Expand Up @@ -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));
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);
}
if (selected_detections[i].det.mask) {
Expand Down
1 change: 1 addition & 0 deletions src/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_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_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 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);
Expand Down

0 comments on commit 4098e48

Please sign in to comment.