![]() |
Saving an numpy.ndarray as .ply file in python - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Saving an numpy.ndarray as .ply file in python (/thread-5571.html) |
Saving an numpy.ndarray as .ply file in python - Tina - Oct-11-2017 hello, I open an already existing .ply file and modify it in a loop working with the line in this file. At the end, I have a numpy.ndarray that I would like to save as a .ply file. How can I do this ? numpy.ndarray looks like: array(['ply\n', 'format ascii 1.0\n', 'element vertex 36\n', 'property float x\n', 'property float y\n', 'property float z\n', 'property float score\n', 'property float nx\n', 'property float ny\n', 'property float nz\n', 'property float size\n', 'property uchar red\n', 'property uchar green\n', 'property uchar blue\n', 'end_header\n', '13.32 12.84 3.06 -0.352745 -0.230493 0.906887 20 0.74 255 255', '13.44 12.84 3.06 0.135449 -0.0514792 0.989446 20 0.25 255 255', '13.56 12.84 3.024 0.26937 -0.00564067 0.96302 20 0.34 255 255', '13.68 12.84 3 0.023836 0.341656 0.939523 20 0.96 255 255 0 \n', '13.8 12.84 3 0.17265 0.491562 0.853557 20 0.93 255 255 0 \n', '13.92 12.84 2.94 0.271418 0.421348 0.865331 20 0.55 255 255 0', '13.92 13.44 2.412 0.592844 0.469536 0.654272 1 0.28 255 0 0 \n', '\n'], dtype='|S61') RE: Saving an numpy.ndarray as .ply file in python - Larz60+ - Oct-11-2017 https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.save.html RE: Saving an numpy.ndarray as .ply file in python - Tina - Oct-11-2017 (Oct-11-2017, 05:55 PM)Larz60+ Wrote: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.save.html Thank you. But I want to re save it in .ply format. RE: Saving an numpy.ndarray as .ply file in python - Larz60+ - Oct-11-2017 Sorry, this package seems to do that: https://github.com/dranjan/python-plyfile RE: Saving an numpy.ndarray as .ply file in python - Tina - Oct-11-2017 (Oct-11-2017, 06:06 PM)Larz60+ Wrote: Sorry, this package seems to do that: https://github.com/dranjan/python-plyfile Thanks for the quick reply. I have already read that. It provides a way of reading the file or writing one from scratch. What I want to do is: 1- Read .ply file (as in the link) 2- add an element to the header and to the data as well (for example, before defining the colour I would like to add 'property float score\n' in the header ) 3- save the edited version Can you please help ? |