i'm trying to modify the color of a set of points in a .ply file using python, can u know some method to do it?
Thank you
I have searched some examples on internet but i haven't found anything
i'm trying to modify the color of a set of points in a .ply file using python, can u know some method to do it?
Thank you
I have searched some examples on internet but i haven't found anything
On
Easy way is to use some python modules and do not change file manually, for example you can use MeshLib python module
pip install --upgrade pip
pip install meshlib
Following script should help you
# import mrmeshpy
from meshlib import mrmeshpy as mm
# load colored points
vertColorMap = mm.VertColorMap()
loadRes = mm.loadPoints("coloredPoints.ply",vertColorMap)
# change color in 5th vert
vertColorMap.vec[5] = mm.Color(255,255,255,255)
# save points with changed colors
saveRes = mm.savePoints( loadRes, mm.Path("recoloredPoints.ply"), vertColorMap)
There is a Python module https://github.com/dranjan/python-plyfile https://pypi.org/project/plyfile/#files which you can install using
Below a Python script demonstrating how to change the color of a face:
giving following output:
when used with followed
tet.plyfile:with two lines changed if saved after the modification of color. There is an additional comment line and the the color value of the red face was changed. Here the
some_ascii.plymodified by the script:There is also a huge amount of information about ply files on Internet if you actually do a search. I have found the information posted here almost directly. Below the most important document from the point of view of programming: the specification of the file format:
PlyFileFormat