stream_hacks to main #2

Merged
skeh merged 8 commits from stream_hacks into main 2024-12-11 03:22:13 +00:00
2 changed files with 32 additions and 8 deletions
Showing only changes of commit c9db70f57d - Show all commits

View File

@ -44,6 +44,12 @@ body_map = {
LANDMARK_TYPES.KNEE | LANDMARK_TYPES.LEFT: [25], LANDMARK_TYPES.KNEE | LANDMARK_TYPES.LEFT: [25],
LANDMARK_TYPES.KNEE | LANDMARK_TYPES.RIGHT: [26], LANDMARK_TYPES.KNEE | LANDMARK_TYPES.RIGHT: [26],
LANDMARK_TYPES.ANKLE | LANDMARK_TYPES.LEFT: [27],
LANDMARK_TYPES.ANKLE | LANDMARK_TYPES.RIGHT: [28],
LANDMARK_TYPES.ANKLE | LANDMARK_TYPES.LEFT: [27],
LANDMARK_TYPES.ANKLE | LANDMARK_TYPES.RIGHT: [28],
} }
# SEE YEAH THESE MAKE SENSE GOOGLE WHAT THE HELL # SEE YEAH THESE MAKE SENSE GOOGLE WHAT THE HELL

View File

@ -130,16 +130,34 @@ class Process(TransformProcess):
joints[JOINT_TYPES.HEAD] = head_joint joints[JOINT_TYPES.HEAD] = head_joint
if landmarks.has(LANDMARK_TYPES.SHOULDER):
shoulder_l = Landmarks.to_numpy(landmarks[LANDMARK_TYPES.SHOULDER | LANDMARK_TYPES.LEFT]).mean(axis=0)
shoulder_r = Landmarks.to_numpy(landmarks[LANDMARK_TYPES.SHOULDER | LANDMARK_TYPES.RIGHT]).mean(axis=0)
joints[JOINT_TYPES.SHOULDER_L] = Joint(Point3d(*shoulder_l), Quaternion.identity())
joints[JOINT_TYPES.SHOULDER_R] = Joint(Point3d(*shoulder_r), Quaternion.identity())
if landmarks.has(LANDMARK_TYPES.ELBOW):
elbow_l = Landmarks.to_numpy(landmarks[LANDMARK_TYPES.ELBOW | LANDMARK_TYPES.LEFT]).mean(axis=0)
elbow_r = Landmarks.to_numpy(landmarks[LANDMARK_TYPES.ELBOW | LANDMARK_TYPES.RIGHT]).mean(axis=0)
joints[JOINT_TYPES.ELBOW_L] = Joint(Point3d(*elbow_l), Quaternion.identity())
joints[JOINT_TYPES.ELBOW_R] = Joint(Point3d(*elbow_r), Quaternion.identity())
if landmarks.has(LANDMARK_TYPES.HIP):
hips = Landmarks.to_numpy(landmarks[LANDMARK_TYPES.HIP]).mean(axis=0)
joints[JOINT_TYPES.HIPS] = Joint(Point3d(*hips), Quaternion.identity())
# Synthizise other joints from existing data # Synthizise other joints from existing data
if not joints.get(JOINT_TYPES.CHEST) and joints.get(JOINT_TYPES.HEAD): if not joints.get(JOINT_TYPES.CHEST):
chest_center = joints[JOINT_TYPES.HEAD].pos.as_np() if landmarks.has(LANDMARK_TYPES.SHOULDER) and landmarks.has(LANDMARK_TYPES.HIP):
chest_center = np.power(chest_center, 3) / (1e3 + np.power(chest_center, 2)) chest = Landmarks.to_numpy(landmarks[LANDMARK_TYPES.SHOULDER, LANDMARK_TYPES.HIP]).mean(axis=0)
chest_center -= [0, 100, 0] joints[JOINT_TYPES.CHEST] = Joint(Point3d(*chest), Quaternion.identity())
elif joints.get(JOINT_TYPES.HEAD):
chest_center = joints[JOINT_TYPES.HEAD].pos.as_np()
chest_center = np.power(chest_center, 3) / (1e3 + np.power(chest_center, 2))
chest_center -= [0, 100, 0]
chest_rot = Quaternion.identity().slerp(joints[JOINT_TYPES.HEAD].rot, 0.1)
chest_rot = Quaternion.identity().slerp(joints[JOINT_TYPES.HEAD].rot, 0.1) joints[JOINT_TYPES.CHEST] = Joint(Point3d(*chest_center), chest_rot)
chest_joint = Joint(Point3d(*chest_center), chest_rot)
joints[JOINT_TYPES.CHEST] = chest_joint
skeleton = Skeleton(joints) skeleton = Skeleton(joints)