Using OpenCv Contrib for android modules

Is there any way to use opencv contrib modules in android? I specifically use a text module. Is there any Android for these modules. I have my desktop code and am trying to port my codes to Android. Any insight would be gr8.

+6
source share
3 answers

I am having trouble figuring out solutions to these problems. I thought I would find the appropriate question and answer the community if others are also looking for solutions to problems like this and mine. Compilation was done on the Macbook Retina 13 ".

The instructions provided are somewhat incomplete, and additional steps are required to obtain the final product.

In the beginning, you will follow the standard procedure described on the Internet.

$ cd <opecv_directory> $ mkdir build $ cd <opencv_build_directory> $ cmake -D OPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules <opencv_source_directory> $ make -j5 $ make install 

In addition to this, you may encounter an error or two errors. I needed to install some missing components in order to get past things that were missing, but this may be different for you (I investigated the errors and realized that I needed additional components)

 brew install ninja brew install oxygen brew install ant 

I also ran into a bug with one module asking for the following declaration in the source code (or with compiler flags):

 #define SOLARIS_64BIT_ENABLED 

Another thing you can do is remove other modules in the contrib folder that may not be of interest at compile time. Just turn on the modules you want and hopefully those that are good. I did this simply by deleting one or two from the / modules folder and then re-running the python script.

To start the assembly, you need the final python script. I created a directory next to the main source tree and the contrib folder.

 OpenCVSource -> opencv -> opencv_contrib -> android_opencv_build 

The call below was made from the directory in which I want the assembly to run, so I went to the directory. The challenge was as follows:

 python ../opencv/platforms/android/build_sdk.py --extra_modules_path ../opencv_contrib/modules --ndk_path <your-path-to-ndk-top-level-folder> --sdk_path <your-path-to-sdk-top-level-folder> ./ ../opencv 

This only creates the .so files needed to use the library, but does not create the .jar file that you will need to use the new binaries. To do this, go to your build folder (mine, as you can see, in android_opencv_build / OpenCV-android-sdk)

Download this project in Eclipse in the standard way by importing an existing Android project into the workspace. You really only need the / sdk project, but if you want, you can also download samples. Then create a project. You may need to change the target assembly to support the new camera APIs for a successful assembly; in my case, changing the target to API level 21.

Then you will find the .jar file in the / bin directory of the project. The .jar and .so files found in the file android_opencv_build / OpenCV-android-sdk / sdk / native / jni / contain the necessary .so files that you will need to add to the project / lib folder next to this jar.

You should now have everything you need. Since we work with Contrib modules (or not, if you build it for other reasons), it is possible that you will encounter other errors during the assembly process that are not stable enough and require some attention. This may not help, but people are free to add comments to other people's decisions and this post to help them solve them if they find a solution.

+2
source

I ran into the same problem after some work came up with a pretty nice self-evident article for creating opencv with additional modules. Link to the same: here

And in case someone wants to use the already built opencv wizard with additional Contrib modules, they can freely use it from their repo, the link for it is this , this article only works with windows, just for information, as I couldn’t follow the same on mac.

0
source

We published packaged assemblies. Aar for opencv android for jcenter. Feel free to use our packages: https://github.com/quickbirdstudios/opencv-android

 dependencies { // opencv 3.4.1 implementation 'com.quickbirdstudios:opencv:3.4.1' // opencv 3.4.4 with contribution packages implementation 'com.quickbirdstudios:opencv:3.4.4-contrib' } 
0
source

Source: https://habr.com/ru/post/986454/


All Articles