4.18. bvh — Reading Biovision Hierarchical (BVH) motion capture files
This module contains the BVHReader class which can be used as a base
class for reading Biovision Hierarchical (BVH) files. The class reads the file
and invokes callback methods with the corresponding data in the file. Derived
classes have to implement those callback methods and process the data as
appropriate.
-
class cgkit.bvh.BVHReader(filename)
- filename is the name of the BVH file that should be read.
-
BVHReader.read()
- Read the entire file.
-
BVHReader.onHierarchy(root)
- This method is called after the joint hierarchy was read. The entire hierarchy
is passed in the argument root which is a Node object.
-
BVHReader.onMotion(frames, dt)
- This method is called when the motion data begins. frames is the number of
motion samples that follow and dt is the time interval that corresponds to one
frame.
-
BVHReader.onFrame(values)
- This method is called for each motion sample (frame) in the file. values is a
list of floats that contains the position and angles of the entire skeleton. The
order is the same than when traversing the joint hierarchy in a depth-first
manner.
4.18.1. Node objects
The onHierarchy() method of the BVHReader class takes the joint
hierarchy of the skeleton as input. Each node in this hierarchy is represented
by a Node object that contains all information stored in the BVH file.
-
class cgkit.bvh.Node
- A Node object represents one joint in the hierarchy.
-
Node.name
- This is the name of the joint (or the root).
-
Node.channels
- This is a list of channel names that are associated with this joint. This list
determines how many values are stored in the motion section and how they are to
be interpreted. Each channel name can be one of Xposition, Yposition,
Zposition, Xrotation, Yrotation, Zrotation.
-
Node.offset
- This is a 3-tuple of floats containing the offset position of this joint
relative to the parent joint.
-
Node.children
- This is a list of children joints (which are again described by Node
objects).
-
Node.isRoot()
- Returns True if the node is the root node.
-
Node.isEndSite()
- Returns True if the node is a leaf.