Ziye Liu's Blog
  • ( www.ziyeliu.com )
  • Home
  • Visual Effects Blog
    • Houdini >
      • Procedural Courtyard House
      • Procedural Music Animation
    • Maya - MEL >
      • MEL Rooftop Generator
      • MEL Circle of Spheres
    • Maya - Rendering >
      • Maya Render Premultiply Issue
      • Depth of Field and Bokeh
      • 3D Render - Match to a Real Object
      • RenderMan I
      • RenderMan II
    • Python >
      • Python Sampler Quilt
      • Motion Capture Data Parsing
      • Python and Turtle Graphics
  • Themes & Variations
    • The Film
    • Scene 1 - "Crazy Polka Dots"
    • Scene 2 - “Untitled”
    • Scene 3 - "Grapes"
    • Scene 4 - “Narcissus Garden”
  • 中文博客

Motion Capture Data Parsing

Python + Houdini

Introduction
Motion capture is a technique widely used in animation and visual effects. The raw data came from motion capture devices are usually in a format that 3D software doesn't recognize. This exercise will convert the raw data into a readable .txt sequence, and load it into 3D software Houdini.
This is the third exercise of Prof. Deborah R. Fowler's VSFX 705 - Programming Concept class in Spring 2013.

Get the data, manipulate its format

Motion capture data comes in the format of a list, which contains position information of all the markers in a frame-by-frame basis.  
Since the data itself couldn't be access by 3D software, so a reformatting operation must be conducted before loading them. In this case, Python being very handy with string manipulation.
May 11th, 2013
Picture
Before: Motion Capture data in .txt format. It is all in one .txt file contains point data of every tracking mark.
Picture
After: Reformat the data, it is now separated into a sequence of .txt file, with label on each marker's x,y,z data.
The motion capture data used here are came from Motion Capture Lab of the Advanced Computing Center for the Arts and Design, Ohio State University.
kareenbalsam03.txt
File Size: 6016 kb
File Type: txt
Download File

kareenbalsam03.zip
File Size: 859 kb
File Type: zip
Download File

aug210106.txt
File Size: 199 kb
File Type: txt
Download File

aug210106.zip
File Size: 27 kb
File Type: zip
Download File

data_parsing_v2.py
File Size: 4 kb
File Type: py
Download File

The original motion capture data used in this exercise

The parsed data in a .zip file.

The original motion capture data used in this exercise

The parsed data in a .zip file.

The Python script used to parse the data.

Import the Motion Capture Data into Houdini

Picture
import hou
  
geo = hou.pwd().geometry()
  
# source file directory
source_file = hou.evalParm("mocapFiles")
source_file = hou.expandString(source_file)
  
# open the file
file = open(source_file)
  
poly = geo.createPolygon()
poly.setIsClosed(0)
  
# read in the mocap file
for line in file:
    line = line.split()[1:]
    # split the list, leaving the x,y,z point datas only
    points = geo.createPoint() 
    # create a point
    points.setPosition((float(line[0]), float(line[2]), float(line[1]))) 
    # position the points based on the mocap's x,y,z
  
# close the file
file.close() 
The parsed motion capture data was then imported into Houdini, via a python operator that reads in .txt sequence and shows the data as particle cloud in the 3D scene.
A basic sphere geometry was attached to the point cloud to represent the tracking markers, and series of nodes such as Scatter, Pointjitter and Trail were connected to enhance the sphere body's volume.
importmocap.hipnc
File Size: 986 kb
File Type: hipnc
Download File

importmocap.otl
File Size: 3 kb
File Type: otl
Download File

The Houdini project file.

The "import mocap" node (Digital Asset).

Rendering, Compositing and Post-Processing

Finished Animation
Raw Render
Compositing Breakdown
Spheres are connected to a mantra shader with basic reflection, and another shader with self-illumination is given to the marker's position.
The scene is rendered using Houdini's Physical Based Lighting with a skylight setup. The rendered sequence is then composited in After Effects.

Reference

  • Resources for Python from Professor Deborah R. Fowler's Website
  • Python Quick Reference from Professor Malcolm Kesson's Website
  • How To Think Like a Computer Scientist from Open Book Project
  • Python Basic Tutorial from Tutorialspoint
  • A Python Course from Uta Priss
  • Motion Capture Lab from Advanced Computing Center of the Arts and Design, The Ohio State University
www.ziyeliu.com
Digital Art, 3D, Photography
©Ziye Liu, 2011 - 2023, All Rights Reserved