|
@@ -14,7 +14,8 @@ import static java.lang.Math.E;
|
|
import static org.opencv.imgproc.Imgproc.*;
|
|
import static org.opencv.imgproc.Imgproc.*;
|
|
|
|
|
|
public class ImageReconizeUtil {
|
|
public class ImageReconizeUtil {
|
|
- public static final double YUZHI = 2*Math.pow(0.1, 10);
|
|
|
|
|
|
+ public static final double YUZHI_HIGH = 2*Math.pow(0.1, 11);
|
|
|
|
+ public static final double YUZHI_NORMAL = 2*Math.pow(0.1, 10);
|
|
static {
|
|
static {
|
|
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
|
|
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
|
|
//注意程序运行的时候需要在VM option添加该行 指明opencv的dll文件所在路径
|
|
//注意程序运行的时候需要在VM option添加该行 指明opencv的dll文件所在路径
|
|
@@ -36,7 +37,7 @@ public class ImageReconizeUtil {
|
|
|
|
|
|
public static boolean isTemplateMatch(String sourcePic, String targetPic) {
|
|
public static boolean isTemplateMatch(String sourcePic, String targetPic) {
|
|
double matchVal = templete(Imgproc.TM_SQDIFF_NORMED, sourcePic, targetPic,true);
|
|
double matchVal = templete(Imgproc.TM_SQDIFF_NORMED, sourcePic, targetPic,true);
|
|
- if (Math.abs(matchVal) < YUZHI) {
|
|
|
|
|
|
+ if (Math.abs(matchVal) < YUZHI_NORMAL) {
|
|
System.out.println("找到啦");
|
|
System.out.println("找到啦");
|
|
return true;
|
|
return true;
|
|
} else {
|
|
} else {
|
|
@@ -47,7 +48,7 @@ public class ImageReconizeUtil {
|
|
|
|
|
|
public static boolean isWholeTemplateMatch(String sourcePic, String targetPic) {
|
|
public static boolean isWholeTemplateMatch(String sourcePic, String targetPic) {
|
|
double matchVal = templete(Imgproc.TM_SQDIFF_NORMED, sourcePic, targetPic, false);
|
|
double matchVal = templete(Imgproc.TM_SQDIFF_NORMED, sourcePic, targetPic, false);
|
|
- if (Math.abs(matchVal) < YUZHI) {
|
|
|
|
|
|
+ if (Math.abs(matchVal) < YUZHI_HIGH) {
|
|
System.out.println("找到啦"+targetPic);
|
|
System.out.println("找到啦"+targetPic);
|
|
return true;
|
|
return true;
|
|
} else {
|
|
} else {
|