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,
)
| 409 | |
| 410 | |
| 411 | def draw_nose( |
| 412 | img, |
| 413 | kp2ds, |
| 414 | threshold=0.6, |
| 415 | data_to_json=None, |
| 416 | idx=-1, |
| 417 | kp2ds_lhand=None, |
| 418 | kp2ds_rhand=None, |
| 419 | draw_hand=False, |
| 420 | stick_width_norm=200, |
| 421 | ): |
| 422 | """ |
| 423 | Draw keypoints and connections representing hand pose on a given canvas. |
| 424 | |
| 425 | Args: |
| 426 | canvas (np.ndarray): A 3D numpy array representing the canvas (image) on which to draw the hand pose. |
| 427 | keypoints (List[Keypoint]| None): A list of Keypoint objects representing the hand keypoints to be drawn |
| 428 | or None if no keypoints are present. |
| 429 | |
| 430 | Returns: |
| 431 | np.ndarray: A 3D numpy array representing the modified canvas with the drawn hand pose. |
| 432 | |
| 433 | Note: |
| 434 | The function expects the x and y coordinates of the keypoints to be normalized between 0 and 1. |
| 435 | """ |
| 436 | |
| 437 | new_kep_list = [ |
| 438 | "Nose", |
| 439 | "Neck", |
| 440 | "RShoulder", |
| 441 | "RElbow", |
| 442 | "RWrist", # No.4 |
| 443 | "LShoulder", |
| 444 | "LElbow", |
| 445 | "LWrist", # No.7 |
| 446 | "RHip", |
| 447 | "RKnee", |
| 448 | "RAnkle", # No.10 |
| 449 | "LHip", |
| 450 | "LKnee", |
| 451 | "LAnkle", # No.13 |
| 452 | "REye", |
| 453 | "LEye", |
| 454 | "REar", |
| 455 | "LEar", |
| 456 | "LToe", |
| 457 | "RToe", |
| 458 | ] |
| 459 | # kp2ds_body = (kp2ds.copy()[[0, 6, 6, 8, 10, 5, 7, 9, 12, 14, 16, 11, 13, 15, 2, 1, 4, 3, 17, 20]] + \ |
| 460 | # kp2ds.copy()[[0, 5, 6, 8, 10, 5, 7, 9, 12, 14, 16, 11, 13, 15, 2, 1, 4, 3, 18, 21]]) / 2 |
| 461 | kp2ds = kp2ds.copy() |
| 462 | kp2ds[1:, 2] = 0 |
| 463 | # kp2ds[0, 2] = 1 |
| 464 | kp2ds_body = kp2ds |
| 465 | # kp2ds_body = kp2ds_body[:18] |
| 466 | |
| 467 | # kp2ds_lhand = kp2ds.copy()[91:112] |
| 468 | # kp2ds_rhand = kp2ds.copy()[112:133] |
no test coverage detected