BVH (Biovision Hierarchy) と CSV データを 相互に変換できるbvhtoolbox

bvhtoolbox

GitHub – OlafHaag/bvh-toolbox: Scripts for manipulating and converting BVH files.

pip install bvhtoolbox

修正

AttributeError: module 'numpy’ has no attribute 'float’.

“D:\WinPython\python-3.10.11.amd64\Lib\site-packages\bvhtoolbox\convert\bvh2csv.py"


    data = np.array(data, dtype=[('joint', np.unicode_, 20),
                                 ('parent', np.unicode_, 20),
                                 ('offset.x', np.float),
                                 ('offset.y', np.float),
                                 ('offset.z', np.float)])

    data = np.array(data, dtype=[('joint', np.unicode_, 20),
                                 ('parent', np.unicode_, 20),
                                 ('offset.x', np.float64),
                                 ('offset.y', np.float64),
                                 ('offset.z', np.float64)])

bvh2csv

call %~dp0\scripts\env_for_icons.bat  %*
bvh2csv C:/data2/bvh/greeting/greeting/bye.bvh --hierarchy --out C:/data2/bvh/greeting/ 

csv2bvh

call %~dp0\scripts\env_for_icons.bat  %*
csv2bvh --out C:/data2/bvh/greeting/bye.bvh  C:/data2/bvh/greeting/hierarchy.csv C:/data2/bvh/greeting/position.csv  C:/data2/bvh/greeting/rotation.csv

サンプル

example_hierarchy.csv

joint,parent,offset.x,offset.y,offset.z
Hips,,   0.00000,   0.00000,   0.00000
Chest,Hips,   0.00000,   5.21000,   0.00000
Neck,Chest,   0.00000,  18.65000,   0.00000
Head,Neck,   0.00000,   5.45000,   0.00000
Head_End,Head,   0.00000,   3.87000,   0.00000
LeftCollar,Chest,   1.12000,  16.23000,   1.87000
LeftUpArm,LeftCollar,   5.54000,   0.00000,   0.00000
LeftLowArm,LeftUpArm,   0.00000, -11.96000,   0.00000
LeftHand,LeftLowArm,   0.00000,  -9.93000,   0.00000
LeftHand_End,LeftHand,   0.00000,  -7.00000,   0.00000
RightCollar,Chest,  -1.12000,  16.23000,   1.87000
RightUpArm,RightCollar,  -6.07000,   0.00000,   0.00000
RightLowArm,RightUpArm,   0.00000, -11.82000,   0.00000
RightHand,RightLowArm,   0.00000, -10.65000,   0.00000
RightHand_End,RightHand,   0.00000,  -7.00000,   0.00000
LeftUpLeg,Hips,   3.91000,   0.00000,   0.00000
LeftLowLeg,LeftUpLeg,   0.00000, -18.34000,   0.00000
LeftFoot,LeftLowLeg,   0.00000, -17.37000,   0.00000
LeftFoot_End,LeftFoot,   0.00000,  -3.46000,   0.00000
RightUpLeg,Hips,  -3.91000,   0.00000,   0.00000
RightLowLeg,RightUpLeg,   0.00000, -17.63000,   0.00000
RightFoot,RightLowLeg,   0.00000, -17.14000,   0.00000
RightFoot_End,RightFoot,   0.00000,  -3.75000,   0.00000

example_pos.csv

