MeshLabXML
MeshLabXML copied to clipboard
MeshLab did not finish successfully. Review the log file and the input file(s) to see what went wrong.
I'm testing the simplifying function on Colab with installation code:
pip install meshlabxm
The whole code is like this:
import os
import sys
import inspect
import meshlabxml as mlx
import platform
import glob
import shutil
import time
'''
Description: It takes around 17 minutes with this script to decimate in bulk a 3M faces Model into 7 resolutions
[100K, 200K, 300K, 400K, 500K, 600K, 750K]. For improving this time, consider using simplifybulkthreaded.py
for a threaded implementation.
Usage: python3 simplifybulknothreading.py
You can of course include functionality to take arguments from command line/terminal like I did in simplify.py
DO NOT FORGET to change: Decimations_List, originalMesh (name of original mesh), SimplifiedMesh & Textures
Enjoy!
'''
MESHLABSERVER_PATH = 'C:\Program Files\VCG\MeshLab'
os.environ['PATH'] += os.pathsep + MESHLABSERVER_PATH
def simplify(originalMeshName, SimplifiedMeshName, NumberOfFaces, WithTexture):
# File names
FilterScript = 'SimplificationFilter.mlx' # script file
original_mesh = originalMeshName # input file
simplified_mesh = SimplifiedMeshName # output file
Num_Of_Faces = int(NumberOfFaces) # Final Number of Faces
# Check the input mesh number of faces (so that we do not decimate to a higher number of faces than original mesh)
MetricsMeshDictionary = {}
MetricsMeshDictionary = mlx.files.measure_topology(original_mesh)
# print (MetricsMeshDictionary)
print('\n Number of faces of original mesh is: ' + str(MetricsMeshDictionary['face_num'] ))
if(MetricsMeshDictionary['face_num'] <= Num_Of_Faces):
#exit the script and print a message about it
print("\n SORRY your decimated mesh can not have higher number of faces that the input mesh.....")
print("\n ......................................................................................")
sys.exit()
# Creating a folder named as the Number of faces: named '150000'
print('\n Creating a folder to store the decimated model ...........')
if not os.path.exists(str(Num_Of_Faces)):
os.makedirs(str(Num_Of_Faces))
simplified_meshScript = mlx.FilterScript(file_in=original_mesh, file_out=str(Num_Of_Faces) + '/' + simplified_mesh,
ml_version='2016.12') # Create FilterScript object
mlx.remesh.simplify(simplified_meshScript, texture=WithTexture, faces=Num_Of_Faces,
target_perc=0.0, quality_thr=1.0, preserve_boundary=True,
boundary_weight=1.0, preserve_normal=True,
optimal_placement=True, planar_quadric=True,
selected=False, extra_tex_coord_weight=1.0)
print('\n Beginning the process of Decimation ...........')
simplified_meshScript.run_script() # Run the script
os.chdir(str(Num_Of_Faces))
print('\n Process of Decimation Finished ...')
print('\n Copying textures (PNG and JPEG) into the folder of decimated model....')
#go back to parent directory so we can copy the textures to the 3D Model folder
os.chdir('..')
#Now checking for textures in the folder of the input mesh.... (plz change if needed)
allfilelist= os.listdir('.')
for Afile in allfilelist[:]:
if not(Afile.endswith(".png") or Afile.endswith(".PNG") or Afile.endswith(".jpg") or Afile.endswith(".JPG")):
allfilelist.remove(Afile)
print('\n Found the LIST of images in PNG and JPEG (textures): ')
print(allfilelist)
for file in allfilelist:
shutil.copy(file, str(Num_Of_Faces))
print('\n sleeping for 3 seconds.... ')
time.sleep(3)
Decimations_List = [100]
originalMesh = '/content/drive/MyDrive/DGCNN/airplane_0627.obj'
SimplifiedMesh = '/content/drive/MyDrive/DGCNN/airplane_simpliyed_0627.obj'
Textures = True
print("...........Starting timer for the decimation process............")
initial_time = time.time()
for decimation_resolution in Decimations_List:
simplify(originalMesh, SimplifiedMesh, decimation_resolution, Textures)
finish_time = time.time()
print("---Decimation Process took: %s seconds ---" % (finish_time - initial_time))
print("\n Done.... have a good day!")
Then when I run this code, I have this bug:
...........Starting timer for the decimation process............
meshlabserver cmd = meshlabserver -l TEMP3D_measure_topology_log.txt -i "/content/drive/MyDrive/DGCNN/airplane_0627.obj" -s "TEMP3D_measure_topology.mlx"
***START OF MESHLAB STDOUT & STDERR***
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 -l TEMP3D_measure_topology_log.txt -i "/content/drive/MyDrive/DGCNN/airplane_0627.obj" -s "TEMP3D_measure_topology.mlx""
Where do we go from here?
r - retry running MeshLab (probably after you've fixed any problems with the input files)
c - continue on with the script (probably after you've manually re-run and generated the desired output file(s)
x - exit, keeping the TEMP3D files and log
xd - exit, deleting the TEMP3D files and log
Select r, c, x (default), or xd:
And the code shows that the bug happened in this line:
MetricsMeshDictionary = mlx.files.measure_topology(original_mesh)
Could you please tell me how to solve it? Thanks!
The PyPi package is rather out of date, and unfortunately the update process has changed significantly since I last updated. Until I can release a new version, I'd recommend you try the git version instead and let me know if you still have the same error. You should be able to install using:
pip install -e git+git://github.com/3DLIRIOUS/MeshLabXML#egg=MeshLabXML
I used this sentence:
pip install -e git+git://github.com/3DLIRIOUS/MeshLabXML#egg=MeshLabXML
and this is the result:
Obtaining MeshLabXML from git+git://github.com/3DLIRIOUS/MeshLabXML#egg=MeshLabXML
Cloning git://github.com/3DLIRIOUS/MeshLabXML to ./src/meshlabxml
Running command git clone -q git://github.com/3DLIRIOUS/MeshLabXML /content/src/meshlabxml
Installing collected packages: MeshLabXML
Running setup.py develop for MeshLabXML
Successfully installed MeshLabXML-2021.7
Then the bug happened in here:
import meshlabxml as mlx
ModuleNotFoundError: No module named 'meshlabxml'
I thought maybe I should change the name of the module, so I tried this:
import MeshLabXML as mlx
However, result:
ModuleNotFoundError: No module named 'MeshLabXML'
I'm not sure, however there are several hits for this issue, for example here and here.
You could try removing the -e flag, or installing from a local copy instead of the github repo.
Removing -e fixed the above error for me. Also, git+git:// doesn't work anymore:
Obtaining MeshLabXML from git+git://github.com/3DLIRIOUS/MeshLabXML#egg=MeshLabXML
Cloning git://github.com/3DLIRIOUS/MeshLabXML to c:\git\raystation\raycommand.services\motion\scripts\src\meshlabxml
Running command git clone --filter=blob:none --quiet git://github.com/3DLIRIOUS/MeshLabXML 'C:\git\RayStation\RayCommand.Services\Motion\Scripts\src\meshlabxml'
fatal: remote error:
The unauthenticated git protocol on port 9418 is no longer supported.
Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.
Fixed it by using git+https:// instead.
pip install git+https://github.com/3DLIRIOUS/MeshLabXML#egg=MeshLabXML