When do we need the NDK for OpenCV Android

android, android-ndk, opencv

Solution

I have been using NDK for my application and following are my observations.

- Yes, it gives the advantage of using plenty of c++ modules which are made available.

- If you already have a bit of experience in computer vision application programming using openCV library in C++, you don´t have to learn new syntaxes in java(can be quite irritating some times).

- Using NDK for your app can give you a slight upperhand in terms of performance when image processing you do is computationally demanding (I am not quite sure about this because the openCV library made available for Android is just a wrapper around the same header files and stuff and should almost give the same performance as NDK. I have never really compared the performance myself but have read in various blogs that NDK is faster).

- One thing you really have to be careful when using NDK is calls from JAVA to NDK side or the other way round, these calls can be really expensive in terms of performance(Needs careful planning).

- Passing few parameters like array of MAT from JAVA to NDK are a bit of headache, but you can find few workarounds.

Based on these and other factors you might have found out from various sources and also by your programming strengths you can decide if you want to use NDK or not. There was never really a set of guidelines i could find that says you can use NDK if so and so conditions are satisfied, people just start with which ever programming style they are more comfortable with.

Problem

I am just starting to learn OpenCV for Android, I have played around with it a bit and it all works fine. I installed the NDK and managed to run some of the sample apps which included it. I am not clear on what we need the NDK for. I could not find it referenced anywhere in the documentation. Is there OpenCV functionality which is not available in the regular library 2.4.8 ? Is it just so we can use modules written in c++ that others have made available, without rewriting them in java ?

Original source