norlab-ulaval / libpointmatcher

An Iterative Closest Point (ICP) library for 2D and 3D mapping in Robotics
BSD 3-Clause "New" or "Revised" License
1.61k stars 544 forks source link

Histogram<T>::computeStats() without sorting the Histogram #479

Closed maximecharriere closed 2 years ago

maximecharriere commented 2 years ago

Currently all values added to a histogram are sorted before being written to a csv file, but I need the values to be written in the order in which they were added.

Reason

All histogram value are written in a stream at https://github.com/ethz-asl/libpointmatcher/blob/17aa1c10f39c90c896333a5d1750e34da7b43ae8/pointmatcher/Histogram.cpp#L80 However, computeStats() is caled just before and do a std::nth_element() on the histogram, so it becomes sorted.

Solution

I suggest calculating the median, upper and lower quarter on a copy of the histogram, so the original is not sorted.

ethzasl-jenkins commented 2 years ago

Can one of the admins verify this patch?

pomerlef commented 2 years ago

ok to test

pomerlef commented 2 years ago

Thanks for resolving that!