Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion fairmotion/tasks/clustering/features/manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def __init__(self, motion, skeleton=feat_utils.Skeleton.PFNN):
self.joints = [joint.name for joint in motion.skel.joints]
self.frame_time = 1 / motion.fps
self.frame_num = 1
self.num_frames = motion.num_frames()
self.offsets = [
conversions.T2p(joint.xform_from_parent_joint)
for joint in motion.skel.joints
Expand All @@ -36,7 +37,16 @@ def __init__(self, motion, skeleton=feat_utils.Skeleton.PFNN):
)

def next_frame(self):
self.frame_num += 1
if self.frame_num + 1 > self.num_frames:
print("Reached end of motion!")
Copy link
Contributor

@Jungdam Jungdam Sep 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Between printing error and returning explicit 'end_of_frame' value, what would be better? Both are functionally the same, but users might want to check whether they reached end_of_frame explicitly?

else:
self.frame_num += 1

def skip_frames(self, num_frames):
if self.frame_num + num_frames > self.num_frames:
print("Reached end of motion!")
else:
self.frame_num += num_frames

def transform_and_fetch_position(self, j):
if j == "y_unit":
Expand Down
5 changes: 3 additions & 2 deletions fairmotion/tasks/clustering/generate_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
def extract_manual_features(motion):
features = []
f = manual.ManualFeatures(motion, feat_utils.Skeleton.PFNN)
for _ in range(1, motion.num_frames(), 30):
frames_to_skip = 30
for _ in range(1, motion.num_frames(), frames_to_skip):
pose_features = []
pose_features.append(
f.f_nmove("neck", "rhip", "lhip", "rwrist", 1.8 * f.hl)
Expand Down Expand Up @@ -115,7 +116,7 @@ def extract_manual_features(motion):
)
pose_features.append(f.f_fast("root", 2.3 * f.hl))
features.append(pose_features)
f.next_frame()
f.skip_frames(frames_to_skip)
return features


Expand Down