I am developing an Android Application that captures an image then processes it using opencv functions, then returns the resulting image and displays it in image view. How can I save the captured image temporarily in order to process it?
public class Camera extends Activity 
{
    ImageView imgview;
    Bitmap Bmp;
    final static int cameraData=0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.camera);
         imgview= (ImageView) findViewById(R.id.imgview);
        Intent i=new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(i,cameraData);
    }
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // TODO Auto-generated method stub
        super.onActivityResult(requestCode, resultCode, data);
        if(resultCode == RESULT_OK)
        {
            Bundle extras=data.getExtras();
            Bmp=(Bitmap)extras.get("data");
            imgview.setImageBitmap(Bmp);
        }
    }
}
You can save the bitmap to the cache folder of the application as follows:
String destFolder = getCacheDir().getAbsolutePath();
FileOutputStream out = new FileOutputStream(destFolder + "/myBitamp.png");
bmp.compress(Bitmap.CompressFormat.PNG, 100, out);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With