I am using OpenCV2.4.7 Library in my Android app. When app starts its goes to Google Play store for Application called OpenCV Manager. Is there any way to integrate this application in my Android apk because we already using OpenCV library so why app needs OpenCV Engine Again? Is Their any way to integrate this engine?
This is a simplified version of this(1) SO answer. Download latest OpenCV sdk for Android from OpenCV.org and decompress the zip file. Import OpenCV to Android Studio, From File -> New -> Import Module, choose sdk/java folder in the unzipped opencv archive. Update build.
You'll see a couple of sample applications, which you can use as a basis for your own developments. “Android development with OpenCV” shows you how to add OpenCV functionality into your Android application. For those who want to reuse their C++ code, we've created a special section: “Native/C++”.
OpenCV is a popular open source image processing library that can easily run on Android. Although you will need to use the Android Native Development Kit (NDK) and may need C++, it's quick and easy to get started with OpenCV on Android.
Yes. To integrate OpenCV inside your application, and avoid explicit installation of OpenCV manager, you need to first read following document provided by OpenCV.
First Read -> Static Initialization of OpenCV
After successfully followed steps, you need to write following code to enable OpenCV in your application initialization code before calling OpenCV API. It can be done, for example, in the static section of the Activity class:
static { if (!OpenCVLoader.initDebug()) { // Handle initialization error } }
References:
As per new scenario in Document and thanks to @rozhok for providing new information, initDebug() method can't be used for production build
Note This method is deprecated for production code. It is designed for experimental and local development purposes only. If you want to publish your app use approach with async initialization.
You need to use following method for that
Syntax
static boolean initAsync(String Version, Context AppContext, LoaderCallbackInterface Callback)
Example
public class Sample1Java extends Activity implements CvCameraViewListener { private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) { @Override public void onManagerConnected(int status) { switch (status) { case LoaderCallbackInterface.SUCCESS: { Log.i(TAG, "OpenCV loaded successfully"); mOpenCvCameraView.enableView(); } break; default: { super.onManagerConnected(status); } break; } } }; @Override public void onResume() { super.onResume(); OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, mLoaderCallback); } ... }
References
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With