From 0e2a49cd6f33cfe270f47637371a64e98e44d09b Mon Sep 17 00:00:00 2001 From: hyb1996 <946994919@qq.com> Date: Sat, 31 Mar 2018 22:07:31 +0800 Subject: [PATCH] fix(images): another mat released causes the mat recycled??? --- .../com/stardust/scriptdroid/ui/edit/editor/CodeEditText.java | 2 +- .../java/com/stardust/autojs/core/image/TemplateMatching.java | 3 +-- .../src/main/java/com/stardust/autojs/runtime/api/Images.java | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/stardust/scriptdroid/ui/edit/editor/CodeEditText.java b/app/src/main/java/com/stardust/scriptdroid/ui/edit/editor/CodeEditText.java index 580686a8..33e4e064 100644 --- a/app/src/main/java/com/stardust/scriptdroid/ui/edit/editor/CodeEditText.java +++ b/app/src/main/java/com/stardust/scriptdroid/ui/edit/editor/CodeEditText.java @@ -47,7 +47,7 @@ public class CodeEditText extends AppCompatEditText { static final String LOG_TAG = "CodeEditText"; - private static final boolean DEBUG = BuildConfig.DEBUG; + private static final boolean DEBUG = false; // 文字范围 protected HVScrollView mParentScrollView; diff --git a/autojs/src/main/java/com/stardust/autojs/core/image/TemplateMatching.java b/autojs/src/main/java/com/stardust/autojs/core/image/TemplateMatching.java index 14c29071..a222f17a 100644 --- a/autojs/src/main/java/com/stardust/autojs/core/image/TemplateMatching.java +++ b/autojs/src/main/java/com/stardust/autojs/core/image/TemplateMatching.java @@ -66,6 +66,7 @@ public class TemplateMatching { if (!isFirstMatching && !shouldContinueMatching(level, maxLevel)) { break; } + // FIXME: 2018/3/31 此处的matchResult.release()某些情况下会导致currentTemplate被释放? // if (matchResult != null) // matchResult.release(); matchResult = matchTemplate(src, currentTemplate, matchMethod); @@ -172,8 +173,6 @@ public class TemplateMatching { public static Mat matchTemplate(Mat img, Mat temp, int match_method) { int result_cols = img.cols() - temp.cols() + 1; int result_rows = img.rows() - temp.rows() + 1; - Log.d(LOG_TAG, "matchTemplate: cols = " + result_cols + ", rows = " + result_rows); - Log.d(LOG_TAG, "matchTemplate: img = " + img + ", temp = " + temp); Mat result = new Mat(result_rows, result_cols, CvType.CV_32FC1); Imgproc.matchTemplate(img, temp, result, match_method); return result; diff --git a/autojs/src/main/java/com/stardust/autojs/runtime/api/Images.java b/autojs/src/main/java/com/stardust/autojs/runtime/api/Images.java index c2555a25..63f7b1c4 100644 --- a/autojs/src/main/java/com/stardust/autojs/runtime/api/Images.java +++ b/autojs/src/main/java/com/stardust/autojs/runtime/api/Images.java @@ -252,7 +252,6 @@ public class Images { if (rect != null) { src = new Mat(src, rect); } - Log.d("Images", "matchTemplate: img = " + src + ", temp = " + template.getMat()); org.opencv.core.Point point = TemplateMatching.fastTemplateMatching(src, template.getMat(), TemplateMatching.MATCHING_METHOD_DEFAULT, weakThreshold, threshold, maxLevel); if (point != null) {