升级Opencv版本到3.4.3

This commit is contained in:
hyb1996
2018-12-16 14:54:55 +08:00
parent f31e3e567e
commit ce00205871
11 changed files with 35 additions and 103 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -49,11 +49,12 @@ dependencies {
})
api 'com.google.android.material:material:1.1.0-alpha01'
api 'com.github.hyb1996:EnhancedFloaty:0.31'
api 'com.github.hyb1996:OpenCvLib:2.4.13.4-imgproc'
api 'com.makeramen:roundedimageview:2.3.0'
// OpenCv
api(name: 'opencv-3.4.3', ext: 'aar')
// OkHttp
api 'com.squareup.okhttp3:okhttp:3.10.0'
//JDeferred
// JDeferred
api 'org.jdeferred:jdeferred-android-aar:1.2.6'
//RootShell
api 'com.github.Stericson:RootShell:1.6'

View File

@@ -4,19 +4,20 @@ import android.graphics.Bitmap;
import android.graphics.Color;
import android.media.Image;
import android.os.Build;
import androidx.annotation.RequiresApi;
import com.stardust.autojs.core.opencv.Mat;
import com.stardust.autojs.core.opencv.OpenCVHelper;
import com.stardust.pio.UncheckedIOException;
import org.opencv.android.Utils;
import com.stardust.autojs.core.opencv.Mat;
import org.opencv.highgui.Highgui;
import org.opencv.imgcodecs.Imgcodecs;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import androidx.annotation.RequiresApi;
/**
* Created by Stardust on 2017/11/25.
*/
@@ -117,7 +118,7 @@ public class ImageWrapper {
throw new UncheckedIOException(e);
}
} else {
Highgui.imwrite(path, mMat);
Imgcodecs.imwrite(path, mMat);
}
}

View File

@@ -214,7 +214,7 @@ public class TemplateMatching {
break;
}
outResult.add(bestMatched);
Core.rectangle(tmResult, bestMatched.point,
Imgproc.rectangle(tmResult, bestMatched.point,
new Point(bestMatched.point.x + template.cols(), bestMatched.point.y + template.rows()),
new Scalar(0, 255, 0), -1);
}

View File

@@ -1,7 +1,10 @@
package com.stardust.autojs.core.opencv;
import android.content.Context;
import androidx.annotation.Nullable;
import android.os.Looper;
import android.util.Log;
import com.afollestad.materialdialogs.MaterialDialog;
@@ -25,7 +28,7 @@ public class OpenCVHelper {
private static final String LOG_TAG = "OpenCVHelper";
private static boolean sInitialized = false;
public static MatOfPoint newMatOfPoint(Mat mat){
public static MatOfPoint newMatOfPoint(Mat mat) {
return new MatOfPoint(mat);
}
@@ -51,97 +54,14 @@ public class OpenCVHelper {
return;
}
sInitialized = true;
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_13, context.getApplicationContext(), new LoaderCallback(context) {
@Override
protected void finish() {
if (Looper.getMainLooper() == Looper.myLooper()) {
new Thread(() -> {
OpenCVLoader.initDebug();
callback.onInitFinish();
}
});
}
public static class LoaderCallback implements LoaderCallbackInterface {
private Context mContext;
public LoaderCallback(Context context) {
this.mContext = context;
}
public void onManagerConnected(int status) {
switch (status) {
case 0:
finish();
break;
case 1:
default:
Log.e(LOG_TAG, "OpenCV loading failed!");
DialogUtils.showDialog(new MaterialDialog.Builder(mContext)
.title("OpenCV error")
.content("OpenCV was not initialised correctly. Application will be shut down")
.cancelable(false)
.positiveText("OK")
.onPositive((dialog, which) -> finish())
.build());
break;
case 2:
Log.e(LOG_TAG, "Package installation failed!");
DialogUtils.showDialog(new MaterialDialog.Builder(mContext)
.title("OpenCV Manager")
.content("Package installation failed!")
.cancelable(false)
.positiveText("OK")
.onPositive((dialog, which) -> finish())
.build());
break;
case 3:
Log.d(LOG_TAG, "OpenCV library instalation was canceled by user");
finish();
break;
case 4:
Log.d(LOG_TAG, "OpenCV Manager Service is uncompatible with this app!");
DialogUtils.showDialog(new MaterialDialog.Builder(mContext)
.title("OpenCV Manager")
.content("OpenCV Manager service is incompatible with this app. Try to update it via Google Play.")
.cancelable(false)
.positiveText("OK")
.onPositive((dialog, which) -> finish())
.build());
}
}
public void onPackageInstall(int operation, final InstallCallbackInterface callback) {
switch (operation) {
case 0:
DialogUtils.showDialog(new MaterialDialog.Builder(mContext)
.title("Package not found")
.content(callback.getPackageName() + " package was not found! Try to install it?")
.cancelable(false)
.positiveText("Yes")
.onPositive((dialog, which) -> callback.install())
.negativeText("No")
.onNegative(((dialog, which) -> callback.cancel()))
.build());
break;
case 1:
DialogUtils.showDialog(new MaterialDialog.Builder(mContext)
.title("OpenCV is not ready")
.content("Installation is in progress. Wait or exit?")
.cancelable(false)
.positiveText("Wait")
.onPositive((dialog, which) -> callback.wait_install())
.negativeText("Exit")
.onNegative(((dialog, which) -> callback.cancel()))
.build());
default:
finish();
}
}
protected void finish() {
}).start();
} else {
OpenCVLoader.initDebug();
callback.onInitFinish();
}
}
}

View File

@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":454,"versionName":"4.1.0 Alpha4","enabled":true,"outputFile":"commonRelease-4.1.0 Alpha4.apk","fullName":"commonRelease","baseName":"common-release"},"path":"commonRelease-4.1.0 Alpha4.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":455,"versionName":"4.1.0 Alpha5","enabled":true,"outputFile":"commonRelease-4.1.0 Alpha5.apk","fullName":"commonRelease","baseName":"common-release"},"path":"commonRelease-4.1.0 Alpha5.apk","properties":{}}]

View File

@@ -5,6 +5,7 @@ import android.app.Dialog;
import android.content.Context;
import android.content.ContextWrapper;
import android.os.Build;
import android.os.Looper;
import android.view.Window;
import android.view.WindowManager;
@@ -14,7 +15,7 @@ import android.view.WindowManager;
public class DialogUtils {
public static <T extends Dialog> T showDialog(T dialog) {
public static <T extends Dialog> T showDialog(final T dialog) {
Context context = dialog.getContext();
if (!isActivityContext(context)) {
@@ -28,7 +29,16 @@ public class DialogUtils {
if (window != null)
window.setType(type);
}
dialog.show();
if (Looper.getMainLooper() == Looper.myLooper()) {
dialog.show();
} else {
GlobalAppContext.post(new Runnable() {
@Override
public void run() {
dialog.show();
}
});
}
return dialog;
}

View File

@@ -1,6 +1,6 @@
{
"appVersionCode": 454,
"appVersionName": "4.1.0 Alpha4",
"appVersionCode": 455,
"appVersionName": "4.1.0 Alpha5",
"target": 28,
"mini": 17,
"compile": 28,