(img, target)
| 13 | return imgarray |
| 14 | |
| 15 | def draw_rec_in_img(img, target): |
| 16 | tl = 3 # thickness line |
| 17 | tf = max(tl-1,1) # font thickness |
| 18 | color = [0,0,255] # color |
| 19 | tempimg = copy.deepcopy(img) |
| 20 | h, w = target['size'] |
| 21 | labels = target['labels'].cpu() |
| 22 | xyxyboxes = target['xyxyboxes'].cpu() |
| 23 | denorm_xyxyboxes = xyxyboxes * torch.tensor([w,h,w,h]) |
| 24 | for box,label in zip(denorm_xyxyboxes, labels): |
| 25 | c1, c2 = (int(box[0]), int(box[1])), (int(box[2]), int(box[3])) |
| 26 | cv2.rectangle(tempimg,c1,c2,color,thickness=tl, lineType=cv2.LINE_AA) |
| 27 | label = str(int(label)) |
| 28 | t_size = cv2.getTextSize(label, 0, fontScale=tl / 3, thickness=tf)[0] |
| 29 | c2 = c1[0] + t_size[0], c1[1] - t_size[1] - 3 |
| 30 | cv2.rectangle(tempimg, c1, c2, color, -1, cv2.LINE_AA) # filled |
| 31 | cv2.putText(tempimg, label, (c1[0], c1[1] - 2), 0, tl / 3, [225, 255, 255], thickness=tf, lineType=cv2.LINE_AA) |
| 32 | return tempimg |
| 33 | |
| 34 | def draw_patch_in_img(img, tgt_patch, inputs_size): |
| 35 | tl = 1 # thickness line |
nothing calls this directly
no outgoing calls
no test coverage detected