目录
bvh格式介绍
3d点转bvh
npz格式:
这个可能是标准的:
保存:
np.savez_compressed(output_npz, reconstruction=output_3d_all)
读取:
prediction = np.load(r'D:\data\output_keypoints_3d.npz', allow_pickle=True)
for key in prediction.keys():
prediction = prediction[key]
prediction = prediction.astype('float32')
bvh格式转换:
bvh-converter ok
pip install bvh-converter
bvh-converter 文件名
or:python -m bvh-converter 文件名
BVH_reader和bvh-converter 一致
https://github.com/ColbyZhuang/BVH_reader
生成bvh:
https://github.com/non-void/LocalMoCap
导入导出bvh
bvh可视化:
https://github.com/dabeschte/npybvh/blob/master/bvh.py
H3.6M数据集转bvh
csv转bvh
https://github.com/Dene33/hmr/blob/83b2c33d42b87781a361c5f01f6fd51afb8517d4/csv_to_bvh.py
import csv
import os
import bpy
objects = bpy.context.scene.objects
empties = []
for object in objects:
if object.type == 'EMPTY':
empties.append(object)
print(empties)
filename = 'csv_joined.csv'
directory = r'hmr/output/csv_joined' # <-- if you have linux or osx
fullpath = os.path.join(directory, filename)
with open(fullpath, 'r', newline='') as csvfile:
ofile = csv.reader(csvfile, delimiter=',')
next(ofile) # <-- skip the x,y,z header
for line in ofile:
f, *pts = line
# these things are still strings (that's how they get stored in the file)
# here we recast them to integer and floats
frame_num = int(f)
fpts = [float(p) for p in pts]
coordinates = [fpts[0:3], fpts[3:6], fpts[6:9], fpts[9:12],
fpts[12:15], fpts[15:18], fpts[18:21], fpts[21:24],
fpts[24:27], fpts[27:30], fpts[30:33], fpts[33:36],
fpts[36:39], fpts[39:42],fpts[42:45], fpts[45:48],
fpts[48:51], fpts[51:54], fpts[54:57], fpts[57:60]]
bpy.context.scene.frame_set(frame_num)
bpy.data.scenes['Scene'].frame_end = frame_num + 1
for ob, position in zip(empties, coordinates):
ob.location = position
ob.keyframe_insert(data_path="location", index=-1)
bpy.data.objects['rig'].select = True
target_file = 'hmr/output/bvh_animation/estimated_animation.bvh'
bpy.ops.export_anim.bvh(filepath=target_file)
pkl转换bvh
【姿态识别】PoseTriplet——3D转bvh-CSDN博客
代码地址:
https://github.com/Garfield-kh/PoseTriplet/blob/eb93132f99161bd776dafbcb713e9fb43e501c36/estimator/posegan_evaluate.py#L360
运行posegan_evaluate.py
环境安装
sklearn
pip install scikit-learn
pip install torchgeometry
問題解決
No such file or directory: ‘data/data_3d_h36m.npz’
下载地址:https://download.csdn.net/download/weixin_46870724/88584488
FileNotFoundError: [Errno 2] No such file or directory:
‘data/data_2d_h36m_gt.npz’
下载地址:https://download.csdn.net/download/weixin_46870724/88584804
FileNotFoundError: [Errno 2] No such file or directory: './data_cross/3dhp/3dhp_testset_bySub.pkl'
下载地址:https://download.csdn.net/download/weixin_46870724/88585024?spm=1001.2014.3001.5503
運行
运行pose2bvh_debug.py
代码中配置好生成3D的pkl文件即可
原文链接:https://blog.csdn.net/weixin_46870724/article/details/134719737