src/bvhtoolbox/convert/bvh2csv.py
def bvh2csv(bvh_path,
            dst_dirpath=None,
            scale=1.0,
            export_rotation=True,
            export_position=True,
            export_hierarchy=True,
            end_sites=True):
    """Converts a BVH file into CSV file format.
    When passing keyword arguments, keywords must be used!

    :param bvh_path: File path(s) for BVH source.
    :type bvh_path: str|list
    :param dst_dirpath: Folder path for destination CSV files.
    :type dst_dirpath: str
    :param scale: Scale factor for root position and offset values.
    :type scale: float
    :param export_rotation: Output rotation CSV file.
    :type export_rotation: bool
    :param export_position: Output world space position CSV file.
    :type export_position: bool
    :param export_hierarchy: Output hierarchy CSV file.
    :type export_hierarchy: bool
    :param end_sites: Include BVH End Sites in position CSV.
    :type end_sites: bool
    :return: If the conversion was successful or not.
    :rtype: bool
    """
    try:
        with open(bvh_path) as file_handle:
            mocap = BvhTree(file_handle.read())
    except IOError as e:
        print("ERROR {}: Could not open file".format(e.errno), bvh_path)
        return False

    # Assume everything works and only set False on error.
    pos_success = True
    rot_success = True
    hierarchy_success = True
    if not dst_dirpath:
        dst_filepath = os.path.join(os.path.dirname(bvh_path), os.path.basename(bvh_path)[:-4])
    else:
        # If the specified path doesn't yet exist, create it.
        if not os.path.exists(dst_dirpath):
            os.mkdir(dst_dirpath)
        dst_filepath = os.path.join(dst_dirpath, os.path.basename(bvh_path)[:-4])
    if export_position:
        pos_success = write_joint_positions(mocap, dst_filepath + '_pos.csv', scale, end_sites)
    if export_rotation:
        rot_success = write_joint_rotations(mocap, dst_filepath + '_rot.csv')
    if export_hierarchy:
        hierarchy_success = write_joint_hierarchy(mocap, dst_filepath + '_hierarchy.csv', scale)

    n_succeeded = sum([pos_success, rot_success, hierarchy_success])
    return bool(n_succeeded)
Converts a BVH file into CSV file format.
    When passing keyword arguments, keywords must be used!

    :param bvh_path: File path(s) for BVH source.
    :type bvh_path: str|list
    :param dst_dirpath: Folder path for destination CSV files.
    :type dst_dirpath: str
    :param scale: Scale factor for root position and offset values.
    :type scale: float
    :param export_rotation: Output rotation CSV file.
    :type export_rotation: bool
    :param export_position: Output world space position CSV file.
    :type export_position: bool
    :param export_hierarchy: Output hierarchy CSV file.
    :type export_hierarchy: bool
    :param end_sites: Include BVH End Sites in position CSV.
    :type end_sites: bool
    :return: If the conversion was successful or not.
    :rtype: bool
    
Converts a BVH file into CSV file format.
When passing keyword arguments, keywords must be used!
Converts a BVH file into CSV file format . When passing keyword arguments keywords must be used!
def bvh2csv(bvh_path,
            dst_dirpath=None,
            scale=1.0,
            export_rotation=True,
            export_position=True,
            export_hierarchy=True,
            end_sites=True):
    try:
        with open(bvh_path) as file_handle:
            mocap = BvhTree(file_handle.read())
    except IOError as e:
        print("ERROR {}: Could not open file".format(e.errno), bvh_path)
        return False
    pos_success = True
    rot_success = True
    hierarchy_success = True
    if not dst_dirpath:
        dst_filepath = os.path.join(os.path.dirname(bvh_path), os.path.basename(bvh_path)[:-4])
    else:
        if not os.path.exists(dst_dirpath):
            os.mkdir(dst_dirpath)
        dst_filepath = os.path.join(dst_dirpath, os.path.basename(bvh_path)[:-4])
    if export_position:
        pos_success = write_joint_positions(mocap, dst_filepath + '_pos.csv', scale, end_sites)
    if export_rotation:
        rot_success = write_joint_rotations(mocap, dst_filepath + '_rot.csv')
    if export_hierarchy:
        hierarchy_success = write_joint_hierarchy(mocap, dst_filepath + '_hierarchy.csv', scale)
    n_succeeded = sum([pos_success, rot_success, hierarchy_success])
    return bool(n_succeeded)
def bvh2csv ( bvh_path , dst_dirpath = None , scale = 1.0 , export_rotation = True , export_position = True , export_hierarchy = True , end_sites = True ) : try : with open ( bvh_path ) as file_handle : mocap = BvhTree ( file_handle . read ( ) ) except IOError as e : print ( "ERROR {}: Could not open file" . format ( e . errno ) , bvh_path ) return False pos_success = True rot_success = True hierarchy_success = True if not dst_dirpath : dst_filepath = os . path . join ( os . path . dirname ( bvh_path ) , os . path . basename ( bvh_path ) [ : - 4 ] ) else : if not os . path . exists ( dst_dirpath ) : os . mkdir ( dst_dirpath ) dst_filepath = os . path . join ( dst_dirpath , os . path . basename ( bvh_path ) [ : - 4 ] ) if export_position : pos_success = write_joint_positions ( mocap , dst_filepath + '_pos.csv' , scale , end_sites ) if export_rotation : rot_success = write_joint_rotations ( mocap , dst_filepath + '_rot.csv' ) if export_hierarchy : hierarchy_success = write_joint_hierarchy ( mocap , dst_filepath + '_hierarchy.csv' , scale ) n_succeeded = sum ( [ pos_success , rot_success , hierarchy_success ] ) return bool ( n_succeeded )
Converts a BVH file into CSV file format.
Converts a BVH file into CSV file format .
"""Converts a BVH file into CSV file format.
    When passing keyword arguments, keywords must be used!

    :param bvh_path: File path(s) for BVH source.
    :type bvh_path: str|list
    :param dst_dirpath: Folder path for destination CSV files.
    :type dst_dirpath: str
    :param scale: Scale factor for root position and offset values.
    :type scale: float
    :param export_rotation: Output rotation CSV file.
    :type export_rotation: bool
    :param export_position: Output world space position CSV file.
    :type export_position: bool
    :param export_hierarchy: Output hierarchy CSV file.
    :type export_hierarchy: bool
    :param end_sites: Include BVH End Sites in position CSV.
    :type end_sites: bool
    :return: If the conversion was successful or not.
    :rtype: bool
    """ # Assume everything works and only set False on error. # If the specified path doesn't yet exist, create it.
If the conversion was successful or not.
If the conversion was successful or not .
bool
bvh_path
File path(s) for BVH source.
File path ( s ) for BVH source .
dst_dirpath
Folder path for destination CSV files.
Folder path for destination CSV files .
scale
Scale factor for root position and offset values.
Scale factor for root position and offset values .
export_rotation
Output rotation CSV file.
Output rotation CSV file .
export_position
Output world space position CSV file.
Output world space position CSV file .
export_hierarchy
Output hierarchy CSV file.
Output hierarchy CSV file .
end_sites
Include BVH End Sites in position CSV.
Include BVH End Sites in position CSV .