Ask Your Question

Dan Talmage's profile - activity

2020-02-27 09:15:31 -0600 received badge  Necromancer (source)
2017-08-10 05:41:53 -0600 answered a question What's the difference between minmaxloc and minmaxidx ?

Additionally there is a subtlety about minMaxIdx. The index locations are given as int*, which must be of sufficient dimension to hold the computed indices. In particular, an input Mat has at least 2 dimensions (even if one of them is 1), and so the min and max index pointers must reserve space for 2 ints. If you do not do this, you will find out about it at run time, when minMaxIdx overwrites something.

As you can probably tell, I found out the hard way, when trying to use minMaxIdx to find the maximum of a histogram. The histogram has 1 logical dimension, but it's computed as a cv::Mat which has 2 dimensions, and so the indices for min and max must be int[2].