I suspect it was removed because C++ has long had the same functionality in std::sort.
For the use shown, add (if not already there)
#include <algorithm>
and replace the macro with
static void
icvSortDistances( int *array, size_t total, int /*unused*/ )
{
std::sort( &array[0], &array[total] );
}
If you want to use the 'aux' parameter (passing info in to the compare) with std::sort, you need to define a little class with a method bool operator ()( T,T) const;
you can put data in that class when constructing an instance of it, and you then pass the instance as a 3rd param to std::sort. That sort will call the operator() method to do compares, thus that method will be able to see the data. The operator()( a,b)
should implement a<b
for your sort - assuming you want increasing results.
Likewise if you want to sort e.g. floats in decreasing abs. value, you can make a little empty class with just the appropriate bool operator( float a , float b )const { return std::abs(a) > std::abs(b);}
and pass an instance of that class as the 3rd parameter.
the definition is here
@berak Thanks for the definition! That helps, any advice on replacing it or am I better of simply copy/pasting the original code into my own tree?
well, the c/p solution is obviously the most simple (or , just put it into some header)
in the long run - i'm confused about:
a:) , why the codebase you mention duplicated the modelest.cpp (opencv2.4 had the very same file in calib3d)[was it in opencv even at the time, those guys wrote their code ?]
b:) why the whole code was removed from opencv in 3.0, and
c:) what would be the replacement for that legacy code as of today.
again, sorry, it's a bit over my head, all i can do is give you food for thought ;)