1 | initial version |
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].