Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to integrate OpenCV Manager in Android App

Tags:

android

opencv

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?

like image 667
Vijay007 Avatar asked Nov 28 '13 06:11

Vijay007


People also ask

Can we use OpenCV for Android app?

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.

Does OpenCV work on mobile?

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++”.

How use OpenCV image processing in Android?

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.


1 Answers

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:

  1. http://answers.opencv.org/question/2033/use-opencv-on-android-without-manager/
  2. Static Initialization on OpenCV Android

Edit

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

  1. http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.html
like image 117
Chintan Rathod Avatar answered Oct 03 '22 22:10

Chintan Rathod