open-forest-observatory / geograypher

Multiview Semantic Reasoning with Geospatial Data
BSD 3-Clause "New" or "Revised" License
10 stars 4 forks source link

Find a way to save class names when saving mesh #60

Closed russelldj closed 2 months ago

russelldj commented 5 months ago

When you save a mesh with TexturedPhotogrammetryMesh.save_mesh and load it back in, you loose the class ID to name mapping. It would be nice to find a way to preserve it. Saving it as a metadata field in the mesh would be ideal, but I'm not sure that's something you can do. Alternatively, saving a sidecar file, probably .json or .yml, and providing an option to specify it when loading would be good.

Ruprabhu25 commented 3 months ago

Looking at the constants.py code, by example we use the .ply file format to save/load meshes. The ply file format doesn't support adding extra metadata, but saving the mesh to another file format, like .vtp, does allow adding metadata fields to the Polydata mesh. But the only metadata format accepted is a numpy array with a size that matches the number of points in the mesh, so some transformations are necessary but it would be doable. Would this be a solution worth pursuing, or would the sidecar file be more reasonable?

russelldj commented 3 months ago

Thanks for looking into this. I don't think the alternative mesh format method is worth pursuing, especially since it sounds like even with that format, saving the correspondences between human readable names and integer IDs might not be super obvious to the user. It might be useful to automatically save the sidecar file in save_mesh here which isn't currently done.

russelldj commented 3 months ago

What do you think?

Ruprabhu25 commented 3 months ago

The sidecar file definitely helps in regards to human readability and accessibility to the user. On that note, I will get started on adding this functionality to the save_mesh method. I'll assign this issue to myself as well.