| 59 | return canvas |
| 60 | |
| 61 | def draw_handpose(canvas, all_hand_peaks, all_hand_scores): |
| 62 | H, W, C = canvas.shape |
| 63 | |
| 64 | edges = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 5], [5, 6], [6, 7], [7, 8], [0, 9], [9, 10], \ |
| 65 | [10, 11], [11, 12], [0, 13], [13, 14], [14, 15], [15, 16], [0, 17], [17, 18], [18, 19], [19, 20]] |
| 66 | |
| 67 | for peaks, scores in zip(all_hand_peaks, all_hand_scores): |
| 68 | |
| 69 | for ie, e in enumerate(edges): |
| 70 | x1, y1 = peaks[e[0]] |
| 71 | x2, y2 = peaks[e[1]] |
| 72 | x1 = int(x1 * W) |
| 73 | y1 = int(y1 * H) |
| 74 | x2 = int(x2 * W) |
| 75 | y2 = int(y2 * H) |
| 76 | score = int(scores[e[0]] * scores[e[1]] * 255) |
| 77 | if x1 > eps and y1 > eps and x2 > eps and y2 > eps: |
| 78 | cv2.line(canvas, (x1, y1), (x2, y2), |
| 79 | matplotlib.colors.hsv_to_rgb([ie / float(len(edges)), 1.0, 1.0]) * score, thickness=2) |
| 80 | |
| 81 | for i, keyponit in enumerate(peaks): |
| 82 | x, y = keyponit |
| 83 | x = int(x * W) |
| 84 | y = int(y * H) |
| 85 | score = int(scores[i] * 255) |
| 86 | if x > eps and y > eps: |
| 87 | cv2.circle(canvas, (x, y), 4, (0, 0, score), thickness=-1) |
| 88 | return canvas |
| 89 | |
| 90 | def draw_facepose(canvas, all_lmks, all_scores): |
| 91 | H, W, C = canvas.shape |