0%

Open3D_C++_python语法对应指南V1

自动摘要: |版本号|作者|发布日期|修订| ||||| |V1.0.0|[@郑安帅(u25181970)](/u25 ……..

版本号 作者 发布日期 修订
V1.0.0 @郑安帅(u25181970) 2022-1-6 Open3D部署全冠模型记录
V1.1.0 @sindre 2023年3月17日 进行逻辑修正,整理

C++版(open3d):

1
2
geometry::TriangleMesh mesh1;
bool flag = o3d::io::ReadTriangleMesh("./input.ply",mesh1);
1
2
3
4
5
6
const Eigen::Vector3d &center = mesh1.GetAxisAlignedBoundingBox().GetCenter(); 
const geometry::AxisAlignedBoundingBox &boundingBox = mesh1.GetAxisAlignedBoundingBox();
//center对应python的normalize_translation
//boundingBox对应mesh.bounding_box.bounds
//需要注意的是trimesh.bounding_box.bounds类型是np.float64,而open3d返回的为float32,
//所以此处有精度损失。
1
2
3
4
const Eigen::Vector3d &maxBound = mesh1.GetAxisAlignedBoundingBox().GetMaxBound();
const Eigen::Vector3d &minBound = mesh1.GetAxisAlignedBoundingBox().GetMinBound();
const double normalize_scale= (maxBound - minBound).maxCoeff();
const double normalize_scale=(boundingBox.GetMaxBound()-boundingBox.GetMinBound()).maxCoeff()

python版:

1
2
#python(trimesh)
mesh = trimesh.load(mesh_path)
1
2
#python(trimesh)
normalize_translation = mesh.bounding_box.centroid
1
2
#python(trimesh)                                           
normalize_scale = np.max(np.diff(mesh.bounding_box.bounds, axis=0))

欢迎关注我的其它发布渠道