Draw 68 key points Args: image: the input image kpt: (68, 3).
(image, kpts, color = 'r')
| 662 | |
| 663 | end_list = np.array([17, 22, 27, 42, 48, 31, 36, 68], dtype = np.int32) - 1 |
| 664 | def plot_kpts(image, kpts, color = 'r'): |
| 665 | ''' Draw 68 key points |
| 666 | Args: |
| 667 | image: the input image |
| 668 | kpt: (68, 3). |
| 669 | ''' |
| 670 | kpts = kpts.copy().astype(np.int32) |
| 671 | if color == 'r': |
| 672 | c = (255, 0, 0) |
| 673 | elif color == 'g': |
| 674 | c = (0, 255, 0) |
| 675 | elif color == 'b': |
| 676 | c = (255, 0, 0) |
| 677 | image = image.copy() |
| 678 | kpts = kpts.copy() |
| 679 | |
| 680 | for i in range(kpts.shape[0]): |
| 681 | st = kpts[i, :2] |
| 682 | if kpts.shape[1]==4: |
| 683 | if kpts[i, 3] > 0.5: |
| 684 | c = (0, 255, 0) |
| 685 | else: |
| 686 | c = (0, 0, 255) |
| 687 | image = cv2.circle(image,(st[0], st[1]), 1, c, 2) |
| 688 | if i in end_list: |
| 689 | continue |
| 690 | ed = kpts[i + 1, :2] |
| 691 | image = cv2.line(image, (st[0], st[1]), (ed[0], ed[1]), (255, 255, 255), 1) |
| 692 | |
| 693 | return image |
| 694 | |
| 695 | def plot_verts(image, kpts, color = 'r'): |
| 696 | ''' Draw 68 key points |
no outgoing calls
no test coverage detected