I have developed an application for computer vision algorithms that uses Native C++ library like OpenCV to capture camera frame and do image processing. My whole implementation resides in a native function which is called through an activity.
Let's say:
public native int MYMETHOD(int width, int height,int[] rgba);
I also load my library like this:
static {
System.loadLibrary("MYNativeLIB");
}
Now my question is how can I deploy my application as a library package. Something deliverable that I can share it and the clients can import it to their project without installing any other libraries like OpenCV. Do I need to build a .so package?
I have read this article. But I do not know how can I link against OpenCV library as well.
Thanks for your help in advance.
You should have a look at the static initialization for OpenCV4andorid. You then can add the Open CV lib into your /libs directory of your Library project without the need to install any third party app when using it.
Have you created your project as a library? Maybe you could create a new project and port code with little effort. A very concise yet detailed explanation here:.
http://developer.android.com/tools/projects/projects-eclipse.html#SettingUpLibraryProject
First you need to compile c/c++ files using android-ndk detailed
explanation here
http://rathodpratik.wordpress.com/2013/03/24/build-cc-executables-for-android-using-ndk/
Then you can successfully run your android project.
Related
I have looked at Use prebuilt JNI library in Android Studio 3.1 and How to use .so in a second project in Android?. The first is trying to get a library file without headers working and the other seems to be focusing on a specific issue with his build (although there's some useful information there). I'm relatively new to app development and especially to native development on android. I've gotten a build with the JNI library and some c++ code working, but that seems to be just for building from source.
It's probably a simple answer, but I haven't been able to find documentation on this specifically in the android developers documentation. I'm interested in understanding the correct (or most conventional) place to put and way to use a precompiled library (module/lib/*.so and module/include/*.h) in an android project. Would I even need to use JNI or the NDK if the library is built with another build tool? Another project I have has a native library source object (*.so) in ./obj/local, ./libs, and in many other folders related to JNI. I'm guessing it would be somewhere in there, but I'd like to know what is conventional.
For some context, I'm trying to work with the essentia library. I have followed the guide on compiling for Android and have a build with the general hierarchy mentioned above (essentia/lib and essentia/include) that seems to be working.
so, I m a bit confused here. I have an opencv project which import an image and does something with it and gives output.So I want to use this project as one part in my android project.So how do I proceed. I have SDK, NDK openCV lib all installed. Any help would be great.
Compile your project with NDK as a static library.
Create a shared library with JNI entry point that takes the necessary inputs from Java and return the result to Java. Link it with your static lib and OpenCV.
Create a Java Android project that uses this shared library.
I am following the steps outlined at http://techiedreams.com/android-zxing-barcode-scanner-integration/ to embed QR scanning into my Android app. Instead of building the .jar files myself, I have downloaded them directly from http://repo1.maven.org/maven2/com/google/zxing/.
The problem is none of the jar files below contain com.google.zxing.client.android.CaptureActivity class that is required for integration.
http://repo1.maven.org/maven2/com/google/zxing/core/3.1.0/core-3.1.0.jar
http://repo1.maven.org/maven2/com/google/zxing/android-core/3.1.0/android-core-3.1.0.jar
http://repo1.maven.org/maven2/com/google/zxing/android-integration/3.1.0/android-integration-3.1.0.jar
All these jars are at the latest version as of this post. Wondering if I missed something. Regards.
Yes, it is not a library component and you are not meant to call it that way. The source is available but it is not distributed as a Maven artifact. It is part of an app.
I have .so library and it's 'JNICall' class, which is an interface for it. They was wrote not by me. To be honest, I decompiled one apk to get them. So the question - It is possible to use them in my project, and how I can do this?
Try to find proper documentation for your library otherwise it'll be difficult to integrate,
as for including the so file in your project follow this:
How do I import a native library (.so file) into Eclipse?
I want to work on an Android project (under Eclipse) using Opencv, I've imported the Opencv library and it's associated samples to Eclipse, as explained here:
http://opencv.itseez.com/doc/tutorials/introduction/android_binary_package/android_binary_package.html.
I tested the samples and they work well. But when I create my new own Android project in Eclipse, it can't link Opencv which is placed in the same workspace as the project (i.e. error when I write import org.opencv.core.*).
Is there something that has to be done for a new project to be linked with Opencv (src and lib)?
I recomend you to download the OpenCV prebuild package and follow these instructions.
I don't know if you are going to use C++ for openCV and crosscompile with NDK and JNI library, but that way is quite easy to set up everything. If you need more help about how including C++ OpenCV codes in android projects I can check my codes. Good luck.
It sounds like you haven’t included the Open CV library’s in your new project.
I can’t remember the exact step to include libraries in projects but below are a couple of link that might help.
http://wiki.eclipse.org/FAQ_How_do_I_add_an_extra_library_to_my_project's_classpath%3F
Import Libraries in Eclipse?