Fork me on GitHub

Static Linking of OpenCV with Android

Posted on 13 April 2014
Under Notes
Static Linking of OpenCV with Android | Jay Rambhia’s Blog

I have been working on this android application for long exposure shots and want to put it on Google Play Store. Since I have included OpenCV, the application needs OpenCV Manager to run. Now, this can be demotivating for the users to download another app to run my app. So I looked around and there’s a way to do the static linking of OpenCV modules. And, it’s pretty easy too.

OpenCV Application Development With Static Initialization

You just need to add following lines in file.

OPENCV_CAMERA_MODULES:=on # If you want Camera module

In Java, Add following in the static section of the Activity class.

static {
    if (!OpenCVLoader.initDebug()) {
        // Handle initialization error
    else {
        System.loadLibrary("jni_part"); // load other native libraries

That’s it. Now, the application doesn’t require OpenCV Manager to run. Although, APK size increases due to installing the modules.

P.S. Static Initialization might be slowing down the opencv processing part.

If you liked - Static Linking of OpenCV with Android and found it helpful, please share it with your fellow developers.

comments powered by Disqus

If you have some feedback or questions regarding this post, please add comments. I'd be happy to get some feedback.

If you liked this post, then you should follow Jay on twitter too. He would be excited to know that you like his work.