升级Opencv版本到3.4.3
This commit is contained in:
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
app/src/main/jniLibs/armeabi-v7a/libopencv_java3.so
Normal file
BIN
app/src/main/jniLibs/armeabi-v7a/libopencv_java3.so
Normal file
Binary file not shown.
@@ -49,11 +49,12 @@ dependencies {
|
|||||||
})
|
})
|
||||||
api 'com.google.android.material:material:1.1.0-alpha01'
|
api 'com.google.android.material:material:1.1.0-alpha01'
|
||||||
api 'com.github.hyb1996:EnhancedFloaty:0.31'
|
api 'com.github.hyb1996:EnhancedFloaty:0.31'
|
||||||
api 'com.github.hyb1996:OpenCvLib:2.4.13.4-imgproc'
|
|
||||||
api 'com.makeramen:roundedimageview:2.3.0'
|
api 'com.makeramen:roundedimageview:2.3.0'
|
||||||
|
// OpenCv
|
||||||
|
api(name: 'opencv-3.4.3', ext: 'aar')
|
||||||
// OkHttp
|
// OkHttp
|
||||||
api 'com.squareup.okhttp3:okhttp:3.10.0'
|
api 'com.squareup.okhttp3:okhttp:3.10.0'
|
||||||
//JDeferred
|
// JDeferred
|
||||||
api 'org.jdeferred:jdeferred-android-aar:1.2.6'
|
api 'org.jdeferred:jdeferred-android-aar:1.2.6'
|
||||||
//RootShell
|
//RootShell
|
||||||
api 'com.github.Stericson:RootShell:1.6'
|
api 'com.github.Stericson:RootShell:1.6'
|
||||||
|
|||||||
@@ -4,19 +4,20 @@ import android.graphics.Bitmap;
|
|||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.media.Image;
|
import android.media.Image;
|
||||||
import android.os.Build;
|
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.autojs.core.opencv.OpenCVHelper;
|
||||||
import com.stardust.pio.UncheckedIOException;
|
import com.stardust.pio.UncheckedIOException;
|
||||||
|
|
||||||
import org.opencv.android.Utils;
|
import org.opencv.android.Utils;
|
||||||
import com.stardust.autojs.core.opencv.Mat;
|
import org.opencv.imgcodecs.Imgcodecs;
|
||||||
import org.opencv.highgui.Highgui;
|
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Stardust on 2017/11/25.
|
* Created by Stardust on 2017/11/25.
|
||||||
*/
|
*/
|
||||||
@@ -117,7 +118,7 @@ public class ImageWrapper {
|
|||||||
throw new UncheckedIOException(e);
|
throw new UncheckedIOException(e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Highgui.imwrite(path, mMat);
|
Imgcodecs.imwrite(path, mMat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ public class TemplateMatching {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
outResult.add(bestMatched);
|
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 Point(bestMatched.point.x + template.cols(), bestMatched.point.y + template.rows()),
|
||||||
new Scalar(0, 255, 0), -1);
|
new Scalar(0, 255, 0), -1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
package com.stardust.autojs.core.opencv;
|
package com.stardust.autojs.core.opencv;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import android.os.Looper;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
@@ -25,7 +28,7 @@ public class OpenCVHelper {
|
|||||||
private static final String LOG_TAG = "OpenCVHelper";
|
private static final String LOG_TAG = "OpenCVHelper";
|
||||||
private static boolean sInitialized = false;
|
private static boolean sInitialized = false;
|
||||||
|
|
||||||
public static MatOfPoint newMatOfPoint(Mat mat){
|
public static MatOfPoint newMatOfPoint(Mat mat) {
|
||||||
return new MatOfPoint(mat);
|
return new MatOfPoint(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,97 +54,14 @@ public class OpenCVHelper {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sInitialized = true;
|
sInitialized = true;
|
||||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_13, context.getApplicationContext(), new LoaderCallback(context) {
|
if (Looper.getMainLooper() == Looper.myLooper()) {
|
||||||
|
new Thread(() -> {
|
||||||
@Override
|
OpenCVLoader.initDebug();
|
||||||
protected void finish() {
|
|
||||||
callback.onInitFinish();
|
callback.onInitFinish();
|
||||||
}
|
}).start();
|
||||||
});
|
} else {
|
||||||
}
|
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() {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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":{}}]
|
||||||
@@ -5,6 +5,7 @@ import android.app.Dialog;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.ContextWrapper;
|
import android.content.ContextWrapper;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.os.Looper;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
@@ -14,7 +15,7 @@ import android.view.WindowManager;
|
|||||||
|
|
||||||
public class DialogUtils {
|
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();
|
Context context = dialog.getContext();
|
||||||
|
|
||||||
if (!isActivityContext(context)) {
|
if (!isActivityContext(context)) {
|
||||||
@@ -28,7 +29,16 @@ public class DialogUtils {
|
|||||||
if (window != null)
|
if (window != null)
|
||||||
window.setType(type);
|
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;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"appVersionCode": 454,
|
"appVersionCode": 455,
|
||||||
"appVersionName": "4.1.0 Alpha4",
|
"appVersionName": "4.1.0 Alpha5",
|
||||||
"target": 28,
|
"target": 28,
|
||||||
"mini": 17,
|
"mini": 17,
|
||||||
"compile": 28,
|
"compile": 28,
|
||||||
|
|||||||
Reference in New Issue
Block a user