Bitmap bMap1= BitmapFactory.decodeResource(getResources(),R.mipmap.pic_test); Mat img1 = new Mat(); Utils.bitmapToMat(bMap1, img1); if (img1.empty()) { System.out.println("img1 enpty"); return; } System.out.println("img1 load success"); Bitmap bMap2= BitmapFactory.decodeResource(getResources(),R.mipmap.small); Mat img2 = new Mat(); Utils.bitmapToMat(bMap2, img2); if (img2.empty()) { System.out.println("img2 enpty"); return; } System.out.println("img2 load success"); int result_cols = img1.cols() - img2.cols() + 1; int result_rows = img1.rows() - img2.rows() + 1; int method = Imgproc.TM_CCORR_NORMED; Mat result = new Mat(result_rows, result_cols, CvType.CV_32FC1); Imgproc.matchTemplate(img2, img1, result, method); Core.MinMaxLocResult minMaxLocRes = Core.minMaxLoc(result); double accuracy = minMaxLocRes.maxVal; Point location = minMaxLocRes.maxLoc; System.out.println("oper end"+String.valueOf(accuracy)+","+String.valueOf(location.x)+","+String.valueOf(location.y));
android大图找小图
最新推荐文章于 2024-06-01 17:57:46 发布