Problem loading the jni lib with OCV Manager
Hello,
I had a simple app for LK tracking that was basically built following and slightly the "Tutorial 2 - mix Java+Native" of a older version of OCV (2.3.x i think). So now I'm trying to update the application in order to use it with the 2.4.3.
I succesfully managed to slightly change the code so i can use the 2.4.3 in a static way. Now I'd like to go further and update it to use the OCV Manager. Here come the problems. :(
Let me first recall that the architecture of the app is exactly the same as the old sample i mentioned before, so we have 3 files, with the main TrackingActivity, the TrackerBase Class with the threaded structure and the Tracker derived class that implements the method to be called whenever a frame is available.
I removed all the code for static loading and added the new way of interacting with the manager to the main activity
public class TrackingActivity extends Activity
{
...
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status)
{
switch (status) {
case LoaderCallbackInterface.SUCCESS:
{
Log.i(TAG, "OpenCV loaded successfully");
// Load native library after(!) OpenCV initialization
System.loadLibrary("LKTracker");
} break;
default:
{
Log.e(TAG, "problem loading OCV?");
super.onManagerConnected(status);
} break;
}
}
};
...
...
@Override
protected void onResume()
{
// TODO Auto-generated method stub
super.onResume();
if( !OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback) )
{
Log.e(TAG, "Cannot connect to OpenCV Manager");
}
}
So far so good. I also changed all the .mk files to resemble those of the official documentation and of the new samples of OCV 2.4.3. When i tried to execute the application (both on real devices and on the AVD) the OpenCV Manager is connected succefully and then when it comes to
System.loadLibrary("LKTracker");
I get this exception
11-06 14:46:31.224: I/Tracking::Activity(1461): OpenCV loaded successfully
11-06 14:46:31.224: D/dalvikvm(1461): Trying to load lib /data/data/com.example.lktracker/lib/libLKTracker.so 0x412a4d98
11-06 14:46:31.224: D/AndroidRuntime(1461): Shutting down VM
11-06 14:46:31.224: W/dalvikvm(1461): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
11-06 14:46:31.244: E/AndroidRuntime(1461): FATAL EXCEPTION: main
11-06 14:46:31.244: E/AndroidRuntime(1461): java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1285]: 36 cannot locate '_ZN2cv12_OutputArrayD1Ev'...
11-06 14:46:31.244: E/AndroidRuntime(1461): at java.lang.Runtime.loadLibrary(Runtime.java:370)
11-06 14:46:31.244: E/AndroidRuntime(1461): at java.lang.System.loadLibrary(System.java:535)
11-06 14:46:31.244: E/AndroidRuntime(1461): at fr.lab.gipsa.lktracker.TrackingActivity$1.onManagerConnected(TrackingActivity.java:62)
11-06 14:46:31.244: E/AndroidRuntime(1461): at org.opencv.android.AsyncServiceHelper$1.onServiceConnected(AsyncServiceHelper.java:314)
11-06 14:46:31.244: E/AndroidRuntime(1461): at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1068)
11-06 14:46:31.244: E/AndroidRuntime(1461): at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1085)
11-06 ...
Ok my bad... I was actually using the trunk version of OCV to build while on the devices i still had the OCV 2.4.3 binary version. As soon as i made everything coherent with the binary version it worked.