Skip to content

kaki005/PyAMCParser

 
 

Repository files navigation

AMCParser

  • This repository is forked from https://github.com/CalciferZh/AMCParser A lightweight library to parse and visualize asf/amc files from CMU MoCap dataset using Python 3. The main purpose of this library is to help understanding how asf/amc file works, as well as how to use them. Therefore, simplicity and readability are stressed, while robustness is ignored.

Demo

Demo using PyGame and PyOpenGL:

3D Demo

Demo using Matplotlib:

Static Demo

Usage

Parse

  • The asf/amc parsers are straightforward and easy to understand. The parsers are fully tested on the CMU MoCap dataset, but I don't expect it can work on other datasets without any modification. However, it won't be hard to extend it for more complicating asf/amc files.
if __name__ == '__main__':
  asf_path = './data/01/01.asf'
  amc_path = './data/01/01_01.amc'
  joints = parse_asf(asf_path)
  motions = parse_amc(amc_path)
  frame_idx = 180
  joints['root'].set_motion(motions[frame_idx])
  joints['root'].draw()

Play motion

  • you can play motion using Viewer class.
  • The data can be found from CMU MoCap dataset.
  • Matplotlib is used to draw joints and bones in 3D statically; PyGame and PyOpenGL are used to draw motion sequence.
  asf_path = './data/01/01.asf'
  amc_path = './data/01/01_01.amc'
  joints = parse_asf(asf_path)
  motions = parse_amc(amc_path)
  v = Viwer(joints)
  v.run_with_amc(motions)
  • Key
    • WASD to move around.
    • QE to zoom in/out.
    • ↑ ↓ ← → to rotate.
    • LEFT MOUSE BUTTON to drag.
    • RETURN to reset camera view.
    • SPACE to start/pause.
    • , and . to rewind and forward.

Convert to Tensor

  • You can convert from amc format to numpy 3D array (time, sensor, coordinate).
  • You can play motion from numpy array.
  asf_path = './data/01/01.asf'
  amc_path = './data/01/01_01.amc'
  joints = parse_asf(asf_path)
  motions = parse_amc(amc_path)
  tensor = amc_to_tensor(motions, joints)
  v = Viewer(joints)
  v.run_with_tensor(tensor)

Dependencies

  • numpy
  • transforms3d
  • matplotlib
  • pygame
  • pyopengl

About

Parse and visualize asf/amc files from CMU MoCap dataset.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 97.5%
  • Makefile 2.5%