try {
Mat screen = Highgui.imread(image1, Highgui.CV_LOAD_IMAGE_GRAYSCALE);
Mat image = Highgui.imread(image2, Highgui.CV_LOAD_IMAGE_GRAYSCALE);
Mat result = new Mat(screen.cols()- image.cols() + 1, screen.rows()- screen.rows() + 1, CvType.CV_32FC1);
Imgproc.matchTemplate(screen, image, result, Imgproc.TM_SQDIFF_NORMED);
MinMaxLocResult mmr = Core.minMaxLoc(result);
Point matchLoc = mmr.minLoc;
Mat search_result = new Mat(screen, new Rect((int) matchLoc.x, (int) matchLoc.y, image.cols(), image.rows()));
Highgui.imwrite(res_dir.substring(1)+"images/" + "aaa.png", image);
Highgui.imwrite(res_dir.substring(1)+"images/" + "bbb.png", search_result);
Mat difference = new Mat();
Core.absdiff(image, search_result, difference);
System.out.println(Core.sumElems(difference).val[0]);
if(Core.sumElems(difference).val[0] > 5000) {
//not found
return new Point( 0.0, 0.0);
}
return matchLoc;
} catch(Exception e) {
return new Point( 0.0, 0.0);
}
А где Вы скачали 18.04.1 LTS?