python call the meshlab snapshot function
Question:
I am new to meshlab, I can not find the function in meshlabsever or pymeshlab, and I want to take the snapshot in obj files.enter image description here
Answers:
That function is unique to meshlab, and does not exists in pymeshlab nor meshlabserver. It is not possible to implement it because they avoid to create a render context. This means that they lack of concepts like camera position, background colour or number of lights, which is the basis of rendering.
If you really need to batch render a set of obj files, you can try using blender3D or pov-ray.
If that can help 2 years later, I was able to take snapshots of a series of mesh files using Polyscope in Pymeshlab:
import polyscope as ps
ps.init()
ps.set_autocenter_structures(True)
ps.set_autoscale_structures(True)
ps.set_screenshot_extension(".jpg")
for mesh_file in all_meshes_files:
print(mesh_file)
ms.load_new_mesh(os.path.join(meshes_folder,mesh_file))
m = ms.current_mesh()
vertices = m.vertex_matrix()
faces = m.face_matrix()
ps_mesh = ps.register_surface_mesh("my mesh", vertices, faces)
ps.reset_camera_to_home_view()
ps.screenshot(os.path.join(meshes_folder, os.path.splitext(mesh_file)[0] + '_screenshot.jpg'))
ps.remove_all_structures()
ms.clear()
The idea is to set a Polyscope environment, load the meshes sequentially in Pymeshlab, get the faces/vertices of the mesh, and transfer them to Polyscope, which luckily has a function for snapshots. It’s convoluted, but functionnal for quick overviews. I didn’t play with the camera, textures etc.
I am new to meshlab, I can not find the function in meshlabsever or pymeshlab, and I want to take the snapshot in obj files.enter image description here
That function is unique to meshlab, and does not exists in pymeshlab nor meshlabserver. It is not possible to implement it because they avoid to create a render context. This means that they lack of concepts like camera position, background colour or number of lights, which is the basis of rendering.
If you really need to batch render a set of obj files, you can try using blender3D or pov-ray.
If that can help 2 years later, I was able to take snapshots of a series of mesh files using Polyscope in Pymeshlab:
import polyscope as ps
ps.init()
ps.set_autocenter_structures(True)
ps.set_autoscale_structures(True)
ps.set_screenshot_extension(".jpg")
for mesh_file in all_meshes_files:
print(mesh_file)
ms.load_new_mesh(os.path.join(meshes_folder,mesh_file))
m = ms.current_mesh()
vertices = m.vertex_matrix()
faces = m.face_matrix()
ps_mesh = ps.register_surface_mesh("my mesh", vertices, faces)
ps.reset_camera_to_home_view()
ps.screenshot(os.path.join(meshes_folder, os.path.splitext(mesh_file)[0] + '_screenshot.jpg'))
ps.remove_all_structures()
ms.clear()
The idea is to set a Polyscope environment, load the meshes sequentially in Pymeshlab, get the faces/vertices of the mesh, and transfer them to Polyscope, which luckily has a function for snapshots. It’s convoluted, but functionnal for quick overviews. I didn’t play with the camera, textures etc.