Getting camera preview data without using a preview callback
- by velocipedestrian
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?