| 27 | |
| 28 | |
| 29 | def show2Dpose(kps, img): |
| 30 | colors = [(255, 128, 255), |
| 31 | (255, 127, 127), |
| 32 | (127, 127, 255)] |
| 33 | |
| 34 | connections = [[0, 1], [1, 2], [2, 3], [0, 4], [4, 5], |
| 35 | [5, 6], [0, 7], [7, 8], [8, 9], [9, 10], |
| 36 | [8, 11], [11, 12], [12, 13], [8, 14], [14, 15], [15, 16]] |
| 37 | |
| 38 | LR = [3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2] |
| 39 | |
| 40 | thickness = 3 |
| 41 | |
| 42 | for j,c in enumerate(connections): |
| 43 | start = map(int, kps[c[0]]) |
| 44 | end = map(int, kps[c[1]]) |
| 45 | start = list(start) |
| 46 | end = list(end) |
| 47 | cv2.line(img, (start[0], start[1]), (end[0], end[1]), colors[LR[j]-1], thickness) |
| 48 | cv2.circle(img, (start[0], start[1]), thickness=-1, color=colors[LR[j]-1], radius=3) |
| 49 | cv2.circle(img, (end[0], end[1]), thickness=-1, color=colors[LR[j]-1], radius=3) |
| 50 | |
| 51 | return img |
| 52 | |
| 53 | |
| 54 | def show3Dpose(vals, ax, fix_z): |