简体   繁体   中英

Calling native opencv, from native c++ files in Android

really struggling here. Basically, I have a whole bunch of c++ files from an iOS project that use opencv and work fine.

Now, I'm trying to port to Android. So what I need to be able to do is, pull the existing c++ files that I have into the Android project as a shared library, and still be able to call the native opencv c++ methods. Is this possible?

I know the java implementation is just a bunch of wrappers over the c++ code but I can't seem to find a way to call the native c++ code from other c++ files in the project. Any help is appreciated. Thanks

Steve

Have you tried using Android NDK (Native Development Kit) ? It allows you to use c/c++ code in Android. But you cannot simply import the library into your app, you need to build it using NDK (the .SO file) and it will generates script which act as linker to the code.

If I understand you correctly, you need to interface to opencv at the native layer (not through a Java API). You should be able to grab the .so library for your target platform along with necessary headers and build against it using the NDK.

If your application project doesn't have a JNI part, just copy the corresponding OpenCV native libs from /sdk/native/libs/ to your project directory to folder libs/.

source

There are many ways to set up an NDK build. The more recent versions of CMake (>=3.7.2) make it relatively painless to cross compile. See this page

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM