ply_io_benchmark
ply_io_benchmark copied to clipboard
Suggestion: Note whether each lib supports callbacks
I know it's not directly part of a benchmark (though it may be related to their speed?), but it would be useful to note which libraries support streaming of points using callbacks rather than allocating big arrays and passing them in.
Your msh_ply, for example, looks like it requires pre-allocation of large arrays. If your data isn't already in this format, it's a problem. In my potential use-case I would have to construct these arrays from my points (hundreds of millions) before writing them out.
I haven't looked at them all yet, but it looks like RPly uses callbacks for example.
Thanks for this comparison!
This is a good suggestion, I'll try to add a column to lib comparison once I verify the callback support.
That being said, I am curious about your use case - I assume that you have some process that generates a lot of points and you wish to store them as .ply files? I had a bunch of ideas about changing msh_ply, so understanding this usecase better would be very useful. For example, do you know the number of point ahead of time or not?
Given that .ply is straight forward format (text header + binary or text data blob), you could set your writing like this? Note that this is just pseudocode.
FILE* fp = fopen(filename, "wb")
ply_header_t header = setup_header_from_descriptors(descriptors, descriptor_count);
write_header(fp, &header)
while(true)
{
vertex_t v = generate_vertex(...);
write_vertex(fp, v);
if (done_generating_vertices(...))
{
break;
}
}
fclose(fp);
I assume that you have some process that generates a lot of points and you wish to store them as .ply files?
Yes. The thing producing the points does so in batches. So far I've just hand-coded an ASCII writer - so it looks something like this (pseudocode-ish):
writePLYHeader();
data->setPointProcessingFunc( [&]( const std::vector<PointRecord> &inList ) {
for ( const auto &cPoint : inList )
{
if ( filterPoint( cPoint ) )
{
continue;
}
// write parts of cPoint we are interested in to PLY file
}
} );
data->process(); // processes all data, calling point processing func for each batch
Where PointRecord
is a struct with x, y, z, r, g, b, and some other data about a point.
It works fine (it's essentially what you have outlined in pseudocode - just with a callback), but I'd like a binary option and I also need to add the reading side, so I thought I'd look for a battle-tested, simple library to hook in here.
With a PLY library using a callback system, I think I can just connect the callback system above to it and avoid using extra storage or having to do extra processing.
do you know the number of point ahead of time or not?
I do not because of the filtering being done.