fix(images): another mat released causes the mat recycled???
This commit is contained in:
@@ -47,7 +47,7 @@ public class CodeEditText extends AppCompatEditText {
|
|||||||
|
|
||||||
|
|
||||||
static final String LOG_TAG = "CodeEditText";
|
static final String LOG_TAG = "CodeEditText";
|
||||||
private static final boolean DEBUG = BuildConfig.DEBUG;
|
private static final boolean DEBUG = false;
|
||||||
|
|
||||||
// 文字范围
|
// 文字范围
|
||||||
protected HVScrollView mParentScrollView;
|
protected HVScrollView mParentScrollView;
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ public class TemplateMatching {
|
|||||||
if (!isFirstMatching && !shouldContinueMatching(level, maxLevel)) {
|
if (!isFirstMatching && !shouldContinueMatching(level, maxLevel)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// FIXME: 2018/3/31 此处的matchResult.release()某些情况下会导致currentTemplate被释放?
|
||||||
// if (matchResult != null)
|
// if (matchResult != null)
|
||||||
// matchResult.release();
|
// matchResult.release();
|
||||||
matchResult = matchTemplate(src, currentTemplate, matchMethod);
|
matchResult = matchTemplate(src, currentTemplate, matchMethod);
|
||||||
@@ -172,8 +173,6 @@ 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;
|
||||||
|
|||||||
@@ -252,7 +252,6 @@ 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