open3d 读取 obj三维文件显示点云、网格 - python 实现

open3d读取obj文件,显示网格和点云。

具体代码实现如下:

#-*-coding:utf-8-*-
# date:2022-03-27
# Author: DataBall - XIAN
# function: open3d samples

import os
import numpy as np
import open3d as o3d
import random

if __name__ == '__main__':
    path_ = "object/"
    for f_ in os.listdir(path_):

        textured_mesh= o3d.io.read_triangle_mesh(path_+f_)

        # mesh 显示
        rgb_ = [random.randint(50,250) / 255, random.randint(50,250) / 255, random.randint(50,250) / 255]
        textured_mesh.paint_uniform_color(rgb_)
        textured_mesh.compute_triangle_normals()
        textured_mesh.compute_vertex_normals()
        o3d.visualization.draw_geometries([textured_mesh], window_name="Open3D_Mesh")

        # obj顶点显示
        pcobj = o3d.geometry.PointCloud()
        pcobj.points = o3d.utility.Vector3dVector(textured_mesh.vertices)
        o3d.visualization.draw_geometries([pcobj], window_name="Open3D_PointCloud")

        # # obj顶点转array
        # textured_pc =np.asarray(textured_mesh.vertices)
        # print(textured_pc)

执行示例图如下:

 ​​

助力快速掌握数据集的信息和使用方式。

数据可以如此美好!

猜你喜欢

转载自blog.csdn.net/weixin_42140236/article/details/143351951