I want to use OpenCV for the Android app I am currently working on, written in Java.
To setup OpenCV, I followed exactly the steps explained on this page as well as on this one (tried both solutions without success). When I then let my project rebuild it works, but when I let my code run, it fails when trying to do the following:
fdetector = FeatureDetector.create(FeatureDetector.SURF);
The error I get is java.lang.UnsatisfiedLinkError: Native method not found: org.opencv.features2d.FeatureDetector.create_0:(I)J
, kind of the same as in the aforementioned question page. I tried all solutions proposed on this page but none of them worked for me.
I do have installed JNI, so I guess this is not the problem. Or m My setup is the following:
-app
|-libs (with my other app libraries, including javacv.jar)
|-src
|-main
|-java (with my code)
|-res
|-jniLibs (with the .so files from the OpenCV's sdk\native\libs\x86)
|-build.gradle
-libs
|-opencv
|-build
|-jniLibs (with the same .so files as I was not sure where to put them)
|-res
|-src
|-build.gradle
My app's build.gradle contains the following dependencies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'libs', include: ['*.java'])
compile fileTree(dir: 'libs', include: ['*.so'])
compile 'com.android.support:appcompat-v7:21.0.2'
compile project(':libs:opencv')
}
And the opencv's build.gradle contains the following sourceSets:
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
aidl.srcDirs = ['src']
jniLibs.srcDirs = ['jniLibs']
}
}
My settings.gradle contains an include ':libs:opencv'
I really cannot see where I did something wrong, can anyone help me with this?