Closed mmmahdiii closed 3 years ago
in AndroidManifest.xml
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
in build.gradle defaultConfig { multiDexEnabled true } dependencies {
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'org.bytedeco:javacv:1.5.5'
}
What's the error message that you get in the log?
no error. I try to get error in try/catch, but noting happened in catch, just close the app.
I've face some problem, maybe I solved in wrong way.
1- I use implementation group: 'org.bytedeco', name: 'javacv', version: '1.5.5'
instit of
implementation group: 'org.bytedeco', name: 'javacv-platform', version: '1.5.5'
2- I use implementation 'androidx.multidex:multidex:2.0.1'
to solve some errores
Ok, but please show me all the messages that you get in the log, including anything at the debug level.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.jcv_t04, PID: 3916
java.lang.IllegalStateException: Could not execute method for android:onClick
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:414)
at android.view.View.performClick(View.java:7448)
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119)
at android.view.View.performClickInternal(View.java:7425)
at android.view.View.access$3600(View.java:810)
at android.view.View$PerformClick.run(View.java:28305)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:409)
at android.view.View.performClick(View.java:7448)
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119)
at android.view.View.performClickInternal(View.java:7425)
at android.view.View.access$3600(View.java:810)
at android.view.View$PerformClick.run(View.java:28305)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libjniopenblas_nolapack.so" not found
at java.lang.Runtime.loadLibrary0(Runtime.java:1087)
at java.lang.Runtime.loadLibrary0(Runtime.java:1008)
at java.lang.System.loadLibrary(System.java:1664)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1718)
at org.bytedeco.javacpp.Loader.load(Loader.java:1328)
at org.bytedeco.javacpp.Loader.load(Loader.java:1132)
at org.bytedeco.openblas.global.openblas_nolapack.
Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libopenblas.so" not found
You'll need that file to be there for OpenCV to load.
Duplicate of #1329
thanks.
I've updated my build.gradle defaultConfig { multiDexEnabled true } dependencies { implementation 'androidx.multidex:multidex:2.0.1' implementation group: 'org.bytedeco', name: 'javacv', version: '1.5.5' implementation group: 'org.bytedeco', name: 'openblas', version: '0.3.13' }
and my debugger turns to:
W/System.err: Warning: Could not load Loader: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.jcv_t04-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.jcv_t04-2/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libjnijavacpp.so"
W/System.err: Warning: Version of org.bytedeco:openblas could not be found.
W/System.err: Warning: Version of org.bytedeco:opencv could not be found.
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.jcv_t04, PID: 24093
java.lang.IllegalStateException: Could not execute method for android:onClick
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:414)
at android.view.View.performClick(View.java:5697)
at android.widget.TextView.performClick(TextView.java:10826)
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119)
at android.view.View$PerformClick.run(View.java:22526)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7225)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:409)
at android.view.View.performClick(View.java:5697)
at android.widget.TextView.performClick(TextView.java:10826)
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119)
at android.view.View$PerformClick.run(View.java:22526)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7225)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.jcv_t04-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.jcv_t04-2/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libjniopenblas_nolapack.so"
at java.lang.Runtime.loadLibrary(Runtime.java:367)
at java.lang.System.loadLibrary(System.java:1076)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1718)
at org.bytedeco.javacpp.Loader.load(Loader.java:1328)
at org.bytedeco.javacpp.Loader.load(Loader.java:1132)
at org.bytedeco.openblas.global.openblas_nolapack.
Add a dependency on javacv-platform. It will get everything that you need.
I Change dependency to:
plugins { id 'com.android.application' id 'org.bytedeco.gradle-javacpp-platform' version "1.5.5" }
android { compileSdkVersion 30 buildToolsVersion "30.0.3" packagingOptions { exclude 'META-INF/native-image/android-arm/jnijavacpp/jni-config.json' exclude 'META-INF/native-image/android-arm/jnijavacpp/reflect-config.json' exclude 'META-INF/native-image/android-arm64/jnijavacpp/jni-config.json' exclude 'META-INF/native-image/android-arm64/jnijavacpp/reflect-config.json' } defaultConfig { applicationId "com.example.jcv_t04" minSdkVersion 16 targetSdkVersion 30 versionCode 1 versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
} def openblas = '0.3.13' def javacv = "1.5.5" def opencv = "4.5.1" //def opencv = "4.3.2"
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'androidx.multidex:multidex:2.0.1'
//implementation 'org.bytedeco:javacv:1.5.5'
//implementation group: 'org.bytedeco', name: 'javacv', version: '1.5.5'
//implementation group: 'org.bytedeco', name: 'openblas', version: '0.3.10-1.5.5'
//implementation group: 'org.bytedeco', name: 'javacv', version: '1.5.5'
//implementation group: 'org.bytedeco', name: 'openblas', version: '0.3.13'
api "org.bytedeco:openblas:${openblas}-${javacv}"
api "org.bytedeco:openblas:${openblas}-${javacv}:android-arm"
api "org.bytedeco:openblas:${openblas}-${javacv}:android-arm64"
api "org.bytedeco:opencv:${opencv}-${javacv}"
api "org.bytedeco:opencv:${opencv}-${javacv}:android-arm"
api "org.bytedeco:opencv:${opencv}-${javacv}:android-arm64"
}
and all the bugs almost gone, but my IMREAD doesn't work. I tried my code in a OpenCV attached project that I've done before, and it's work well.
when I use Mat image = imread(filename);
the returned image is zero size,
when I use org.opencv.core.Mat img = org.opencv.imgcodecs.Imgcodecs.imread(filename);
, I see the error bellow
D/ViewRootImpl: ViewPostImeInputStage processPointer 1 E/art: No implementation found for long org.opencv.imgcodecs.Imgcodecs.imread_1(java.lang.String) (tried Java_org_opencv_imgcodecs_Imgcodecs_imread_11 and Java_org_opencv_imgcodecs_Imgcodecs_imread_11Ljava_lang_String_2) D/AndroidRuntime: Shutting down VM E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.jcv_t04, PID: 11983 java.lang.IllegalStateException: Could not execute method for android:onClick at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:414) at android.view.View.performClick(View.java:5697) at android.widget.TextView.performClick(TextView.java:10826) at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119) at android.view.View$PerformClick.run(View.java:22526) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7225) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:409) at android.view.View.performClick(View.java:5697) at android.widget.TextView.performClick(TextView.java:10826) at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119) at android.view.View$PerformClick.run(View.java:22526) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7225) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) Caused by: java.lang.UnsatisfiedLinkError: No implementation found for long org.opencv.imgcodecs.Imgcodecs.imread_1(java.lang.String) (tried Java_org_opencv_imgcodecs_Imgcodecs_imread_11 and Java_org_opencv_imgcodecs_Imgcodecs_imread_11__Ljava_lang_String_2) at org.opencv.imgcodecs.Imgcodecs.imread_1(Native Method) at org.opencv.imgcodecs.Imgcodecs.imread(Imgcodecs.java:287) at com.example.jcv_t04.Smoother.smooth(MainActivity.java:125) at com.example.jcv_t04.MainActivity.doSomething(MainActivity.java:117) at java.lang.reflect.Method.invoke(Native Method) at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:409) at android.view.View.performClick(View.java:5697) at android.widget.TextView.performClick(TextView.java:10826) at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119) at android.view.View$PerformClick.run(View.java:22526) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7225) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) E/art: No implementation found for void org.opencv.core.Mat.n_delete(long) (tried Java_org_opencv_core_Mat_n_1delete and Java_org_opencv_core_Mat_n_1deleteJ) E/System: Uncaught exception thrown by finalizer java.lang.UnsatisfiedLinkError: No implementation found for void org.opencv.core.Mat.n_delete(long) (tried Java_org_opencv_core_Mat_n_1delete and Java_org_opencv_core_Mat_n_1delete__J) at org.opencv.core.Mat.n_delete(Native Method) at org.opencv.core.Mat.finalize(Mat.java:740) at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:217) at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:200) at java.lang.Thread.run(Thread.java:818)
Make sure that Loader.load(opencv_java.class) has been called: https://github.com/bytedeco/javacpp-presets/tree/master/opencv#documentation
No error
Thanks a lot. Finally, my imread worked. my GaussianBlurr worked. my imwrite worked.
but drawing circle, faced with error, Cannot resolve method 'circle(org.bytedeco.opencv.opencv_core.Mat, org.bytedeco.opencv.opencv_core.Point, int, org.bytedeco.opencv.opencv_core.CvScalar)'
don't waist your time on this issue, I ask you to update the Samples, for the beginners like me.
CvScalar
is for the deprected C API. Use Scalar
instead.
Thanks a million. Can you refer me to any references for deal with this thing?
What thing?
this errors,
Hi, stock at the first step off coding with javaCV.
my android app get closed suddenly when I use Imread.
class Smoother { public static void smooth(String filename) { Mat image = imread(filename); if (image != null) { GaussianBlur(image, image, new Size(3, 3), 0); imwrite(filename, image); } } }
public void doSomthing(View view){ try { String path=getPathImage(imageUri); Smoother.smooth(path); txtV1.setText("GOOOOOOOOOOOOD"); } catch (Exception e) { e.printStackTrace(); txtV1.setText(e.getMessage()); } }
It never fall in catch. and this closing happen after the function below in Loder.java
public static String load() { return load(getCallerClass(2), loadProperties(), Loader.pathsFirst); }
thanks' for any help