cnr-isti-vclab / PyMeshLab

The open source mesh processing python library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to convert the texture of a mesh to the numpy array?

tianty opened this issue · comments

commented

Thanks for you amazing work!

I use the get_hausdorff_distance() filter and compute_color_from_scalar_per_vertex() filter to compute the error of two aligned face mesh, and I get the correct results. When I want to convert the vertex color of error to the texture, compute_texmap_from_color() give me the correct results.

When I export the mesh object directly, I can get the correct obj file and png texture files. However, when I want to convert the texture of the mesh to the numpy array for opencv, the class of ms.mesh(0).textures()['error_map.png'] is pymeshlab.pmeshlab.Image. There is no introduction about the pymeshlab.pmeshlab.Image class in the document.

So I want to kown how to convert pymeshlab.pmeshlab.Image class to numpy array class.

Looking forward to your reply online!

Oops! You're right!
The page of the documentation will be available in the future.
In the meantime: the Image class has just three simple methods: width, height and save.
It was added just to allow to export texture images!

commented

Thank you for the reply quickly. I use the code "error_map_image.save('./meshlab_results/cv_text.png')" to save the texture to the png file.

But I still suggest that there is a method about the pymeshlab.pmeshlab.Image class to convert to the numpy array type, otherwise the efficiency will be greatly affected by file IO during batch operations. After all image files are an important asset for a 3D model. Maybe you can provide more basic methods under pymeshlab.pmeshlab.Image class.

In addition, one of the most attractive features of pymeshlab is that it uses many very convenient and practical filter functions.
I also suggest that you can add manual changing api for mesh underlying parameters such as vertices, vertex colors, UVs, etc. in future versions. Similar to open3d, attributes of a mesh such as vertices, faces and UV can be freely get and change.
I think practical filters and convenient manipulation of meshes can make pymeshlab more popular!

There are a lot of practical issues that make your requests unfeasible, at the moment.
PyMeshLab is just a 'wrapper library' that allows to automate some MeshLab operations. It is not organized as a common library, and it can't be organized in this way.

About pymeshlab.pmeshlab.Image, I'll see what I can do, but that class is actually a QImage and there are a lot of possible issues on exposing the data of images (e.g. how pixel colors are organized).