1

I'm a java developer and I want to develop an android app that capture a photo and extract its bags of visual words. To extract those bags of words I use the TOP-SURF toolkit which is written in C++

I'm new to C++ development and I want to know how to develop an android app that use this toolkit

I read about the NDK. It's the solution?

0

2 Answers 2

3

The NDK is the solution to all Android problems :)

I noted with interest that all the best performing games I have are all written in the NDK (get Addons Detector - used mainly for seeing which app contains those ** push advert APIs, but it also tells you which dev tools were used for an app).

Writing with the NDK means you won't have any worries about using the C++ library. If you want to keep your Java code, you can just use JNI to call it, or wrap it in a class.

6
  • 2
    I noted with interest that all the best performing games I have are all written in the NDK -- Despite the fact that the page you linked claims that most programs will not see a performance increase? Oct 2, 2013 at 21:52
  • 2
    @RobertHarvey: "most programs" are rather trivial UIs for some data retrieved over network and these do so little locally that performance does not matter. But for things that actually do some significant work, benchmarks I've seen generally show performance of Dalvik (the Android custom JVM) is abysmal.
    – Jan Hudec
    Oct 3, 2013 at 8:54
  • 1
    @RobertHarvey: Besides, most games are actually implemented multi-platform and C++ is still the only language that is supported on all relevant platforms.
    – Jan Hudec
    Oct 3, 2013 at 9:03
  • 1
    @RobertHarvey The link says what someone at Google wants you to believe - that Java is the only solution that "doesn't suck". The reality is different, try that inspection app and see for yourself.
    – gbjbaanb
    Oct 3, 2013 at 12:47
  • Can C++11 be used? Oct 3, 2013 at 17:15
0

The problem with the NDK (the main reason why the official docs say not to use it solely as a performance boost) has to do with the fact that whatever C/C++ code you write for your Android app, it will still, at some point, be called from Java code via JNI. And JNI calls are slow.

That being said, you can avoid granular JNI calls, and get good performance in certain situations. The best thing to do is to do a small Proof of Concept for your app.

Here's what I'd do:

  • Install the great Eclipse Sequoyah plugin in your Eclipse (which should already have the Android Eclipse plugin)
  • Get the source code for your library. Either build it as an Android library and add that to your project (you can do this using the NDK) or just add the source code of that library to your App's project
  • Try to write a Native Activity that does some simple API calls towards your library. Once that's working, do some benchmarks to see if you can get user friendly response times for some of the usual operations you intend to implement
  • Avoid the Android Emulator, it's simply terrible. Use a real Android device.

Not the answer you're looking for? Browse other questions tagged or ask your own question.