fix(images): another mat released causes the mat recycled???
This commit is contained in:
@@ -73,6 +73,7 @@ public class UiSelector extends UiGlobalSelector {
|
|||||||
public UiObjectCollection find() {
|
public UiObjectCollection find() {
|
||||||
ensureAccessibilityServiceEnabled();
|
ensureAccessibilityServiceEnabled();
|
||||||
AccessibilityNodeInfo root = mAccessibilityBridge.getRootInActiveWindow();
|
AccessibilityNodeInfo root = mAccessibilityBridge.getRootInActiveWindow();
|
||||||
|
Log.d(TAG, "find: root = " + root);
|
||||||
if (root == null) {
|
if (root == null) {
|
||||||
return UiObjectCollection.EMPTY;
|
return UiObjectCollection.EMPTY;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.stardust.autojs.core.image;
|
package com.stardust.autojs.core.image;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
import android.util.TimingLogger;
|
import android.util.TimingLogger;
|
||||||
|
|
||||||
@@ -65,8 +66,8 @@ public class TemplateMatching {
|
|||||||
if (!isFirstMatching && !shouldContinueMatching(level, maxLevel)) {
|
if (!isFirstMatching && !shouldContinueMatching(level, maxLevel)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (matchResult != null)
|
// if (matchResult != null)
|
||||||
matchResult.release();
|
// matchResult.release();
|
||||||
matchResult = matchTemplate(src, currentTemplate, matchMethod);
|
matchResult = matchTemplate(src, currentTemplate, matchMethod);
|
||||||
Pair<Point, Double> bestMatched = getBestMatched(matchResult, matchMethod, weakThreshold);
|
Pair<Point, Double> bestMatched = getBestMatched(matchResult, matchMethod, weakThreshold);
|
||||||
p = bestMatched.first;
|
p = bestMatched.first;
|
||||||
@@ -74,8 +75,8 @@ public class TemplateMatching {
|
|||||||
} else {
|
} else {
|
||||||
//根据上一轮的匹配点,计算本次匹配的区域
|
//根据上一轮的匹配点,计算本次匹配的区域
|
||||||
Rect r = getROI(p, src, currentTemplate);
|
Rect r = getROI(p, src, currentTemplate);
|
||||||
if (matchResult != null)
|
// if (matchResult != null)
|
||||||
matchResult.release();
|
// matchResult.release();
|
||||||
Mat m = new Mat(src, r);
|
Mat m = new Mat(src, r);
|
||||||
matchResult = matchTemplate(m, currentTemplate, matchMethod);
|
matchResult = matchTemplate(m, currentTemplate, matchMethod);
|
||||||
m.release();
|
m.release();
|
||||||
@@ -171,6 +172,8 @@ public class TemplateMatching {
|
|||||||
public static Mat matchTemplate(Mat img, Mat temp, int match_method) {
|
public static Mat matchTemplate(Mat img, Mat temp, int match_method) {
|
||||||
int result_cols = img.cols() - temp.cols() + 1;
|
int result_cols = img.cols() - temp.cols() + 1;
|
||||||
int result_rows = img.rows() - temp.rows() + 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);
|
Mat result = new Mat(result_rows, result_cols, CvType.CV_32FC1);
|
||||||
Imgproc.matchTemplate(img, temp, result, match_method);
|
Imgproc.matchTemplate(img, temp, result, match_method);
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import android.os.Build;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.annotation.RequiresApi;
|
import android.support.annotation.RequiresApi;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
@@ -251,6 +252,7 @@ public class Images {
|
|||||||
if (rect != null) {
|
if (rect != null) {
|
||||||
src = new Mat(src, rect);
|
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,
|
org.opencv.core.Point point = TemplateMatching.fastTemplateMatching(src, template.getMat(), TemplateMatching.MATCHING_METHOD_DEFAULT,
|
||||||
weakThreshold, threshold, maxLevel);
|
weakThreshold, threshold, maxLevel);
|
||||||
if (point != null) {
|
if (point != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user