誰かがまだ答えを探している場合:
package com.example.ocv4androidwithoutcamera;
import org.opencv.android.BaseLoaderCallback;
import org.opencv.android.InstallCallbackInterface;
import org.opencv.android.LoaderCallbackInterface;
import org.opencv.android.OpenCVLoader;
import org.opencv.core.Mat;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.widget.Toast;
public class MainActivity extends Activity implements LoaderCallbackInterface {
protected BaseLoaderCallback mOpenCVCallBack = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status) {
switch (status) {
case LoaderCallbackInterface.SUCCESS:
{
onOpenCVReady();
} break;
default:
{
super.onManagerConnected(status);
} break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
protected void onResume()
{
super.onResume();
Log.i("DEMO", "Trying to load OpenCV library");
if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_4, this, mOpenCVCallBack))
{
Log.e("DEMO", "Cannot connect to OpenCV Manager");
}
}
protected void onOpenCVReady(){
//this should crash if opencv is not loaded
Mat img = new Mat();
Toast.makeText(getApplicationContext(), "opencv ready", Toast.LENGTH_LONG).show();
}
@Override
public void onManagerConnected(int status) {
// TODO Auto-generated method stub
}
@Override
public void onPackageInstall(int operation,
InstallCallbackInterface callback) {
// TODO Auto-generated method stub
}
}
Project Properties => Android => Library に opencv ライブラリを追加することを忘れないでください。