Here is just a simple way I made it working:
OpenCV for iOS (downloaded version or build by yourself from sources) doesn't contain the jni support layer needed fo Java integration.
Ways which didn't work:
I tried to modify the OpenCV framework build process in order to include it - it didn't work as intended and I gave up due to the complexity of the build scripts and the speed they are developing.
I tried to convince the OpenCV developers to add Java support to the iOS-framework - no reaction.
Thus I decided to do it pragmatically:
The idea is:
- the jni-layer is a very thin one containing only wrapper code and conversion functionality
- this layer can be added to the OpenCV-framework at that point in time when you are building your app
You need the jni support sources and an opencv-*.jar.
If you download the OpenCV sources you will find some of the needed sources there:
(common.h converters.cpp converters.h jni_part.cpp Mat.cpp utils.cpp)
The missing sources will be created automatically if you build OpenCV for a platform where Java support can be activated easily - I did it on Linux.
Then you find the needed other sources there opencv.build/modules/java:
calib3d.cpp core.cpp features2d.cpp imgcodecs.cpp imgproc.cpp ml.cpp objdetect.cpp photo.cpp video.cpp videoio.cpp
The opencv-*.jar will be created in opencv.build/bin
- add all these sources to the Xcode part of my MOE app
(the following configuration changes must be done in the target-configuraton: Build Settings, Build Phases)
- add OpenCV framework to Xcode part of MOE
- add frameworks needed by OpenCV framework to Xcode part of MOE app: CoreMedia, CoreVideo, CoreGraphics, AVFoundation (sufficient for my case - maybe others could be needed too depending of OpenCV functionality used in app)
- add needed framework and header search paths to Xcode part of MOE app
- solve header include problems
- in core.cpp comment out the following line: cv::setErrorVerbosity( ... in a Method called Java_org_opencv_core_Core_setErrorVerbosity_10
- remove features2d.cpp from Xcode sources (didn't link and I didn't need it -> an issue still to be solved)
- create precompiled header project.pch containing the following lines:
#ifdef _ _cplusplus
#ifdef _ _OBJC _ _
(I had to add extra spaces in the underscore sequences to be displayed properly)
- under Product/Perform Action compile pch-file
- close XCode project
- add the opencv-*.jar to the libs folder of your app
- create a proguard.append.cfg in your ios module folder (if it didn't exist already)
- add the following line to it: -keep class org.opencv.core.CvException
- build and run your MOE app with OpenCV based functionality
Issue: The feature2d.cpp linking problem is still to be solved ...