Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Porting from Desktop C++ to Android NDK

My intention is to test some modifications to an algorithm, in particular ORB feature detector and descriptor. So 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 the ORB, the third and fourth are necessary as called with "includes" in fast.cpp. Obviously I copied the headers and method declarations from .hpp OpenCV 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 to those of OpenCV, since OpenCV is still necessary 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 import my files .cpp and .hpp above, set the .mk file and other related stuffs to compile my files.

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

Porting from Desktop C++ to Android NDK

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 the ORB, the third and fourth are necessary as called with "includes" in fast.cpp. Obviously I copied the headers and method declarations from .hpp 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 to from those of OpenCV, since OpenCV 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.files, and obviously set up the project to use OpenCV4Android.

The problem is the following: my algorithm works, the code is compiled compiled/builded and launched in by Eclipse ADT, and I'm able to call myORB. myORB class. However when I open my version of the files, for istance orb.cpp, (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 open I've opened the file it shows the errors, and then it's impossible to build the project in ADT, 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.it again...