Ask Your Question
5

OpenCV on Android without the OpenCV Manager

asked 2014-03-01 10:23:08 -0600

ErikHellman gravatar image

Yes, I know this question has been asked many times before, but this is a real issue if you want to do any serious application development on Android.

We need an easy and simple way of bundling and loading the OpenCV libraries in an Android app. Depending on a different application (i.e., the OpenCV Manager) is plain stupid from a usability perspective, never mind the fact that I won't have full control of which library is loaded.

The size of the application is something we can deal with using other methods and shouldn't be of a concern for the OpenCV library as such.

This is the single most annoying thing about writing OpenCV apps on Android today. It is actually blocking my current progress on the Android platform.

What we need is the .so files available as separate downloads as well as a regular .jar containing the Java interfaces. This could all be packaged in the new .aar format now that it supports native libraries as well.

Any plans on making it possible for us to do this ourself or are you planning on releasing something like this in the near future?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
5

answered 2016-01-25 03:23:40 -0600

steveliles gravatar image

Since 2012 we've been bundling the native libs in our apps - it works great, and offers a much better end user experience than the OpenCV Manager (and for that matter a better developer experience).

You can get the native libs from inside the OpenCV4Android download and add them to your own project directly or bundle them in your own .aar. I'm sure you are aware of that Eric (nice book btw)., but others who come across this question may not realise it.

Steps:

  • Download and unpack OpenCV4Android
  • Create a library project in Android Studio
  • Copy the Java src from OpenCV4Android into your libraries /src/main/java directory
  • Copy the native lib directories into /src/main/jniLibs
  • Depend on your new library

If you want to reduce the download size of dependent apps, add a 'splits' directive to the 'android' gradle plugin configuration - something like this:

android {
   // ... 
   splits {
     abi {
       enable true
       reset()
       include 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'mips', 'mips64', 'arm64-v8a'
       universalApk false
     }
   }
}

I cannot understand why anyone would think the OpenCV Manager approach is OK, never mind push it to the exclusion of the better alternative.

Producing a .aar is very easy, and having it published to maven central and jcenter also very easy. I suspect having an official .aar available and documented as the straight-forward integration route would do wonders for OpenCV usage on Android!

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-03-01 10:23:08 -0600

Seen: 1,611 times

Last updated: Jan 25 '16