[WIP] feat(generic): add functions is_left_handed and flip_holistic#95
Open
J22Melody wants to merge 1 commit intosign-language-processing:masterfrom
Open
[WIP] feat(generic): add functions is_left_handed and flip_holistic#95J22Melody wants to merge 1 commit intosign-language-processing:masterfrom
J22Melody wants to merge 1 commit intosign-language-processing:masterfrom
Conversation
AmitMY
requested changes
Jun 12, 2024
|
|
||
| def flip_holistic(pose: Pose) -> Pose: | ||
| FLIPPED_COMPONENTS = ["POSE_LANDMARKS", "FACE_LANDMARKS", "RIGHT_HAND_LANDMARKS", "LEFT_HAND_LANDMARKS"] | ||
| FLIPPED_BODY_POINTS = ['NOSE', 'RIGHT_EYE_INNER', 'RIGHT_EYE', 'RIGHT_EYE_OUTER', 'LEFT_EYE_INNER', 'LEFT_EYE', 'LEFT_EYE_OUTER', 'RIGHT_EAR', 'LEFT_EAR', 'MOUTH_RIGHT', 'MOUTH_LEFT', 'RIGHT_SHOULDER', 'LEFT_SHOULDER', 'RIGHT_ELBOW', 'LEFT_ELBOW', 'RIGHT_WRIST', 'LEFT_WRIST', 'RIGHT_PINKY', 'LEFT_PINKY', 'RIGHT_INDEX', 'LEFT_INDEX', 'RIGHT_THUMB', 'LEFT_THUMB', 'RIGHT_HIP', 'LEFT_HIP', 'RIGHT_KNEE', 'LEFT_KNEE', 'RIGHT_ANKLE', 'LEFT_ANKLE', 'RIGHT_HEEL', 'LEFT_HEEL', 'RIGHT_FOOT_INDEX', 'LEFT_FOOT_INDEX'] |
Collaborator
There was a problem hiding this comment.
|
|
||
|
|
||
| def flip_holistic(pose: Pose) -> Pose: | ||
| FLIPPED_COMPONENTS = ["POSE_LANDMARKS", "FACE_LANDMARKS", "RIGHT_HAND_LANDMARKS", "LEFT_HAND_LANDMARKS"] |
Collaborator
There was a problem hiding this comment.
to be even more generic (assume we don't know the original component ordering):
pose_components = [c.name for c in pose. header.components]
# Swap LEFT and RIGHT
flipped_components = [
c.replace("LEFT", "TEMP").replace("RIGHT", "LEFT").replace("TEMP", "RIGHT")
for c in pose_components
]| # CAUTION: works on reduced set of face keypoints (face_contours) only | ||
| FLIPPED_FACE_POINTS = ['0', '249', '10', '13', '14', '17', '251', '263', '267', '269', '270', '276', '282', '283', '284', '285', '288', '291', '293', '295', '296', '297', '300', '308', '310', '311', '312', '314', '317', '318', '321', '323', '324', '332', '334', '336', '338', '356', '361', '362', '365', '373', '374', '375', '377', '378', '379', '152', '380', '381', '382', '384', '385', '386', '387', '388', '389', '390', '397', '398', '400', '402', '405', '409', '415', '454', '466', \ | ||
| '7', '21', '33', '37', '39', '40', '46', '52', '53', '54', '55', '58', '61', '63', '65', '66', '67', '70', '78', '80', '81', '82', '84', '87', '88', '91', '93', '95', '103', '105', '107', '109', '127', '132', '133', '136', '144', '145', '146', '148', '149', '150', '153', '154', '155', '157', '158', '159', '160', '161', '162', '163', '172', '173', '176', '178', '181', '185', '191', '234', '246'] | ||
| body = [p for p in FLIPPED_BODY_POINTS if p in pose.header.components[0].points] |
Collaborator
There was a problem hiding this comment.
same here, first create a component
body_component = next(c for c in pose.header.components if c == "POSE_LANDMARKS")
body = [p for p in FLIPPED_BODY_POINTS if p in body_component.points](same for the face)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.