File size: 1,327 Bytes
2d5fdd1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import os,sys
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
ROOT_DIR = os.path.abspath(os.path.join(THIS_DIR, os.pardir))
sys.path.append(ROOT_DIR)

from analysis.pymo.parsers import BVHParser
from analysis.pymo.data import Joint, MocapData
from analysis.pymo.preprocessing import *
from analysis.pymo.viz_tools import *
from analysis.pymo.writers import *
from sklearn.pipeline import Pipeline

import matplotlib.pyplot as plt

#%%
p = BVHParser()
# f1="data/dance_full/shadermotion_justdance/bvh/justdance_0.bvh"
# f2="data/dance_full/kth_streetdance_data/bvh/Streetdance_001.bvh"
f1=sys.argv[1] #target file
scale=float(sys.argv[2]) #scale
output=sys.argv[3] #output file
# f2=sys.argv[2] #file from which to source the offsets of the skeleton (bone names and hierarchy should be the same)
# f2="/home/guillefix/code/mt-lightning/data/dance_full/kth_streetdance_data/bvh/Streetdance_001.bvh"

data1 = p.parse(f1)
# data2 = p.parse(f2)

data1.skeleton

for name, bone in data1.skeleton.items():
    bone["offsets"] = [x*scale for x in bone["offsets"]]
    data1.skeleton[name]=bone

data1.values["Hips_Xposition"] *= scale
data1.values["Hips_Yposition"] *= scale
data1.values["Hips_Zposition"] *= scale

writer = BVHWriter()
with open(output,'w') as f:
    writer.write(data1, f)

# data1.skeleton
#
# data2.skeleton