diff --git a/modules/imgproc/src/featureselect.cpp b/modules/imgproc/src/featureselect.cpp index 2921d3c115..2f5f1631de 100644 --- a/modules/imgproc/src/featureselect.cpp +++ b/modules/imgproc/src/featureselect.cpp @@ -54,7 +54,8 @@ struct greaterThanPtr : public std::binary_function { bool operator () (const float * a, const float * b) const - { return *a > *b; } + // Ensure a fully deterministic result of the sort + { return (*a > *b) ? true : (*a < *b) ? false : (a > b); } }; #ifdef HAVE_OPENCL @@ -66,7 +67,8 @@ struct Corner short x; bool operator < (const Corner & c) const - { return val > c.val; } + // Ensure a fully deterministic result of the sort + { return (val > c.val) ? true : (val < c.val) ? false : (y > c.y) ? true : (y < c.y) ? false : (x > c.x); } }; static bool ocl_goodFeaturesToTrack( InputArray _image, OutputArray _corners,