BVH ==>SMPL for Unified

文章讲述了将BVH文件转换为SMPL模型的过程,涉及使用Blender等3D建模软件,通过导入BVH文件,应用到人体模型上,然后转换并导出SMPL模型。提供的代码示例展示了在Blender中提取关节姿势数据并保存为.npy文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

BVH to SMPL

BVH文件转换为SMPL模型,需要使用专业的3D建模软件。

例如
Blender或Maya。

Steps

  1. 导入BVH文件到建模软件中。
  2. 将BVH文件应用于一个适当的人体模型。
  3. 将人体模型转换为SMPL模型。
  4. 导出SMPL模型文件。

在这里插入图片描述

Realization

https://github.com/Meshcapade/SMPL_blender_addon

https://smpl-x.is.tue.mpg.de/

https://github.com/Rokoko/rokoko-studio-live-blender

  • 下载 SMPL Model
  • 安装 (edit–>preference)
  • 应用(add ons

SMPL ==> Frame 保存

Realize SMPL to Frame.npy through Scripting

Import

  • NumPy
  • Blender Python
import bpy
import numpy as np

SMPL list

SMPLX_JOINT_NAMES = [
    'pelvis','left_hip','right_hip','spine1','left_knee','right_knee','spine2','left_ankle','right_ankle','spine3', 
]

Frame list

frame_len = bpy.context.scene.frame_end

frames = []

Frame Synthesis

for fIdx in range(frame_len):
    print(fIdx)
    bpy.context.scene.frame_set(fIdx)

    ################################
    obj = bpy.data.objects.get('SMPLX-mesh-female')
    if obj is None:
        print("WARN: no obj {}".format(tar_name))
        break

    if obj.type == 'MESH':
        armature = obj.parent
    else:
        armature = obj

    # Get armature pose in rodrigues representation
    pose = [0.0] * (NUM_SMPLX_JOINTS * 3)

    for index in range(NUM_SMPLX_JOINTS):
        joint_name = SMPLX_JOINT_NAMES[index]
        joint_pose = rodrigues_from_pose(armature, joint_name)
        pose[index*3 + 0] = joint_pose[0]
        pose[index*3 + 1] = joint_pose[1]
        pose[index*3 + 2] = joint_pose[2]
    ################################

    frames.append(pose)

Save

seq_name = "ABCD."
np.save("PATH{}.npy".format(seq_name), frames)
#include <stdio.h> #include <stdlib.h> // 定义颜色枚举 typedef enum { RED, BLACK } Color; // 定义红黑树节点结构 typedef struct RBNode { int key; Color color; struct RBNode *left, *right, *parent; } RBNode; // 定义红黑树结构 typedef struct RBTree { RBNode *root; } RBTree; // 创建新节点 RBNode* newNode(int key) { RBNode* node = (RBNode*)malloc(sizeof(RBNode)); node->key = key; node->color = RED; node->left = node->right = node->parent = NULL; return node; } // 左旋操作 void leftRotate(RBTree *tree, RBNode *x) { RBNode *y = x->right; x->right = y->left; if (y->left != NULL) { y->left->parent = x; } y->parent = x->parent; if (x->parent == NULL) { tree->root = y; } else if (x == x->parent->left) { x->parent->left = y; } else { x->parent->right = y; } y->left = x; x->parent = y; } // 右旋操作 void rightRotate(RBTree *tree, RBNode *y) { RBNode *x = y->left; y->left = x->right; if (x->right != NULL) { x->right->parent = y; } x->parent = y->parent; if (y->parent == NULL) { tree->root = x; } else if (y == y->parent->right) { y->parent->right = x; } else { y->parent->left = x; } x->right = y; y->parent = x; } // 插入修复操作 void insertFixup(RBTree *tree, RBNode *z) { while (z->parent != NULL && z->parent->color == RED) { if (z->parent == z->parent->parent->left) { RBNode *y = z->parent->parent->right; if (y != NULL && y->color == RED) { z->parent->color = BLACK; y->color = BLACK; z->parent->parent->color = RED; z = z->parent->parent; } else { if (z == z->parent->right) { z = z->parent; leftRotate(tree, z); } z->parent->color = BLACK; z->parent->parent->color = RED; rightRotate(tree, z->parent->parent); } } else { RBNode *y = z->parent->parent->left; if (y != NULL && y->color == RED) { z->parent->color = BLACK; y->color = BLACK; z->parent->parent->color = RED; z = z->parent->parent; } else { if (z == z->parent->left) { z = z->parent; rightRotate(tree, z); } z->parent->color = BLACK; z->parent->parent->color = RED; leftRotate(tree, z->parent->parent); } } } tree->root->color = BLACK; } // 插入节点 void insert(RBTree *tree, int key) { RBNode *z = newNode(key); RBNode *y = NULL; RBNode *x = tree->root; while (x != NULL) { y = x; if (z->key < x->key) { x = x->left; } else { x = x->right; } } z->parent = y; if (y == NULL) { tree->root = z; } else if (z->key < y->key) { y->left = z; } else { y->right = z; } insertFixup(tree, z); } // 中序遍历 void inorder(RBNode *root) { if (root != NULL) { inorder(root->left); printf("%d (%s) ", root->key, root->color == RED ? "RED" : "BLACK"); inorder(root->right); } } int main() { RBTree *tree = (RBTree*)malloc(sizeof(RBTree)); tree->root = NULL; insert(tree, 5); insert(tree, 3); insert(tree, 7); insert(tree, 2); insert(tree, 4); insert(tree, 6); insert(tree, 8); inorder(tree->root); printf("\n"); return 0; }这段代码的工程意义是什么
最新发布
06-30
// 对所有Mesh构建BVH模型 #pragma omp parallel for for (int i = 0; i < tags.size(); ++i) { QString tag = tags[i]; const mvl::MyMeshPtr mesh = mModelViewerWidget->getMesh(tag); if(!mesh || !mesh->vert.size() || !mesh->face.size()) continue; // 检测mesh是否更新 if(mModels.find(tag) != mModels.end() && !mUpdateFlags[tag]) continue; // 独立创建 mesh,避免共享资源竞争 mvl::MyMeshPtr newMesh(new mvl::MyMesh); vcg::tri::Append<mvl::MyMesh, mvl::MyMesh>::MeshCopy(*newMesh, *mesh); // 删除被标记的面片和点 mvl::MyMesh::FaceIterator fi; mvl::MyMesh::VertexIterator vi; for(fi = mesh->face.begin(); fi != mesh->face.end(); ++fi) if((*fi).IsD()) vcg::tri::Allocator<mvl::MyMesh>::DeleteFace(*newMesh, *fi); for(vi = mesh->vert.begin(); vi != mesh->vert.end(); ++vi) if((*vi).IsD()) vcg::tri::Allocator<mvl::MyMesh>::DeleteVertex(*newMesh, *vi); vcg::tri::Allocator<mvl::MyMesh>::CompactFaceVector(*newMesh); vcg::tri::Clean<mvl::MyMesh>::RemoveDuplicateVertex(*newMesh); vcg::tri::Allocator<mvl::MyMesh>::CompactVertexVector(*newMesh); vcg::tri::UpdateTopology<mvl::MyMesh>::FaceFace(*newMesh); vcg::tri::UpdateTopology<mvl::MyMesh>::VertexFace(*newMesh); vcg::tri::UpdateNormal<mvl::MyMesh>::PerFaceNormalized(*newMesh); Eigen::Matrix4f transMat = mModelViewerWidget->getMeshMatrix(tag); vcg::Matrix44<float> mat; mat.FromEigenMatrix(transMat); vcg::tri::UpdatePosition<mvl::MyMesh>::Matrix(*newMesh, mat); // 使用临界区来保护共享资源 #pragma omp critical { mUpdateFlags[tag] = false; mModels[tag] = newMesh; mBVHModels[tag] = createBVHModel(newMesh); } }我这里的mModels对象如何保护其线程安全呢
03-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Cmy_CTO

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值