Unsatisfied Link Error - OpenCV for Android Non-native
After a bunch of searching, I found this:
"3. 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/."
So that means copy the \armeabi, \armeabi-v7a, and \x86 folders.
"4. The last step of enabling OpenCV in your application is Java initialization code before call to OpenCV API. It can be done, for example, in the static section of the Activity class, which gets executed only once, before any instance of the class is created:
static {
if (!OpenCVLoader.initDebug()) {
// Handle initialization error
}
}
Alternatively, you can put it inside the onCreate method:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_load_image);
if (!OpenCVLoader.initDebug()) {
// Handle initialization error
}
[...]
}
Now it works!
you should use
if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mOpenCVCallBack))
{
Log.e("TEST", "Cannot connect to OpenCV Manager");
}
in OnCreate() And use
private BaseLoaderCallback mOpenCVCallBack = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status) {
switch (status) {
case LoaderCallbackInterface.SUCCESS:
{
Mat Image = Highgui.imread("/image.jpg");
if (Image == null) {
AlertDialog ad = new AlertDialog.Builder(this).create();
ad.setMessage("Fatal error: can't open /image.jpg!");
}
} break;
default:
{
super.onManagerConnected(status);
} break;
}
}
};