(img, center_coordinate, heatmap_template, side, width, height)
| 33 | |
| 34 | |
| 35 | def draw_heatmap(img, center_coordinate, heatmap_template, side, width, height): |
| 36 | x1 = max(center_coordinate[0] - side, 1) |
| 37 | x2 = min(center_coordinate[0] + side, width - 1) |
| 38 | y1 = max(center_coordinate[1] - side, 1) |
| 39 | y2 = min(center_coordinate[1] + side, height - 1) |
| 40 | x1, x2, y1, y2 = int(x1), int(x2), int(y1), int(y2) |
| 41 | |
| 42 | if (x2 - x1) < 1 or (y2 - y1) < 1: |
| 43 | print(center_coordinate, "x1, x2, y1, y2", x1, x2, y1, y2) |
| 44 | return img |
| 45 | |
| 46 | need_map = cv2.resize(heatmap_template, (x2-x1, y2-y1)) |
| 47 | |
| 48 | img[y1:y2,x1:x2] = need_map |
| 49 | |
| 50 | return img |
| 51 | |
| 52 | |
| 53 | def generate_gassian_heatmap(pred_tracks, pred_visibility=None, image_size=None, side=20): |
no outgoing calls
no test coverage detected