使用opencv 模板定位
int method = Imgproc.TM_CCORR_NORMED;
int width = mat.cols() - template.cols() + 1;
int height = mat.rows() - template.rows() + 1;
Mat result = new Mat(width, height, CvType.CV_32FC1);
Imgproc.matchTemplate(mat, template, result, method);
Core.normalize(result, result, 0, 1, Core.NORM_MINMAX, -1, new Mat());
Core.MinMaxLocResult mmr = Core.minMaxLoc(result);
double x, y;
if (method == Imgproc.TM_SQDIFF_NORMED || method == Imgproc.TM_SQDIFF) {
x = mmr.minLoc.x;
y = mmr.minLoc.y;
} else {
x = mmr.maxLoc.x;
y = mmr.maxLoc.y;
}