leadrien / opencv_native_androidstudio Goto Github PK
View Code? Open in Web Editor NEWAn android studio project with native Opencv
An android studio project with native Opencv
Hi! I'm testing your app with several devices it works perfectly fine with my Moto G 1st gen Android 5.0, but it doesn't in a Samsung Galaxy Grand Neo (API level 17) I've change minimum SDK from Gradle in order to load it on this device.
The problem I'm facing is that it work won't on this device, error is:
E/dalvikvm: dlopen("/data/app-lib/com.packagename/libnative-lib.so") failed: Cannot load library: soinfo_link_image(linker.cpp:1636): could not load library "libopencv_java3.so" needed by "libnative-lib.so"; caused by load_library(linker.cpp:746): library "libopencv_java3.so" not found
followed by:
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.UnsatisfiedLinkError: Cannot load library: soinfo_link_image(linker.cpp:1636): could not load library "libopencv_java3.so" needed by "libnative-lib.so"; caused by load_library(linker.cpp:746): library "libopencv_java3.so" not found
at java.lang.Runtime.loadLibrary(Runtime.java:371)
at java.lang.System.loadLibrary(System.java:535)
at com.packagename.MainActivity.onCreate(MainActivity.java:45)
at android.app.Activity.performCreate(Activity.java:5326)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2218)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2309)
at android.app.ActivityThread.access$700(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1289)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5319)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
jniLIbs symlink is correct and I also tried coping the CPU folders inside a jniLibs folder just to test if the symlink was the problem and still getting the same error.
I downloaded "What's my ABI?" from playstore and both Moto G and Samsung Galaxy Grand Neo are armeabi-v7a
any ideas? Thank you
Hi, thank you for your work.
I have followed all your steps to create a project from scratch.
It all works fine, but in native-lib.cpp I have this problem
Error:(3, 10) fatal error: 'opencv2/core.hpp' file not found
I said that all works fine because I tried to change
#include <opencv2/core.hpp>
in
#include <[my custom path]/opencv2/core.hpp>
where my custom path is a folder that contain the opencv directories that usually are in /local/include and it works.
Obv this is not a solution, because I have to modify also all the opencv library header.
I tried to copy opencv2 and opencv in the same folder of native-code.cpp, same problem.
Can you help me?
Hello, I am not very familiar with ndk, and I got an error in compiling the project. Is this asking me to compile the so file by cmake? I remember that I don’t need to compile it manually in android studio
Error message:
Build command failed.
Error while executing process D:\androidsdk\cmake\3.6.4111459\bin\cmake.exe with arguments {--build C:\Users\Administrator\Desktop\zuoz\imageview\opencv_native_androidstudio-master\app.cxx\cmake\debug\arm64-v8a --target native-lib}
ninja: error: '../../../../src/main/jniLibs/arm64-v8a/libopencv_java3.so', needed by '../../../../build/intermediates/cmake/debug/obj/arm64-v8a/libnative-lib.so', missing and no known rule to make it
i got this gradle error after importing this project,
Gradle tasks [:app:assembleDebug]
error: '../../../../src/main/jniLibs/arm64-v8a/libopencv_java3.so', needed by '../../../../build/intermediates/cmake/debug/obj/arm64-v8a/libnative-lib.so', missing and no known rule to make it
BUILD FAILED
..
what doesn't mean ?
Hello,
When I try to run the Android App, I have this message :
Build command failed.
Error while executing process C:\Users\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {--build C:\Users\Desktop\opencv_native_androidstudio-master\opencv_native_androidstudio-master\app.externalNativeBuild\cmake\debug\x86 --target native-lib}
ninja: error: '../../../../src/main/jniLibs/x86/libopencv_java3.so', needed by '../../../../build/intermediates/cmake/debug/obj/x86/libnative-lib.so', missing and no known rule to make it
Could you help ?
Thank you,
Christophe
Hello! Thanks for sharing this and making the Usage guide. I've manage to compile and test your code, but the only problem I'm facing is that screen image is rotated 90° (non clockwise). Any idea of what's going on?
Thanks in advance!
PS: I'm using a Moto G 1st gen
Hi,
I want to work on OpenCV with native C++ and trying to build your project.
i have encountered a cmake build problem.
I think its a simple problem but i still couldn't figure out, maybe you might have an idea.
What went wrong:
Execution failed for task ':app:externalNativeBuildDebug'.
Build command failed.
Error while executing process C:\Users\sakthivel\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {--build D:\OCVA\opencv_native_androidstudio-master\opencv_native_androidstudio-master\app.externalNativeBuild\cmake\debug\arm64-v8a --target native-lib}
ninja: error: '../../../../src/main/jniLibs/arm64-v8a/libopencv_java3.so', needed by '../../../../build/intermediates/cmake/debug/obj/arm64-v8a/libnative-lib.so', missing and no known rule to make it
I added a simple exception in native-lib.cpp and the app crashed.
extern "C"
{
void JNICALL Java_ch_hepia_iti_opencvnativeandroidstudio_MainActivity_salt(JNIEnv *env, jobject instance,
jlong matAddrGray,
jint nbrElem) {
try {
throw logic_error("");
}
catch (logic_error) {
}
Mat &mGr = *(Mat *) matAddrGray;
for (int k = 0; k < nbrElem; k++) {
int i = rand() % mGr.cols;
int j = rand() % mGr.rows;
mGr.at<uchar>(j, i) = 255;
}
}
}
And the program work perfect without lib_opencv.
target_link_libraries( # Specifies the target library.
native-lib
# OpenCV lib
# lib_opencv
# Links the target library to the log library
# included in the NDK.
${log-lib} )
NDK not configured.
Download it with SDK manager.
Update NDK version to 21.3.6528147 and sync project
I have already installed NDK even though I am getting this error.
Can you please help to resolve this issue.
Hi there
I love your work here and thank you for sharing it.
I follow your instruction and succeed to compile with this configuration:
opencv 3.1
gradle-experimental:0.7.0-alpha4
sdk 23
just one tip for this instruction:
fully read this http://tools.android.com/tech-docs/new-build-system/gradle-experimental to config gradle properly.
cheers.
Of all guide on creating OpenCv with c++ on Android Studio, this is the only one that I managed to get it work.
Thanks. Much appreciated.
sir i have read your repository and it so clean to read, but i get some problem that i got not reference by class cvtColor on .cpp file how should i do that? thank you
Error:error: '../../../../src/main/jniLibs/arm64-v8a/libopencv_java3.so', needed by '../../../../build/intermediates/cmake/debug/obj/arm64-v8a/libnative-lib.so', missing and no known rule to make it
Hello @leadrien ,
I compile this project failed, do you have any clue?
Hello! I think this repo is really helpful, and it works well for me! However, it takes a lot of time before I find this repo using google. Even using "opencv native android studio" I cannot find this repo... Therefore, I suggest changing the repo name or slogan, such that more people can find and use it :)
Hi! Thanks for this wonderful project! Now OpenCV4 has released, so how should I update it to V4? I am willing to give a PR!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.