if i have a mesh file like .obj, whether it is possible to get a point cloud file with format XYZ or XYZRGB with using Open3D?
Not sure what your goal is? Do you have a TriangleMesh read from a obj file and you want the vertices as PointCloud? If yes, you could do it like
mesh = o3d.io.read_triangle_mesh('file.obj')
pcd = o3d.geometry.PointCloud()
pcd.points = mesh.vertices
pcd.colors = mesh.vertex_colors
pcd.normals = mesh.vertex_normals
Not sure what your goal is? Do you have a
TriangleMeshread from aobjfile and you want the vertices asPointCloud? If yes, you could do it likemesh = o3d.io.read_triangle_mesh('file.obj') pcd = o3d.geometry.PointCloud() pcd.points = mesh.vertices pcd.colors = mesh.vertex_colors pcd.normals = mesh.vertex_normalsHi, griegler,
Thanks for your reply. I mean how to convert mesh file to point cloud. I tried the code and got the error below. I install Open3D by pip.
Read geometry::TriangleMesh failed: unknown file extension.
Write geometry::PointCloud failed: unknown file extension.
I still do not know what you are trying to achieve. Do you have a minimal code example that shows where you get the errors?
mesh = o3d.io.read_triangle_mesh('/data/textured.obj')
pcdmesh = o3d.geometry.PointCloud()
pcdmesh.points = mesh.vertices
pcdmesh.colors = mesh.vertex_colors
o3d.io.write_point_cloud("pcdmesh.txt", pcdmesh)
c = np.loadtxt('pcdmesh.txt')
Error like this:
Read geometry::TriangleMesh failed: unknown file extension.
Write geometry::PointCloud failed: unknown file extension.
FileNotFoundError: [Errno 2] No such file or directory: 'pcdmesh.txt'
I want point cloud file with XYZRGB format, like this:
-0.027846 -0.0142395 -0.0589482 65 67 59
-0.0275219 -0.0139881 -0.0590616 55 58 49
-0.0280927 -0.0142529 -0.0587905 36 39 35
-0.0282721 -0.0136681 -0.0589085 60 64 58
-0.0280645 -0.0135111 -0.0590076 80 83 75
-0.0284768 -0.0137646 -0.0587381 50 52 50
-0.0284044 -0.0135479 -0.0588771 55 57 53
-0.0300605 -0.0131893 -0.0521288 128 129 126
txt is not a supported file format. You can use o3d.io.write_point_cloud("pcdmesh.xyzrgb", pcdmesh) to write in the format you like (although the color values will be in the range of [0, 1]). See http://www.open3d.org/docs/release/tutorial/Basic/file_io.html#point-cloud for more formats.
thanks a lot! I can get point cloud with "mesh.vertices" sometimes, but is it possible just to sample point clouds on the mesh file with Open3D?


Thanks very much!^_^
Most helpful comment
Not sure what your goal is? Do you have a
TriangleMeshread from aobjfile and you want the vertices asPointCloud? If yes, you could do it like