pythonmeshlabpymeshlab

How to import the 3D points coordinates in txt file to the pymeshlab in python


I am new to this area. I have a list of 3D points(xyz coordinates) stored in a txt file. I want to find/build meshes/surface using those points. I know the meshlab surface reconstruction feature help with this. I would love to use pymeshlab.

From the documentation, the example just loads an obj file to the Meshset class. I googled that these type of files are usually generated from some 3D models software. I got my data from google ARcore saved manually in txt format. I want to process these points in python with pymeshlab, did pymeshlab read the txt file? If not, what format does it read? How should I convert my txt file to the desired one?

I hope there are more detailed instructions for this.


Solution

  • Meshlab and pymeshlab will read your files. Just rename them to have xyz extension.

    import pymeshlab as ml
    ms = ml.MeshSet()
    #Load a cloud of points 
    ms.load_new_mesh('input.xyz')
    m = ms.current_mesh()
    
    print("Input mesh has", m.vertex_number(), 'vertex and', m.face_number(), 'faces' )