-
Notifications
You must be signed in to change notification settings - Fork 89
Open
Description
followed the code in this project and simplified it a bit. I would like to ask how these 61 points generate 778*3 points. I feel that the result is strange after generation. I hope you can take a look and tell me what needs to be modified.
import pickle
import numpy as np
import torch
from manopth.manolayer import ManoLayer
import os
# 2. 解析提供的数据
vertices = [
2.2324724197387686,
0.17883239686489108,
-0.21358124911785112,
0.05220034718513489,
-0.16106925904750824,
-0.07513493299484253,
-0.024418428540229797,
-0.003119782544672489,
0.5173907279968262,
0.1269320398569107,
0.06313903629779816,
0.41491588950157166,
-0.12646515667438507,
-0.13528624176979065,
0.6040743589401245,
-0.06075223162770271,
-0.07627902179956436,
0.4660395085811615,
-0.008370521478354931,
0.060622330754995346,
0.3614122271537781,
-0.6038511991500854,
0.27024397253990173,
0.960309624671936,
-0.0069151027128100395,
-0.0011883098632097244,
0.3552946150302887,
-0.4096725583076477,
-0.03698532655835152,
-0.012458777986466885,
-0.13010376691818237,
0.10553926974534988,
0.9122609496116638,
-0.2833951711654663,
0.04361569136381149,
0.2645259499549866,
-0.15045560896396637,
0.052607789635658264,
0.31532639265060425,
0.2744719088077545,
-0.09708910435438156,
-0.29489558935165405,
-0.43372780084609985,
-0.10651036351919174,
0.21608810126781464,
0.2551076114177704,
-0.12822265923023224,
-0.19144994020462036,
-0.31784361600875854,
-0.0012996774166822433,
0.006854147184640169,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
88.70099920875388,
107.33331026139358,
661.7427649346813
]
# 提取shape、pose和camera参数
shape_params = np.array(vertices[48:58])
pose_params = np.array(vertices[:48])
# 3. 初始化 MANO 模型
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
mano_layer = ManoLayer(
mano_root='./mano_models',
use_pca=False, # 使用完整的 48 维姿态参数
flat_hand_mean=False
).to(device)
# 4. 将参数转换为张量
shape_tensor = torch.tensor(shape_params, dtype=torch.float32).unsqueeze(0).to(device)
pose_tensor = torch.tensor(pose_params, dtype=torch.float32).unsqueeze(0).to(device)
# 5. 通过MANO模型获取手部网格
hand_verts, hand_joints = mano_layer(pose_tensor, shape_tensor)
# 6. 应用相机参数
# FreiHAND相机模型: [焦距, 主点x, 主点y]
# 获取顶点并转到CPU
vertices = hand_verts.squeeze().detach().cpu().numpy()/1000.0 # [778, 3]
# 7. 保存为OBJ文件
def save_obj(vertices, faces, filepath):
with open(filepath, 'w') as fp:
for v in vertices:
fp.write('v %f %f %f\n' % (v[0], v[1], v[2]))
for f in faces:
# OBJ文件索引从1开始
fp.write('f %d %d %d\n' % (f[0] + 1, f[1] + 1, f[2] + 1))
print(f"保存了包含{len(vertices)}个顶点的手部模型到{filepath}")
# 获取面片信息
faces = mano_layer.th_faces.detach().cpu().numpy()
# 保存OBJ文件
output_path = "hand_model.obj"
save_obj(vertices, faces, output_path)
# 8. 验证顶点数量
print(f"生成的手部模型有{len(vertices)}个顶点")
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels