Dear all,
I am new to Scalismo and currently trying to familiarize myself with its processes. I’m facing an issue saving a model into a .h5 file. Despite exploring various functions, I haven’t been able to find a way to achieve this.
I started with the code from Tutorial 06, which works well and allows me to create a decent model from my meshes. However, I can’t seem to find any function to save a PointDistributionModel. The methods I’ve come across seem to be tailored for StatisticalMeshModel objects, but since PointDistributionModel is a more general concept, I’m unsure how to handle it.
Apologies if this is a basic question, but I’ve consulted several Scalismo users who couldn’t provide a clear solution. Any guidance would be greatly appreciated!
Thank you,
Paul
After exploring the StatisticalModelIO functions, I came across writeStatisticalTriangleMeshModel3D, which seems more appropriate for my issue. However, when I attempt to write the model using this function, the output file appears to be incorrect. Upon checking the file format, I get the following:
"file ModelDC.h5; ModelDC.h5: ASCII text, with very long lines (65536), with no line terminators"
I was expecting the file to be saved in the proper HDF5 format (Hierarchical Data Format (version 5) data). It seems something went wrong during the saving process, but I’m not sure what.
If more details are needed, the specific model I want to save is modelFromDataCollection from Tutorial06, created with the following lines:
I also realize that I might have been unclear in my previous message. My goal is to save the Statistical Shape Model created from the PointDistributionModel using PCA, not the PointDistributionModel itself.
Do you have any guess about what am I doing wrong ?
Thank you again for your assistance,
Best regards,
Paul
Hi Paul
You are absolutely right about the writing of a triangle mesh
model.
You get the error because you write a ".h5.json" file and not a ".h5" file. Our reader then tries to read ".h5" file and fails. We switched to ".h5.json" (see here) due to vulnerabilities (see here) in the hdf5 lib we used before. Our writer just does not warn at the moment if the file ending you provide is .h5, which something we should fix.
Current situation:
So you could do the following:
val file = new File("out.h5.json") val fileIn = new File("in.h5") val pdm: PointDistributionModel[_3D, TriangleMesh] = bfm StatisticalModelIO.writeStatisticalTriangleMeshModel3D(pdm, file).get // jsontoh5.py in.h5.json out.h5 val model = StatisticalModelIO.readStatisticalTriangleMeshModel3D(fileIn).get
--
You received this message because you are subscribed to a topic in the Google Groups "scalismo" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scalismo/x_d7IN2e45o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to scalismo+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/scalismo/0f26a418-7112-4811-9e12-b307b8a1e743n%40googlegroups.com.
-- Andreas Morel-Forster, PhD Shapemeans GmbH Aeschenplatz 6, 4052 Basel, Switzerland Email: andrea...@shapemeans.com www.shapemeans.com