hi guys i am new user about android eclipse and opencv. i get some error when bitmap to mat converting.could you look my logcat and say something about this error?
code;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (!OpenCVLoader.initDebug()) {
// Handle initialization error
}
ImageView goster=(ImageView)findViewById(R.id.imageView1);
Bitmap bMap = BitmapFactory.decodeResource(getResources(), R.drawable.testx);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Config.RGB_565;
Bitmap input = BitmapFactory.decodeFile("testx.jpg", options);
Mat mat = new Mat();
// Utils.bitmapToMat(input, mat);
// Highgui.imwrite("mat.jpg", mat);
goster.setImageBitmap(input);
}
}
and logcat
05-24 00:41:11.080: E/AndroidRuntime(7964): FATAL EXCEPTION: main
05-24 00:41:11.080: E/AndroidRuntime(7964): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.new2/com.example.new2.MainActivity}: java.lang.IllegalArgumentException: bmp == null
05-24 00:41:11.080: E/AndroidRuntime(7964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
05-24 00:41:11.080: E/AndroidRuntime(7964): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
05-24 00:41:11.080: E/AndroidRuntime(7964): at android.app.ActivityThread.access$600(ActivityThread.java:130)
05-24 00:41:11.080: E/AndroidRuntime(7964): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
05-24 00:41:11.080: E/AndroidRuntime(7964): at android.os.Handler.dispatchMessage(Handler.java:99)
05-24 00:41:11.080: E/AndroidRuntime(7964): at android.os.Looper.loop(Looper.java:137)
05-24 00:41:11.080: E/AndroidRuntime(7964): at android.app.ActivityThread.main(ActivityThread.java:4745)
05-24 00:41:11.080: E/AndroidRuntime(7964): at java.lang.reflect.Method.invokeNative(Native Method)
05-24 00:41:11.080: E/AndroidRuntime(7964): at java.lang.reflect.Method.invoke(Method.java:511)
05-24 00:41:11.080: E/AndroidRuntime(7964): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
05-24 00:41:11.080: E/AndroidRuntime(7964): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-24 00:41:11.080: E/AndroidRuntime(7964): at dalvik.system.NativeStart.main(Native Method)
05-24 00:41:11.080: E/AndroidRuntime(7964): Caused by: java.lang.IllegalArgumentException: bmp == null
05-24 00:41:11.080: E/AndroidRuntime(7964): at org.opencv.android.Utils.bitmapToMat(Utils.java:90)
05-24 00:41:11.080: E/AndroidRuntime(7964): at org.opencv.android.Utils.bitmapToMat(Utils.java:102)
05-24 00:41:11.080: E/AndroidRuntime(7964): at com.example.new2.MainActivity.onCreate(MainActivity.java:41)
05-24 00:41:11.080: E/AndroidRuntime(7964): at android.app.Activity.performCreate(Activity.java:5008)
05-24 00:41:11.080: E/AndroidRuntime(7964): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
05-24 00:41:11.080: E/AndroidRuntime(7964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
05-24 00:41:11.080: E/AndroidRuntime(7964): ... 11 more