Draw keypoints and connections representing hand pose on a given canvas. Args: canvas (np.ndarray): A 3D numpy array representing the canvas (image) on which to draw the hand pose. keypoints (List[Keypoint]| None): A list of Keypoint objects representing the hand keypoints
(img, kp2ds, threshold=0.6, data_to_json=None, idx=-1, kp2ds_lhand=None, kp2ds_rhand=None, draw_hand=False, stick_width_norm=200, draw_head=True)
| 573 | |
| 574 | |
| 575 | def draw_aapose(img, kp2ds, threshold=0.6, data_to_json=None, idx=-1, kp2ds_lhand=None, kp2ds_rhand=None, draw_hand=False, stick_width_norm=200, draw_head=True): |
| 576 | """ |
| 577 | Draw keypoints and connections representing hand pose on a given canvas. |
| 578 | |
| 579 | Args: |
| 580 | canvas (np.ndarray): A 3D numpy array representing the canvas (image) on which to draw the hand pose. |
| 581 | keypoints (List[Keypoint]| None): A list of Keypoint objects representing the hand keypoints to be drawn |
| 582 | or None if no keypoints are present. |
| 583 | |
| 584 | Returns: |
| 585 | np.ndarray: A 3D numpy array representing the modified canvas with the drawn hand pose. |
| 586 | |
| 587 | Note: |
| 588 | The function expects the x and y coordinates of the keypoints to be normalized between 0 and 1. |
| 589 | """ |
| 590 | |
| 591 | new_kep_list = [ |
| 592 | "Nose", |
| 593 | "Neck", |
| 594 | "RShoulder", |
| 595 | "RElbow", |
| 596 | "RWrist", # No.4 |
| 597 | "LShoulder", |
| 598 | "LElbow", |
| 599 | "LWrist", # No.7 |
| 600 | "RHip", |
| 601 | "RKnee", |
| 602 | "RAnkle", # No.10 |
| 603 | "LHip", |
| 604 | "LKnee", |
| 605 | "LAnkle", # No.13 |
| 606 | "REye", |
| 607 | "LEye", |
| 608 | "REar", |
| 609 | "LEar", |
| 610 | "LToe", |
| 611 | "RToe", |
| 612 | ] |
| 613 | # kp2ds_body = (kp2ds.copy()[[0, 6, 6, 8, 10, 5, 7, 9, 12, 14, 16, 11, 13, 15, 2, 1, 4, 3, 17, 20]] + \ |
| 614 | # kp2ds.copy()[[0, 5, 6, 8, 10, 5, 7, 9, 12, 14, 16, 11, 13, 15, 2, 1, 4, 3, 18, 21]]) / 2 |
| 615 | kp2ds = kp2ds.copy() |
| 616 | if not draw_head: |
| 617 | kp2ds[[0, 14, 15, 16, 17], 2] = 0 |
| 618 | kp2ds_body = kp2ds |
| 619 | |
| 620 | # kp2ds_lhand = kp2ds.copy()[91:112] |
| 621 | # kp2ds_rhand = kp2ds.copy()[112:133] |
| 622 | |
| 623 | limbSeq = [ |
| 624 | [2, 3], |
| 625 | [2, 6], # shoulders |
| 626 | [3, 4], |
| 627 | [4, 5], # left arm |
| 628 | [6, 7], |
| 629 | [7, 8], # right arm |
| 630 | [2, 9], |
| 631 | [9, 10], |
| 632 | [10, 11], # right leg |
no test coverage detected