time,Hips.x,Hips.y,Hips.z,Chest.x,Chest.y,Chest.z,Neck.x,Neck.y,Neck.z,Head.x,Head.y,Head.z,LeftCollar.x,LeftCollar.y,LeftCollar.z,LeftUpArm.x,LeftUpArm.y,LeftUpArm.z,LeftLowArm.x,LeftLowArm.y,LeftLowArm.z,LeftHand.x,LeftHand.y,LeftHand.z,RightCollar.x,RightCollar.y,RightCollar.z,RightUpArm.x,RightUpArm.y,RightUpArm.z,RightLowArm.x,RightLowArm.y,RightLowArm.z,RightHand.x,RightHand.y,RightHand.z,LeftUpLeg.x,LeftUpLeg.y,LeftUpLeg.z,LeftLowLeg.x,LeftLowLeg.y,LeftLowLeg.z,LeftFoot.x,LeftFoot.y,LeftFoot.z,RightUpLeg.x,RightUpLeg.y,RightUpLeg.z,RightLowLeg.x,RightLowLeg.y,RightLowLeg.z,RightFoot.x,RightFoot.y,RightFoot.z
   0.00000,   8.03000,  35.01000,  88.36000,   8.32964,  40.03869,  89.68911,   9.16411,  56.59903,  81.15206,  10.05713,  58.31566,  76.05714,   8.02774,  53.61066,  80.53079,   2.66686,  55.00472,  80.62631,  -8.11044,  57.04537,  75.85900,  -6.00360,  50.19564,  68.98533,  10.26293,  53.57085,  80.67206,  16.05239,  55.26203,  81.35541,  27.78119,  56.50936,  80.58617,  28.90726,  64.65271,  73.81561,   4.25561,  34.96535,  89.37986,   0.90001,  17.29523,  92.96628,  -0.39191,   9.47835, 108.42410,  11.80439,  35.05465,  87.34014,  14.80475,  19.91596,  78.81755,  17.13273,   4.58868,  86.12745
   0.03333,   7.81000,  35.10000,  86.47000,   8.14475,  40.16665,  87.63668,   9.28071,  56.09223,  77.99781,  10.19532,  57.46254,  72.80279,   8.09148,  53.08930,  77.57853,   2.97815,  55.00491,  76.64265,  -7.69478,  58.58872,  72.60699,  -5.86550,  52.37798,  65.07802,  10.32551,  53.01939,  77.72631,  15.84285,  54.73873,  79.58310,  27.62790,  54.84512,  78.68104,  29.82679,  62.17369,  71.27298,   3.99595,  35.15415,  87.32917,  -0.00787,  17.33422,  88.99497,   0.19280,   9.70638, 104.59923,  11.62405,  35.04585,  85.61083,  14.91456,  19.55809,  77.85720,  17.14937,   4.64242,  86.00018

example_rot.csv

time,Hips.z,Hips.x,Hips.y,Chest.z,Chest.x,Chest.y,Neck.z,Neck.x,Neck.y,Head.z,Head.x,Head.y,LeftCollar.z,LeftCollar.x,LeftCollar.y,LeftUpArm.z,LeftUpArm.x,LeftUpArm.y,LeftLowArm.z,LeftLowArm.x,LeftLowArm.y,LeftHand.z,LeftHand.x,LeftHand.y,RightCollar.z,RightCollar.x,RightCollar.y,RightUpArm.z,RightUpArm.x,RightUpArm.y,RightLowArm.z,RightLowArm.x,RightLowArm.y,RightHand.z,RightHand.x,RightHand.y,LeftUpLeg.z,LeftUpLeg.x,LeftUpLeg.y,LeftLowLeg.z,LeftLowLeg.x,LeftLowLeg.y,LeftFoot.z,LeftFoot.x,LeftFoot.y,RightUpLeg.z,RightUpLeg.x,RightUpLeg.y,RightLowLeg.z,RightLowLeg.x,RightLowLeg.y,RightFoot.z,RightFoot.x,RightFoot.y
   0.00000,  -3.41000,  14.78000,-164.35000,  13.09000,  40.30000, -24.60000,   7.88000,  43.80000,   0.00000,  -3.61000, -41.45000,   5.82000,  10.08000,   0.00000,  10.21000,  97.95000, -23.53000,  -2.14000,-101.86000, -80.77000, -98.91000,   0.69000,   0.03000,   0.00000, -14.04000,   0.00000, -10.50000, -85.52000, -13.72000,-102.93000,  61.91000, -61.18000,  65.18000,  -1.57000,   0.69000,   0.02000,  15.00000,  22.78000,  -5.92000,  14.93000,  49.99000,   6.60000,   0.00000,  -1.14000,   0.00000, -16.58000, -10.51000,  -3.11000,  15.38000,  52.66000, -21.80000,   0.00000, -23.95000,   0.00000
   0.03333,  -3.78000,  12.94000,-166.97000,  12.64000,  42.57000, -22.34000,   7.67000,  43.61000,   0.00000,  -4.23000, -41.41000,   4.89000,  19.10000,   0.00000,   4.16000,  93.12000,  -9.69000,  -9.43000, 132.67000, -81.86000, 136.80000,   0.70000,   0.37000,   0.00000,  -8.62000,   0.00000, -21.82000, -87.31000, -27.57000,-100.09000,  56.17000, -61.56000,  58.72000,  -1.63000,   0.95000,   0.03000,  13.16000,  15.44000,  -3.56000,   7.97000,  59.29000,   4.97000,   0.00000,   1.64000,   0.00000, -17.18000, -10.02000,  -3.08000,  13.56000,  53.38000, -18.07000,   0.00000, -25.93000,   0.00000

etc,Python

Posted by eightban