190 lines
5.9 KiB
Python
190 lines
5.9 KiB
Python
import json
|
|
|
|
# ==================================================================================================
|
|
|
|
|
|
def load_json(path: str):
|
|
with open(path, "r", encoding="utf-8") as file:
|
|
data = json.load(file)
|
|
return data
|
|
|
|
|
|
def save_json(data: dict, path: str):
|
|
with open(path, "w+", encoding="utf-8") as file:
|
|
json.dump(data, file, indent=0)
|
|
|
|
|
|
# ==================================================================================================
|
|
|
|
|
|
def use_whole_body(whole_body: dict) -> bool:
|
|
return any((whole_body[k] for k in whole_body))
|
|
|
|
|
|
# ==================================================================================================
|
|
|
|
|
|
def get_joint_names(whole_body: dict):
|
|
|
|
joint_names_2d = [
|
|
"nose",
|
|
"eye_left",
|
|
"eye_right",
|
|
"ear_left",
|
|
"ear_right",
|
|
"shoulder_left",
|
|
"shoulder_right",
|
|
"elbow_left",
|
|
"elbow_right",
|
|
"wrist_left",
|
|
"wrist_right",
|
|
"hip_left",
|
|
"hip_right",
|
|
"knee_left",
|
|
"knee_right",
|
|
"ankle_left",
|
|
"ankle_right",
|
|
]
|
|
|
|
if whole_body["foots"]:
|
|
joint_names_2d.extend(
|
|
[
|
|
"foot_toe_big_left",
|
|
"foot_toe_small_left",
|
|
"foot_heel_left",
|
|
"foot_toe_big_right",
|
|
"foot_toe_small_right",
|
|
"foot_heel_right",
|
|
]
|
|
)
|
|
if whole_body["face"]:
|
|
joint_names_2d.extend(
|
|
[
|
|
"face_jaw_right_1",
|
|
"face_jaw_right_2",
|
|
"face_jaw_right_3",
|
|
"face_jaw_right_4",
|
|
"face_jaw_right_5",
|
|
"face_jaw_right_6",
|
|
"face_jaw_right_7",
|
|
"face_jaw_right_8",
|
|
"face_jaw_middle",
|
|
"face_jaw_left_1",
|
|
"face_jaw_left_2",
|
|
"face_jaw_left_3",
|
|
"face_jaw_left_4",
|
|
"face_jaw_left_5",
|
|
"face_jaw_left_6",
|
|
"face_jaw_left_7",
|
|
"face_jaw_left_8",
|
|
"face_eyebrow_right_1",
|
|
"face_eyebrow_right_2",
|
|
"face_eyebrow_right_3",
|
|
"face_eyebrow_right_4",
|
|
"face_eyebrow_right_5",
|
|
"face_eyebrow_left_1",
|
|
"face_eyebrow_left_2",
|
|
"face_eyebrow_left_3",
|
|
"face_eyebrow_left_4",
|
|
"face_eyebrow_left_5",
|
|
"face_nose_1",
|
|
"face_nose_2",
|
|
"face_nose_3",
|
|
"face_nose_4",
|
|
"face_nose_5",
|
|
"face_nose_6",
|
|
"face_nose_7",
|
|
"face_nose_8",
|
|
"face_nose_9",
|
|
"face_eye_right_1",
|
|
"face_eye_right_2",
|
|
"face_eye_right_3",
|
|
"face_eye_right_4",
|
|
"face_eye_right_5",
|
|
"face_eye_right_6",
|
|
"face_eye_left_1",
|
|
"face_eye_left_2",
|
|
"face_eye_left_3",
|
|
"face_eye_left_4",
|
|
"face_eye_left_5",
|
|
"face_eye_left_6",
|
|
"face_mouth_1",
|
|
"face_mouth_2",
|
|
"face_mouth_3",
|
|
"face_mouth_4",
|
|
"face_mouth_5",
|
|
"face_mouth_6",
|
|
"face_mouth_7",
|
|
"face_mouth_8",
|
|
"face_mouth_9",
|
|
"face_mouth_10",
|
|
"face_mouth_11",
|
|
"face_mouth_12",
|
|
"face_mouth_13",
|
|
"face_mouth_14",
|
|
"face_mouth_15",
|
|
"face_mouth_16",
|
|
"face_mouth_17",
|
|
"face_mouth_18",
|
|
"face_mouth_19",
|
|
"face_mouth_20",
|
|
]
|
|
)
|
|
if whole_body["hands"]:
|
|
joint_names_2d.extend(
|
|
[
|
|
"hand_wrist_left",
|
|
"hand_finger_thumb_left_1",
|
|
"hand_finger_thumb_left_2",
|
|
"hand_finger_thumb_left_3",
|
|
"hand_finger_thumb_left_4",
|
|
"hand_finger_index_left_1",
|
|
"hand_finger_index_left_2",
|
|
"hand_finger_index_left_3",
|
|
"hand_finger_index_left_4",
|
|
"hand_finger_middle_left_1",
|
|
"hand_finger_middle_left_2",
|
|
"hand_finger_middle_left_3",
|
|
"hand_finger_middle_left_4",
|
|
"hand_finger_ring_left_1",
|
|
"hand_finger_ring_left_2",
|
|
"hand_finger_ring_left_3",
|
|
"hand_finger_ring_left_4",
|
|
"hand_finger_pinky_left_1",
|
|
"hand_finger_pinky_left_2",
|
|
"hand_finger_pinky_left_3",
|
|
"hand_finger_pinky_left_4",
|
|
"hand_wrist_right",
|
|
"hand_finger_thumb_right_1",
|
|
"hand_finger_thumb_right_2",
|
|
"hand_finger_thumb_right_3",
|
|
"hand_finger_thumb_right_4",
|
|
"hand_finger_index_right_1",
|
|
"hand_finger_index_right_2",
|
|
"hand_finger_index_right_3",
|
|
"hand_finger_index_right_4",
|
|
"hand_finger_middle_right_1",
|
|
"hand_finger_middle_right_2",
|
|
"hand_finger_middle_right_3",
|
|
"hand_finger_middle_right_4",
|
|
"hand_finger_ring_right_1",
|
|
"hand_finger_ring_right_2",
|
|
"hand_finger_ring_right_3",
|
|
"hand_finger_ring_right_4",
|
|
"hand_finger_pinky_right_1",
|
|
"hand_finger_pinky_right_2",
|
|
"hand_finger_pinky_right_3",
|
|
"hand_finger_pinky_right_4",
|
|
]
|
|
)
|
|
|
|
joint_names_2d.extend(
|
|
[
|
|
"hip_middle",
|
|
"shoulder_middle",
|
|
"head",
|
|
]
|
|
)
|
|
|
|
return joint_names_2d
|