facebookresearch/fairmotion

Assert error when loading BVH motion that has frame rate different than 60 fps

anonymous-pusher opened this issue · 2 comments

The problem:

When loading a BVH file with motion captured at a sampling rate different than 60 fps, the animation does not loop in the visualization and the following error is thrown:
Exception ignored on calling ctypes callback function: <bound method Viewer.draw_GL of <__main__.MocapViewer object at 0x7fcde5185f40>> Traceback (most recent call last): File "/home/jones/anaconda3/envs/ScaDiver/lib/python3.8/site-packages/fairmotion/viz/glut_viewer.py", line 162, in draw_GL self.render_callback() File "fairmotion/viz/bvh_visualizer.py", line 176, in render_callback self._render_characters(colors) File "fairmotion/viz/bvh_visualizer.py", line 154, in _render_characters pose = motion.get_pose_by_frame(motion.time_to_frame(t)) File "/home/jones/anaconda3/envs/ScaDiver/lib/python3.8/site-packages/fairmotion/core/motion.py", line 359, in get_pose_by_frame assert frame < self.num_frames(), f"{frame} vs. {self.num_frames()}" AssertionError: 4400 vs. 4311

The cause:

By default the motion class uses 60 as default value for fps, therefore fps_inv is 1/60. When loading a BVH file, an empty motion object is created with default field values then those values are overwritten by values read from the loaded file. In fairmotion.data.bvh, the value of fps is assigned to the motion object field but not fps_inv, so it is always kept to 1/60 and the motion length will be nbr_poses * 1/60.

Solution

Add line motion.fps_inv = dt after motion.fps = round(1 / dt) in fairmotion.data.bvh

@mJones00 thanks for the report. The bug was fixed in an earlier PR from Sep 2020 (#33). Are you using the latest version of code?

If you're using a packaged version from PyPI, I would suggest doing a local install instead -- clone the repo and run pip install -e .. We haven't updated the public PyPI package in a while, it's on my TODOs.

@dpacgopinath Yes I'm using the PyPI packaged version. I will do a local install as you suggested. Thanks