Getting camera preview data without using a preview callback

Posted by velocipedestrian on Stack Overflow See other posts from Stack Overflow or by velocipedestrian
Published on 2012-06-21T09:13:50Z Indexed on 2012/06/21 9:16 UTC
Read the original article Hit count: 220

I have an app that does some processing to camera preview frames before displaying them to the user. I'm currently using preview callbacks to access the image data, but the problem I have is that the onPreviewFrame() function stops getting called if you start recording video using a MediaRecorder, and I want the processing to continue when video is being recorded. I've tried doing the following:

public static Bitmap convertViewToBitmap(View view)
{
    Bitmap bitmap = Bitmap.createBitmap(view.getWidth(),view.getHeight(), Bitmap.Config.ARGB_8888);                
    view.draw(new Canvas(bitmap));
    return bitmap;
}

to convert the preview surface to a bitmap, but when I pass the preview SurfaceView to the function it returns an all-black bitmap (it works when I test it on normal views though). Is there any other way I can access the image data if preview callbacks are not available?

© Stack Overflow or respective owner

Related posts about android

Related posts about android-camera