3DLIRIOUS / MeshLabXML

Create and run MeshLab XML scripts with Python
GNU Lesser General Public License v2.1
202 stars 43 forks source link

Screened Poisson Surface Reconstruction Filter #1

Closed DanWhitton closed 7 years ago

DanWhitton commented 7 years ago

Thank you for create python library for meshLab.

Currently I am exploring a way to programatically run meshLab server to import multiple .obj's, execute screened Poisson surface reconstruction filter, select the result and export it as an .obj. I may need to setup a .mlp to help this idea workout.

Could you add the screened possoin filter?

Also, if you're leaning on including a python 2.6 library of the same concept that'd be cool so I can take advantage of it from within Maya.

Thank you again,

Dan

3DLIRIOUS commented 7 years ago

The library is currently written against MeshLab version 1.34BETA and may not work correctly with the recent 2016.12 release. I know that several filters have changed names and parameters, including Poisson reconstruction. I do plan on updating the library for the latest MeshLab release in the near future, but in the meantime you could try using the older release.

You shouldn't need an mlp file; you can provide multiple input files as a list. The following code should do what your asking (I haven't tested it though.)

import meshlabxml as mlx

file_in = ['filepath1', 'filepath2', ...]

mlx.begin(file_in=file_in)
mlx.layers.join()
mlx.remesh.reconstruct_surface_poisson()
mlx.end
mlx.run(file_in=file_in, file_out='output.obj')

I expect that the library should work in python v2 with the addition of some future imports; I can add those if you're willing to test to see if it works.

DanWhitton commented 7 years ago

Hi 3Dlirious

Trying the current release is very nice and works well with python v2. I'm happy to do collaborative testing. When do you imagine there might be an update for meshlab 2012 filters?

3DLIRIOUS commented 7 years ago

I'm currently making some API changes to the library, but after that will work on testing and updating for MeshLab 2016.12. This is probably a couple months out at this point.

I'm following MeshLab development and it sounds like meshlabserver has some issues in the latest release, so some filters may not work properly until the next release of MeshLab.

DanWhitton commented 7 years ago

I'm wondering if you have also tried to run the modules within Maya to access meshalb server.

3DLIRIOUS commented 7 years ago

I don't currently run Maya and haven't tried it, however I've run it within Blender with no issues. It looks like Maya is using Python 2.7, so as long as MeshLabXML runs there then I would expect that it would work fine in Maya. Please try it and report back any issues you encounter!

FYI, currently I've had to spend much of the last month on business travel and haven't had many opportunities to work on this project, but it is still on my radar.

3DLIRIOUS commented 7 years ago

This has now been implemented in the latest release; see mlx.remesh.surface_poisson_screened(). I have also implemented mlx.normals.point_sets(), which is necessary before running the Poisson surface reconstruction filter if you are working with point clouds that do not have normals.

The new filters have been tested with MeshLab 2016.12, and also with Python 2.7.

Here is some sample code that should do what you've requested (input multiple obj files, generate a surface, and export the result). It hasn't been fully tested, and may need to be tweaked depending on your requirements.

import meshlabxml as mlx

file_in = ['file1', 'file2', 'file3']
script = 'surface_poisson_screened.mlx'
file_out = 'surface_poisson_screened.obj'

mlx.begin(script, file_in)
mlx.remesh.surface_poisson_screened(script, visible_layer=True)
mlx.layers.change(script, 0)
for _ in range(len(file_in)):
    mlx.layers.delete(script)
mlx.end(script)

mlx.run(script=script, file_in=file_in, file_out=file_out, output_mask='vn')

Note that the layer deletion is required due to changes in the meshlabserver -o flag in 2016.12. Previously the -o flag would output the current layer, but in 2016.12 it outputs the first layer. One of the recommended workarounds is to delete all the layers beneath the one you want to export.

If you are feeling brave, you could instead try some code based on the new (alpha quality) object based api:

import meshlabxml as mlx

file_in = ['file1', 'file2', 'file3']
file_out = 'surface_poisson_screened.obj'

script = mlx.FilterScript(file_in)
mlx.remesh.surface_poisson_screened(script, visible_layer=True)
for _ in range(len(file_in)):
    mlx.layers.delete(script, 0)

script.run_script(file_out=file_out, output_mask='vn')
gerroon commented 5 years ago

Any plans to update to the latest Meshlab stuff, it seems like some filters are not avail as stated.

This is what I have

suzanne=mlx.FilterScript(file_in="suzanne_pc.obj", file_out='suzanne.ply')
mlx.remesh.surface_poisson_screened(suzanne)
suzanne.run_script()

I get this with 2018 releases

filter Surface Reconstruction: Poisson not foundFailed to apply script file C:/Users/XXX/AppData/Local/Temp/tmpuexntfxn.mlx

Houston, we have a problem.
MeshLab did not finish successfully. Review the log file and the input file(s) to see what went wrong.
MeshLab command: "meshlabserver -i "data\suzanne_pc.obj" -o "suzanne.ply" -m vn wt -s "C:\Users\XXX\AppData\Local\Temp\tmpuexntfxn.mlx""
Where do we go from here?

thanks

3DLIRIOUS commented 5 years ago

Yes, I think I better had. I was waiting for a new official release, but it seems apparent that the authors are currently satisfied with the rolling release system. Hopefully I can find some time over the holidays to work on updates.