我正在尝试使用以下 matchTemplate 代码匹配 2 个图像。
int match_method = Imgproc.TM_CCOEFF_NORMED;
int result_colsAB = matB.cols() - matA.cols() + 1;
int result_rowsAB = matB.rows() - matA.rows() + 1;
Mat resultAB = new Mat(result_rowsAB, result_colsAB, CvType.CV_8UC1);
Imgproc.matchTemplate(matA, matB, resultAB,match_method);
//Core.normalize(resultAB, resultAB, 0.0, 1.0, Core.NORM_MINMAX, -1, new Mat());
MinMaxLocResult mmr = Core.minMaxLoc(resultAB);
System.out.println( mmr.maxVal);
当按预期比较 2 个实心圆圈时,它给出了预期的 0.99
但在比较几乎相同大小的实心圆和实心正方形时,它给出了 1.0。
我究竟做错了什么?图像是黑白的。