Ask Your Question
0

Porting from Desktop C++ to Android NDK

asked 2013-06-25 11:33:33 -0600

ShadowTS gravatar image

updated 2013-06-26 02:53:13 -0600

My intention is to test some modifications to an OpenCV algorithm, in particular ORB feature detector and descriptor. So I start developing on my desktop with C++ and I copied some .cpp file from OpenCV sources, in particular orb.ccp, fast.cpp, precomp.cpp, fast_score.cpp. The first one is the main file of the algorithm, the second one is the feature detector used by ORB, the third and fourth are necessary as called with "includes" in fast.cpp. Obviously I copied the headers and method declarations from OpenCV .hpp(s), creating my headers. I changed the names of the two classes involved (ORB and FAST -> myORB and myFAST) in all files, so that you can distinguish the calls to my versions of the algorithm from those of OpenCV, since it is still necessary to have OpenCV for all imgproc functions, core, Mat class ... used inside the cpp files modified.

So far so good, it works, I am able to use my version of ORB copied and eventually apply changes to the algorithm.

Problems arise when I switch to Android NDK. What I do, after setting a project with NDK, is to create a JNI method in which I implement the code that will use the algorithm ORB, then I import my files .cpp and .hpp above, set the .mk file and other related stuffs to compile my files, and obviously set up the project to use OpenCV4Android.

The problem is the following: my algorithm works, the code is compiled/builded and launched by Eclipse ADT, and I'm able to call myORB class. However when I open my version of the files, for istance (my)orb.cpp, in the editor of ADT, problems arise: the code has dozens of errors, relative to (opencv) methods non exsisting ("could not be resolved"), (opencv) methods called with invalid arguments ... So after I've opened the file it shows the errors, and then it's impossible to build the project in ADT again, but if I delete and copy back the .cpp file into the project it is compiled again without problems until I open it again...

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2013-07-19 03:37:07 -0600

ShadowTS gravatar image

The problem is due to Android ADT and/or Android NDK. The editor identifies false errors, in fact, the Console indicates that the C code is compiled without errors. However, Eclipse does not allow to run code/apps which, according to him, contains errors. So the fastest way to get around this is to modify the properties of the project in:

Project -> Properties -> C / C + + General -> Code Analysis

changing the "severity" of the "problems" that appear in the editor to "warning" or other types.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-06-25 11:33:33 -0600

Seen: 759 times

Last updated: Jul 19 '13