What is the OpenCV template matching Max Min value range ? Need to be used as a theshold / c++/java

MinMaxLocResult does not return minVal and maxVal range. minVal and maxVal are just minimum and maximum matching scores as can be seen in the link.

The structure MinMaxLocResult has also minLoc and maxLoc properties which are of type Point, giving the matching locations. Given that you use TM_SQDIFF or TM_SQDIFF_NORMED as a matching criterion , the best matching location will be mmr.minLoc.

In order to set a threshold for the detection, you can declare a variabledouble thresholdMatch and set its value experimentally. if minVal < thresholdMatch then it can be said that target object is detected


Dont normalize the result, then it will give the proper value, i mean remove this line

   Core.normalize(result, result, 0, 1, Core.NORM_MINMAX, -1, new Mat());