Note that there are some explanatory texts on larger screens.

plurals
  1. POjava.lang.OutOfMemoryError in opencv in android
    text
    copied!<p>I am trying to use opencv in android.After so many difficulties i finally manage to run it in my device.But unfortunately it is not working.When i am trying to capture the image i am facing two problem:- 1.The camera is showing 90 degree horizontal. 2.When i click "capture" it is getting crashed.</p> <p>Here is my code:</p> <pre><code>/** Handles data for raw picture */ PictureCallback rawCallback = new PictureCallback() { public void onPictureTaken(byte[] data, Camera camera) { if (data != null) { bmp = BitmapFactory.decodeByteArray(data, 0, data.length); findViewById(R.id.img).setVisibility(View.VISIBLE); ((ImageView) findViewById(R.id.img)).setImageBitmap(bmp); findViewById(R.id.preview).setVisibility(View.GONE); if (pg != null) pg.dismiss(); ok_button.setVisibility(View.VISIBLE); click_button.setVisibility(View.GONE); try_again_button.setVisibility(View.VISIBLE); } } }; /** Handles data for jpeg picture */ PictureCallback jpegCallback = new PictureCallback() { public void onPictureTaken(byte[] data, Camera camera) { if (data != null) { bmp = BitmapFactory.decodeByteArray(data, 0, data.length); findViewById(R.id.img).setVisibility(View.VISIBLE); ((ImageView) findViewById(R.id.img)).setImageBitmap(bmp); findViewById(R.id.preview).setVisibility(View.GONE); if (pg != null) pg.dismiss(); ok_button.setVisibility(View.VISIBLE); click_button.setVisibility(View.GONE); try_again_button.setVisibility(View.VISIBLE); } } }; </code></pre> <p>The error in the logcat :</p> <pre><code>07-02 15:31:51.875: E/AndroidRuntime(30198): FATAL EXCEPTION: main 07-02 15:31:51.875: E/AndroidRuntime(30198): java.lang.OutOfMemoryError 07-02 15:31:51.875: E/AndroidRuntime(30198): at android.graphics.BitmapFactory.nativeDecodeByteArray(Native Method) 07-02 15:31:51.875: E/AndroidRuntime(30198): at android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:430) 07-02 15:31:51.875: E/AndroidRuntime(30198): at android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:447) 07-02 15:31:51.875: E/AndroidRuntime(30198): at org.opencv.face.Sample3Native$4.onPictureTaken(Sample3Native.java:209) 07-02 15:31:51.875: E/AndroidRuntime(30198): at android.hardware.Camera$EventHandler.handleMessage(Camera.java:687) 07-02 15:31:51.875: E/AndroidRuntime(30198): at android.os.Handler.dispatchMessage(Handler.java:99) 07-02 15:31:51.875: E/AndroidRuntime(30198): at android.os.Looper.loop(Looper.java:137) 07-02 15:31:51.875: E/AndroidRuntime(30198): at android.app.ActivityThread.main(ActivityThread.java:4441) 07-02 15:31:51.875: E/AndroidRuntime(30198): at java.lang.reflect.Method.invokeNative(Native Method) 07-02 15:31:51.875: E/AndroidRuntime(30198): at java.lang.reflect.Method.invoke(Method.java:511) 07-02 15:31:51.875: E/AndroidRuntime(30198): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823) 07-02 15:31:51.875: E/AndroidRuntime(30198): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590) 07-02 15:31:51.875: E/AndroidRuntime(30198): at dalvik.system.NativeStart.main(Native Method) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload